**3. Morphological filtering**

For the binary image *G*, any set *A* of black pixels, and a (small) pixel set *S* called structuring element, the *dilatation* of *A* by *S* is the set *A* ⊕ *S* of all pixels *p* ¼ *px*, *py* such that *x*<sup>1</sup> ≤*px* ≤*x*max, *y*<sup>1</sup> ≤*py* ≤ *y*max, and *p* ¼ *a* þ *s* ¼ *ax* þ *sx*, *ay* þ *sy* for some *a* ¼ *ax*, *ay* <sup>∈</sup> *<sup>A</sup>*, *<sup>s</sup>* <sup>¼</sup> *sx*, *sy* ∈*S* [27]. Thus, the dilation consists of extending the set of black points in *G* converting into black all pixels of *A* ⊕ *S*. The *erosion* of *A* by *S* is the pixel set *A* Ɵ *S* ¼ f g *p* ∈ *A* : *p* þ *s* ∈ *A*∀*s*∈ *S* . Erosion reduces the set of black points in *G* converting into White all pixels of A which do not belong to *A* Ɵ *S*. Erosion followed by dilation is called morphological opening, whereas morphiological closing is defined as Erosion of a dilated set.

The filters applied to the binarization techniques reported in [27, 28] consists in morphological opening of the set of black pixels in G, by a structuring element distinct from those used in works previously published. Based on the a- priori knowledge that the indentation region has a rhombic shape. Moreover, these binarization techniques use a structuring element *S* of diamond shape of 10 pixels radius. This morphological opening sustantively reduces structural noise of the image, making possible to find the interest object (indentation region) as the largest connected region of black pixels in the next step. In addition, *Binarization Based on Maximum and Average Gray Values DOI: http://dx.doi.org/10.5772/intechopen.99932*

it preserves size and shape of the indentation. Finally, through region growing, which is a standard procedure in image processing the image segmentation is completed. In a binary image, region growing consists in determining all connected components of black pixels, where the algorithms reported in [27, 28] applies 8-connectivity.

**Figure 3** shows images together with their binary versions, and the results of morphological filtering. The first example contains a slightly deformed indentation and the second presents surface imperfections. Nevertheless, many of these types of images present some shading by lots of lighting and additionally, a light sopt in the image center, both problems caused by the light reflection capacity when capturing the image through a camera. Thus, the algortihm semi-automatic reported in [27] is

**Figure 3.**

*Indentation images (first column), binary versions (second column) and morphological filtering (third column).*

**Figure 4.** *Indentation images with low contrast, where the algorithm reported in [27] fails in binarization technique.*

not suitable for indentation images with low contrast in relation to the adjacent image, as show in the **Figure 4**.

### **4. Image segmentation automatically evaluating maximum and average gray values like binarization criteria**

The algorithm reported in [28] uses image segmentation via binarization, automatically evaluating the mean and extreme gray values by means of standard histogram equalization so as to determine the optimal binarization threshold from each input image. The binarization of the input image use the average gray value, a standard histogram applied to the input image, and the difference to the maximum gray values to determine the threshold values ð Þ*τ* for binarization. The highest frquency of occurence *f <sup>h</sup>* ¼ max *h i*ð Þ (where *h i*ð Þ is the histogram of the image with a number *i* of gray values), average *f mean*, and maximum *f* max gray values are global characteristics determined by the input image *F* . Unlike semi-automatic binarization reported in [27], the image segmentation reported in [28] evaluate maximum and average gray values under the following binarization criterion:

$$\left| f(\mathbf{x}, y) - f\_{\text{max}} \right| > \mathfrak{r} \tag{1}$$

The binarization using (1) with *τ* ¼ *τ*<sup>0</sup> ¼ *f mean* is applied to indentation images with gray levels distribuided along the dynamic range of *h i*ð Þ as shown in **Figure 5**, where *f mean* ffi *f <sup>h</sup>* and *f mean* are located to approximately half of the dynamic range *h i*ð Þ.

#### **Figure 5.**

*Indentation images where f mean* ffi *f <sup>h</sup> and f mean are located to approximately half of the dynamic range h i*ð Þ*.*

*Binarization Based on Maximum and Average Gray Values DOI: http://dx.doi.org/10.5772/intechopen.99932*

**Figure 6.** *Dark-field images of indentation and their h i*ð Þ*.*

**Figure 7.** *Indentation images with light gray levels and their h i*ð Þ*.*

The highest frequency of occurrence on the left of the dynamic range is presented in dark-field images of indentation, as shown in **Figure 6**. For these images in *τ* ¼ *τ*<sup>0</sup> ¼ *f mean* prevents good binarization. Thus, Eq. (1) is evaluated for *τ* ¼ *τ*<sup>0</sup> þ *f <sup>h</sup>* � *f mean* until good binarization can be obtained.

