The same principle of the binary top hat by reconstruction can be applied for gray-scale images. The extension of the binary case for the gray-level case is a very powerful concept which is exploitation is still in its infancy. Just to mention a few implications of this extension we can view the connectedness of the pixels in the binary case as a gray-scale connectedness definition for gray-scale images.
In this experiment we have the same goal used in the binary case, which is to identify and separate the holes of the PCB. We use the original gray-scale image. The gray-scale top hat is applied first and the thresholding is the last step used for segmentation. The thresholding is this situation, when applied later in the process is normally very robust, and the thresholding applied as the first step normally does not work. So, as a general rule, we should try to solve the problem in the gray-scale domain as much as possible and making use of the thresholding at the last stage of the processing.
We show below the original image and an initial attempt trying to threshold the image directly. We can see that although the holes are very bright compared to the other features in the image, a simple global threshold does not give good results and its value is very dependent on the image and is normally chosen manually.
|
|
|---|---|
| a) | b) |
We use the same marker as used in the binary case. We can see the reconstruction as a gray-scale connectedness function where the values in the resultant image gives a measure of its connectivity to the marker image. This is a very intuitive approach that can be further investigated and properly defined. Below we show the marker and the reconstructed images.
|
|
|---|---|
| a) | b) |
The top hap will give the degree of discrepancy of gray-scale non-connectivity to the frame. In this particular example, will give very high for the holes. Below is show the gray-scale top hat and the final thresholded image. The choice of the threshold in this case is very robust and can be set automatically.
|
|
|---|---|
| a) | b) |