rangefilt

Local range of image

Syntax

J = rangefilt(I)
J = rangefilt(I, NHOOD)

Description

J = rangefilt(I) returns the array J, where each output pixel contains the range value (maximum value − minimum value) of the 3-by-3 neighborhood around the corresponding pixel in the input image I. The image I can have any dimension. The output image J is the same size as the input image I.

J = rangefilt(I, NHOOD) performs range filtering of the input image I where you specify the neighborhood in NHOOD. NHOOD is a multidimensional array of zeros and ones where the nonzero elements specify the neighborhood for the range filtering operation. NHOOD's size must be odd in each dimension.

By default, rangefilt uses the neighborhood true(3). rangefilt determines the center element of the neighborhood by floor((size(NHOOD) + 1)/2). For information about specifying neighborhoods, see Notes.

Class Support

I can be logical or numeric and must be real and nonsparse. NHOOD can be logical or numeric and must contain zeros or ones.

The output image J is the same class as I, except for signed integer data types. The output class for signed data types is the corresponding unsigned integer data type. For example, if the class of I is int8, then the class of J is uint8.

Notes

rangefilt uses the morphological functions imdilate and imerode to determine the maximum and minimum values in the specified neighborhood. Consequently, rangefilt uses the padding behavior of these morphological functions.

In addition, to specify neighborhoods of various shapes, such as a disk, use the strel function to create a structuring element object and then use the getnhood method to extract the neighborhood from the structuring element object.

Examples

expand all

Identify Objects in 2-D Image

I = imread('liftingbody.png');
J = rangefilt(I);
imshow(I), figure, imshow(J);

Quantify Land Cover Changes in an RGB (3-D) Image

Read an image and convert color space from RGB to LAB.
I = imread('autumn.tif');
cform = makecform('srgb2lab');
LAB = applycform(I, cform);

Perform the range filtering on the LAB image.

rLAB = rangefilt(LAB);

Display the images.

imshow(I);
figure, imshow(rLAB(:,:,1),[]);
figure, imshow(rLAB(:,:,2),[]);
figure, imshow(rLAB(:,:,3),[]);

Was this topic helpful?