Learn R Programming

rcaiman (version 2.0.1)

defuzzify: Defuzzify a fuzzy classification

Description

Converts fuzzy membership values into a binary classification using a regional approach that preserves aggregation consistency between the fuzzy and binary representations.

Usage

defuzzify(mem, segmentation)

Value

Logical terra::SpatRaster of the same dimensions as mem, where each pixel value represents the binary version of mem after applying the regional defuzzification procedure.

Arguments

mem

numeric terra::SpatRaster of one layer. Degree of membership in a fuzzy classification.

segmentation

single-layer terra::SpatRaster with integer values.

Details

The conversion is applied within segments defined by segmentation, ensuring that, in each segment, the aggregated Boolean result matches the aggregated fuzzy value. This approach is well suited for converting subpixel estimates, such as gap fraction, into binary outputs.

Examples

Run this code
if (FALSE) {
caim <- read_caim()
r <- caim$Blue
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)

path <- system.file("external/example.txt", package = "rcaiman")
sky_cie <- read_sky_cie(gsub(".txt", "", path), z, a)

sky_above <- ootb_sky_above(sky_cie$model$rr$sky_points, z, a, sky_cie)

ratio <- r / sky_above$dn_raster
ratio <- normalize_minmax(ratio, 0, 1, TRUE)
plot(ratio)
g <- sky_grid_segmentation(z, a, 10)
bin2 <- defuzzify(ratio, g)
plot(bin2) # unsatisfactory results due to light conditions
}

Run the code above in your browser using DataLab