[Top] [Up] [Prev] [Next] [Up] [Basic Concepts] [Demonstrations] [Functions] SDC Morphology Toolbox V1.1 15Jan02

mmdleaf - Segment a leaf from the background


Description
This experiment demonstrate the use of the toggle to segment an image with ill defined borders.

Reading

The gray scale image to be processed is read.

f = mmreadgray('leaf.tif');
mmshow(f);
image
(f)

Simple thresholding

Although the leaf was pictured on a light background, it is not possible to fully segment the leaf using a simple thresholding

f_low=mmthreshad(f,100);
Warning: Converting image from scalar to uint8.
f_med=mmthreshad(f,128);
Warning: Converting image from scalar to uint8.
f_high=mmthreshad(f,160);
Warning: Converting image from scalar to uint8.
mmshow(f_low);
mmshow(f_med);
mmshow(f_high);
image
(f_low)
image
(f_med)
image
(f_high)

Toggle

The toggle is a non-linear image enhancement that changes the pixel value to the maximum or the minimum in the neighborhood given by the structure element, depending which one is the nearest value. The result of the toggle is that near the edges, the image is better defined.

f1=mmtoggle(f,mmero(f,mmsedisk(7)),mmdil(f,mmsedisk(7)));
mmshow(f1);
image
(f1)

Thresholding and area open

The thresholding can now be applied resulting a good definition of the leaf boarder. Small white spots can be removed by the area open filter.

f2=mmthreshad(f1,100);
Warning: Converting image from scalar to uint8.
f3=mmareaopen(f2,80);
mmshow(f2);
mmshow(f3);
image
(f2)
image
(f3)

Final display

For illustration, the contour of the segmented leaf is overlayed in red in the original image

f4=mmgradm(f3);
mmshow(f,f4);
image
(f,f4)

[Top] [Up] [Prev] [Next] [Up] [Basic Concepts] [Demonstrations] [Functions] Valid XHTML 1.0!
Copyright (c) 1998-2002 by SDC Information Systems