defuzzify: Defuzzify a fuzzy classification

defuzzifyR Documentation

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)

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.

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.

Note

This method is also available in the HSP software package. See hsp_compat().

Examples

## Not run: 
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

## End(Not run)

rcaiman documentation built on Sept. 9, 2025, 5:42 p.m.