Skip to contents

Takes HSV-formatted pixel.array and bounds. When determining which pixels lie within the bounds, only the hue- and saturation- values are respected. The value-component is not considered.

Usage

rectangularRange_HSV(pixel.array, upper_bound, lower_bound, check_V = FALSE)

Arguments

pixel.array

image array as loaded via duflor::load_image()

upper_bound

EITHER:

  • list of upper HSV-bounds, e.g. list(green = c(H_green_lower,S_green_lower,V_green_lower),drought = c(H_drought_lower,S_drought_lower,V_drought_lower))

  • single vector of length 3 declaring a set of HSV-values

lower_bound

see upper_bound

check_V

boolean toggle to also check the VALUE-component of an HSV-pixel

Value

upon success, returns a list-object with the following elements:

  • pixel.idx - pixel-locations of pixels detected between lower and upper bound.

  • pixel.count - number of pixels detected between lower and upper bound

  • img.fraction - fraction of image detected between lower and upper bound

  • original.img - fed-in pixel.array

Upon failure to find any matching pixels, an empty matrix of dimensions [0, 1:2] is returned

Note

The use of rectangularRange_HSV_cpp() is strongly suggested due to its drastically faster execution. Adopted from countcolors::rectangularRange, reworked to work in HSV color space instead of RGB and simplified.

Examples

if (FALSE) {
rectangularRange_HSV(
    pixel.array = pixel.array,
    lower_bound = an_lower_bound,
    upper_bound = an_upper_bound
)
}