[mmdflow] [Up] [mmdholecenter] Demonstrations

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.

Demo Script

Reading

The binary image of a gear is read.

a = mmreadgray('gear.tif');
mmshow(a);
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);
b 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')
mmlblshow(d,'border');
d,'border'

[mmdflow] [Up] [mmdholecenter]