MATLAB: How to compute gray-level difference of an image….

gray-level differenceImage Processing Toolbox

Please can someone help me to compute the "gray-level difference" of image…
i need to get an answer like [2 -2 -1 1 -2 -4 -3 3]
somewhat of this range digits of "0 – 7" range….
i tried many codes available in the net… but from none of them i got such an output in the range "0 – 7' for an image patch…
My images are of size 32 X 32 and of patch size 8…. please do someone reply me…..

Best Answer

Use the rangefilt() function.
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.
Use imerode() to get the min value in a window, and imdilate() to get the max value in a window.
Related Question