mmdcalc - Extract the keys of a calculator.
-
Description
- This procedure detects the keys in a gray-scale image of a calculator. The approach used is watershed Beucher's paradigm. The internal markers are the numbers on the keys and the external markers are obtained by the skiz of the keys background.
Reading
The gray-scale image of the calculator is read.
a = imread('keyb.tif');
mmshow(a);
|
| (a) |
|
|
Gradient image
The image edges are enhanced by the gradient operator.
Inside marker: Opening top-hat
The opening top-hat procedure enhances the small objects relatively to its background. In the calculator image, the digits are enhanced.
Inside marker: Thresholding
The threshold operator is used to separated the enhanced objects. This procedure is quite robust, since the background was reduced to very low levels with the opening top-hat.
Inside marker: Final
In order to have just one object (i.e., connected component) inside each key, a dilation is applied.
Outside markers
The outside markers are built by taking the watershed (skiz) of the complement of internal markers image.
Both markers
The markers used are the union of the internal and external markers detected. They are displayed as overlay on the gradient image.
Constrained watershed
The calculator keys are extracted by applying the watershed operator on the gradient image, constrained by the markers detected.
Show the result
Superposition of the detected contours on the input image.