You are here : matlabImage Processinggraydiffweight

graydiffweight() - Image Processing

W = graydiffweight(I,refGrayVal) computes
the pixel weight for each pixel in the grayscale image I.
The weight is the absolute value of the difference between the intensity
of the pixel and the reference grayscale intensity specified by the
scalar refGrayVal. Pick a reference grayscale
intensity value that is representative of the object you want to segment.
The weights are returned in the array W, which
is the same size as input image I. The weight of a pixel is inversely related to the absolute value
of the grayscale intensity difference at the pixel location. For pixels
with small difference (regions with intensity close to refGrayVal),
the weight value is large, and for pixels with large difference (regions
with intensity very different from refGrayVal),
the weight value is small.W = graydiffweight(I,mask) computes
the pixel weights for each pixel in the grayscale image I,
where the reference grayscale intensity value is the average of the
intensity values of all the pixels in I that
are marked as logical true in mask. Using the
average of several pixels to calculate the reference grayscale intensity
value can be more effective than using a single reference intensity
value, as in the previous syntax.W = graydiffweight(I,C,R) computes
the pixel weights for each pixel in the grayscale image I,
where the reference grayscale intensity value is the average of the
intensity values of the pixel locations specified by C and R. C and R are
vectors containing the column and row indices of the pixel locations. C and R must
contain values which are valid pixel indices in I.exampleW = graydiffweight(___, Name,
Value, ...) returns the weight array W using
name-value pairs to control aspects of weight computation.


Syntax

W = graydiffweight(I,refGrayVal)W = graydiffweight(I,mask)W = graydiffweight(I,C,R)W = graydiffweight(___, Name,
Value, ...) example


Example

Calculate Grayscale Intensity Difference WeightsOpen This Example
This example segments an object in an image using Fast Marching Method using grayscale intensity difference weights calculated from the intensity values at the seed locations.
Read image and display it.I = imread('cameraman.tif');
imshow(I)
title('Original Image')

Specify row and column index of pixels for use a reference grayscale intensity value.seedpointR = 159;
seedpointC = 67;
Calculate the grayscale intensity difference weight array for the image and display it. The example does log-scaling of W for better visualization.W = graydiffweight(I, seedpointC, seedpointR,'GrayDifferenceCutoff',25);
figure, imshow(log(W),[])

Segment the image using the grayscale intensity difference weight array. Specify the same seed point vectors you used to create the weight array.thresh = 0.01;
BW = imsegfmm(W, seedpointC, seedpointR, thresh);
figure, imshow(BW)
title('Segmented Image')


Output / Return Value


Limitations


Alternatives / See Also


Reference