You are here : matlabImage Processingimsegfmm

imsegfmm() - Image Processing

BW = imsegfmm(W,mask,thresh) returns
a segmented image BW, which is computed using
the Fast Marching Method. The array W specifies
weights for each pixel. mask is a logical array
that specifies seed locations. thresh is a non-negative
scalar in the range [0 1] which specifies the level
at which imsegfmm thresholds the output of the
Fast Marching Method to obtain the output binary image BW.BW = imsegfmm(W,C,R,thresh) returns
a segmented image, with seed locations specified by the vectors C and R,
which contain column and row indices. C and R must
contain values which are valid pixel indices in W.[BW,D] =
imsegfmm(___) returns the normalized geodesic
distance map D computed using the Fast Marching
Method. BW is a thresholded version of D,
where all the pixels that have normalized geodesic distance values
less than thresh are considered foreground pixels
and set to true. D can be
thresholded at different levels to obtain different segmentation results.


BW = imsegfmm(W,mask,thresh) exampleBW = imsegfmm(W,C,R,thresh)[BW,D] =


Segment Image Using Fast Marching Method AlgorithmOpen This Example
This example shows how to segment an object in an image using Fast Marching Method based on differences in grayscale intensity as compared to the seed locations.
Read image.I = imread('cameraman.tif');
title('Original Image')

Create mask and specify seed location. You can also use roipoly to create the mask interactively.mask = false(size(I));
mask(170,70) = true;
Compute the weight array based on grayscale intensity differences.W = graydiffweight(I, mask, 'GrayDifferenceCutoff', 25);
Segment the image using the weights.thresh = 0.01;
[BW, D] = imsegfmm(W, mask, thresh);
title('Segmented Image')

You can threshold the geodesic distance matrix D using different thresholds to get different segmentation results.figure
title('Geodesic Distances')

Output / Return Value


Alternatives / See Also