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

mmdgear - Detect the teeth of a gear


Description
The input image is a binary image of a gear. The opening top-hat is used to detect the gear teeth. Finally, the teeth detected are labeled.

Reading

The binary image of a gear is read.

a = mmreadgray('gear.tif');
mmshow(a);
image
(a)

Opening and subtraction

Opening of the input image by an Euclidean disk of radius 20. The sequence opening-subtraction is called opening top-hat. The opening top-hat could be executed in a single command: c = mmopenth(a,mmsedisk(20));

b = mmopen(a,mmsedisk(20));
mmshow(b);
c = mmsubm(a,b);
mmshow(c);
image
(b)
image
(c)

Labeling and counting

The teeth detected are labeled. The maximum pixel value in the labeled image gives the number of connected objects (n. of teeth).

d = mmlabel(c);
nteeth=mmstats(d,'max')

nteeth =
    24
mmlblshow(d,'border');
image
(d,'border')

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