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

mmdruler - Detect defects in a ruler.


Description
The input image is a gray-scale image of a ruler, that has a number touching a tick mark. This number and mark are detected based on morphological and connected filtering.

Reading

The gray-scale image of the ruler is read.

a = imread('mm3.tif');
mmshow(a);
image
(a)

Segmentation

The close top-hat operator followed by a thresholding is applied.

b = mmthreshad( mmcloseth(a,mmsebox(5)),40);
Warning: Converting image from scalar to uint8.
mmshow(b);
image
(b)

Size filtering

The vertical lines longer than 50 pixels are detected.

c = mmopen(b,mmseline(50,90));
mmshow(c);
image
(c)

Ruler tick marks filtering

It closes ruler tick marks gaps.

d =mmclose(c,mmseline(15));
mmshow(d);
image
(d)

Ruler tick marks connection

It detects all objects connected to the ruler tick markers.

e = mminfrec(d,b);
mmshow(e);
image
(e)

Ruler tick mark vertical connection

It detects all objects vertically connected to the ruler tick mark. Note that the 3x1 rectangle is used as structuring element in the vertical reconstruction.

f = mminfrec(d,b,mmseline(3,90));
mmshow(f);
image
(f)

Non ruler tick mark vertical connection

The residues obtained from the previous image.

g = mmsubm(e,f);
mmshow(g);
image
(g)

Ruler tick marks detection

It uses an opening by an elementary cross structuring element to eliminate the artifacts.

h = mmopen(g);
mmshow(h);
image
(h)

Objects detection

It detects the objects connected to ruler tick marks. A reconstruction from the ruler marks detected is applied.

i = mminfrec(h, b);
mmshow(i);
image
(i)

Final presentation

Overlay the detected defect over the original image

mmshow(a,i);
image
(a,i)

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