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);
|
| (a) |
|
|
Segmentation
The close top-hat operator followed by a thresholding is applied.
Size filtering
The vertical lines longer than 50 pixels are detected.
Ruler tick marks filtering
It closes ruler tick marks gaps.
Ruler tick marks connection
It detects all objects connected to the ruler tick markers.
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.
Non ruler tick mark vertical connection
The residues obtained from the previous image.
Ruler tick marks detection
It uses an opening by an elementary cross structuring element to eliminate the artifacts.
Objects detection
It detects the objects connected to ruler tick marks. A reconstruction from the ruler marks detected is applied.
Final presentation
Overlay the detected defect over the original image