thr_image: Threshold image

thr_imageR Documentation

Threshold image


Transform background digital number into threshold values.


thr_image(dn, intercept, slope)



Numeric vector or SpatRaster. Digital number of the background. These values should be normalized and, if they are extracted from a JPEG image, gamma back corrected.

intercept, slope

Numeric vector of length one. These are linear function coefficients–see section Details in thr_image.


This function transforms background digital numbers into threshold values by means of the Equation 1 from \insertCiteDiaz2018;textualrcaiman, which is a linear function with the slope modified by a weighting parameter. This simple function was found by studying canopy models, also known as targets, which are perforated surfaces made of a rigid and dark material. These models were backlighted with homogeneous lighting, photographed with a Nikon Coolpix 5700 set to acquire in JPEG format, and those images were gamma back corrected with a default gamma value equal to 2.2 (see gbc). Results clearly shown that the optimal threshold value was linearly related with the background digital number, shifting the aim from finding the optimal threshold to obtaining the background DN as if the canopy was not there. Functions fit_coneshaped_model and fit_trend_surface address that topic.

It is worth noting that Equation 1 was developed with 8-bit images, so calibration of new coefficient should be done in the 0 to 255 domain since that is what thr_image expect, although the input dn should be normalized. The latter was a design decision aiming to harmonize the whole package, although it might sound counter intuitive.

To apply the weighting parameter (w) from Equation 1, just provide the argument slope as slope \times w.

Type thr_image–no parenthesis–in the console to inspect the code, which is very simple to follow.


An object of the same class and dimensions than dn.



See Also

normalize, gbc, apply_thr and regional_thresholding.

Other Binarization Functions: apply_thr(), find_sky_pixels_nonnull(), find_sky_pixels(), obia(), ootb_mblt(), ootb_obia(), regional_thresholding(), thr_isodata()


thr_image(gbc(125), -8, 1)

rcaiman documentation built on Sept. 20, 2022, 1:05 a.m.

Related to thr_image in rcaiman...