To indentation images with light gray levels present histogram with a landslide of gray values, where the highest frequency of ocurrence falls to the right of the dynamic range *h i*ð Þ, as shown in **Figure 7**. In these images, Eq. (1) is evaluated for *τ* ¼ *τ*<sup>0</sup> � *f <sup>h</sup>* � *f mean* until better image segmentation is achieved and some feature of the object of interes may be obtained, for example the indentation vertices [28].

Thus, the binarization reported in [28] can be resumed as shown in the flow chart of the **Figure 8**.

*Binarization Based on Maximum and Average Gray Values DOI: http://dx.doi.org/10.5772/intechopen.99932*

**Figure 9** shows an example of improved binarization in dark-field of indentations applying the algorithm reported in [28]. **Figure 10** shows an example of the algorithm reported in [28] applied in Indentation images with light gray levels.

## **5. Examples of the techniques**

The indentations image are generated through Microdurometers, which use a diamond tip to generate the indentation images. Example, the microdurometer

**Figure 9.** *Example of improved binarization in dark-field of indentation images.*

Mitutoyo model HM-125 (see **Figure 11**) use a microscope with up to 100-fold magnification, which it analog video signal was converted to a digital video signal [32], so that it can be stored as 2D indentation images in gray-scale BMP format.

In many indantion images obtained of samples of steel-316 with roughly polished surface, it is enough to apply the semi-automatic segmentation technique to obtain a good binarization of the image. In **Figure 2**, with the values of *f mean* and *f* max are enough to evaluate *f x*ð Þ� , *y f* max > *f mean* and obtain a good binarization (see **Figure 2**). Furthermore, with morphological filter and region growing, reduces structural noise of the image, making possible to find the indentation and other characteristics of the interes object like the indentation vertices applying techniques reported in [27, 28]. Images acquired from samples of steel-316, but with specularpolished surface, present a light spot in the indentation center, generated by the microscope's integrated light source, which these indentation images have low

*Binarization Based on Maximum and Average Gray Values DOI: http://dx.doi.org/10.5772/intechopen.99932*

**Figure 10.** *Example of improved binarization in indentation images with light gray levels.*

contrast in relation to the adjacent image area. For these images, the binarization is bad obtained by the semi-automatic segmentation technique, because present a maximum area 8-component such that not coincide with the indentation, as shown in the first image of the **Figure 12**. In addition, samples of steel-316 with roughly polished surface, present dark-field images of indentation, where the morphological filter is insufficient to eliminate pixels detected as false positives for the indentation region, as shown in the second image of the same **Figure 12**.

Thus, images with low contrast have been treated by automatic image segmentation, obtaining a better binarization than the semi-automatic segmentation technique. **Figure 13** shows the improvement of binarization applying the automatic image segmentation technique to the same images in **Figure 12**, which, is observed that in the binarization obtained by the automatic image segmentation the maximum area 8-component coincides with the indentation footprint. In addition, applying techniques reported in [27, 28] the indentation vertices are obtained

**Figure 11.** *Microdurometer Mitutoyo HM-125.*

satisfactoraly after applying morphological filter and region growing to the final binarization obtained.

The first input image of **Figure 13** satisfies the condition *<sup>f</sup> mean* <sup>&</sup>gt; *<sup>f</sup>* max <sup>2</sup> of the automatic segmentation technique, while the second input image satisfies that *<sup>f</sup> mean* <sup>&</sup>lt; *<sup>f</sup>* max <sup>2</sup> to obtain the optimal binarization threshold from the second image of **Figure 13**.

*Binarization Based on Maximum and Average Gray Values DOI: http://dx.doi.org/10.5772/intechopen.99932*

**Figure 12.** *Indentations images with low contrast (left column). Bad binarization obtained by the semi-automatic segmentation technique (second column).*

### **6. Conclusions**

A couple of algorithms were presented in this chapter, which consist in a very simple binarization, based in the average gray value of the input image as threshold and the difference to the maximum gray value as binarization criteria, which presents robustness against image noise and surface imperfections.

A second algorithm presented in this chapter, employed the same binarization criteria for each input image as the firts algorithm. However, the second altering the mean gray values via automatic analysis with standard histogram equalization to determine the optimal binarization threshold. Morphological filtering was applied to the binarized image, followed by a segmentation on the growing region. Therefore, the result obtained is a maximum area black 8-component of the image segmentation by both algorithms. Nevertheless, the second algorithm, unlike the first, evaluates a wide range of indentation images, which the indentation edges are not exactly straight lines, and indentation images with very low contrast relation to the adjacent image area, and where the indentation image presents some shading, thereby resolving illumination problems in the image.

*Binarization Based on Maximum and Average Gray Values DOI: http://dx.doi.org/10.5772/intechopen.99932*

**Figure 13.**

*Sequence to obtain good binarization through the automatic segmentation technique applied to indentations images with low contrast.*

*Digital Image Processing Applications*
