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.```

Syntax

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

Example

```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.
imshow(I)
title('Original Image')

Create mask and specify seed location. You can also use roipoly to create the mask interactively.mask = false(size(I));
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);
figure
imshow(BW)
title('Segmented Image')

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