inrangecv

Gets the handle Rto a binary image specifying which pixels are within the specified range.

Syntax

R = inrangecv(cvhandle, lower, upper)

Inputs

cvhandle
Handle of the image from a imreadcv command.
Type: integer
lower
Real vector or scalar containing lower bound element(s). Size of lower must be equal to the number of channels in the image represented by cvhandle.
Type: double | vector
upper
Real vector or scalar containing upper bound element(s). Size of upper must be equal to the number of channels in the image represented by cvhandle.
Type: double | vector

Outputs

R
Handle of the binary image showing specifying which pixels are in range. The output will be the same size as the image represented by cvhandle. Pixels in R will be 0 if they are not in the range and 255 otherwise.
Type: integer

Examples

Apply bitwiseandcv and inrangecv functions to perform cloud detection:
img = imreadcv('Clouds.jpg', 1);
figure(1); 
imshowcv(img);

white_ = [255, 255, 255];
lowerBound = [200,200,200];

mask = inrangecv(img, lowerBound, white_);
res = bitwiseandcv(img, img, mask);

figure(2); 
imshowcv(res);


Figure 1. Input image


Figure 2. Output image
Checks if image is in range with scalar bounds :

cvhandle = imreadcv('image1.jpg');
R = inrangecv(cvhandle, 0, 255);
Checks if image is in range with vector bounds :

cvhandle = imreadcv('image1.jpg');
R = inrangecv(cvhandle, [0 100 0], [255 255 255]);