## Abstract

The paper deals with computer vision and image processing methods applied to the task of corrosion damage search. A step-by-step algorithm is given for processing of the data from a chemical corrosion experiment on a metal surface: image preprocessing, image binarization and identification of object contours, and analysis of object characteristics. The application of the developed methods is exemplified by detection and recognition of corrosion damage on a steel specimen, pitting corrosion, and corrosion of an aluminum specimen. Furthermore, the mechanism of fractal analysis for corrosion cracking specimens was studied and fractal dimension was selected as characteristics of corrosion damage.

## 1. Introduction

Metals and alloys are the key construction materials. In operation, they undergo corrosion due to chemical or electrochemical impact of the environment [ 1 ]. Corrosion is irreversible and can result in failure of various equipment items and metal structures; hence, it has to be identified at early stages. Furthermore, there is a need for quantitative estimation of corrosion damage and prediction of the danger of corrosion enhancement if no measures for improvement of corrosion protection are taken. Identification of the corrosion damage origin makes it possible to choose an appropriate protection method.

The complexity of the problem being studied, complexity and diversity of the corrosion environment and corrosion conditions give impetus to development of a set of research and test methods that would help to answer the questions raised by theory and practice.

Analysis of corrosion process (corrosion metal damage) development is based on corrosion indicators. All corrosion indicators are divided into quantitative and qualitative ones.

The weight, volume, electrochemical, magnetometric, and other quantitative indicators are often used to study corrosion. The main drawback of these methods is that they are rather laborious and that they cannot be used outside laboratory conditions.

Qualitative indicators do not provide comprehensive characterization of metal corrosion resistance but can serve to determine the nature and intensity of the corrosion process. Qualitative methods include visual examination of a metal specimen and monitoring of solution changes: optical microscopy [ 2 ], confocal microscopy [ 3 ], laser scanning microscopy, scanning reflectometry [ 4 ], etc. The complexity of quantitative description is the main drawback of visual methods.

Corrosion is a complex and irregular process. In view of this, the morphology and geometry of a corroded surface vary even in studies with the same material and the same corrosion medium. Furthermore, analysis of corrosion by visual methods is complicated by the diversity of objects to be analyzed for corrosion estimation. Depending on the corrosive medium, corrosion process mechanism, and nature of additional impacts on the corroding metal that interacts with the environment, various corrosion processes are possible: cavitation corrosion, pitting corrosion, and stress corrosion cracking. The image analysis criteria for these processes will differ dramatically.

Analysis of corrosion from photographic images is commonly based on the mesh method. The method involves visual determination of the type of corrosion damage on the specimens followed by measurement of the damaged area.

However, a drawback of the mesh method is that it is difficult to describe a complex irregular structure, such as a corrosion crack, using this method. An efficient approach to this problem involves the use of fractals originally suggested by Mandelbrot in 1982 [ 5 ]. In [ 6 ] texture analysis (atmospheric corrosion in an ASTM A36 sample) by six characteristics of image was used (one of them is Hurst coefficient, which directly related to fractal dimension) for checking the state of surface corrosion. In case of abrupt changes in the corrosion rate, the method is not seen as efficient enough. Using of texture descriptor constructed by means of a cellular automaton from the pitting corrosion phenomenon was shown by Silva and Van Der Weeen [ 7 ]. Fractals are used in computer systems (data compression) [ 8 ], simulation of turbulent flows [ 9 ], description of complex surfaces [ 10 ], as well as in medicine and biology.

It often happens that researchers who use fractal geometry or any other method for corrosion process analysis [ 11 ] fail to consider the fact that efficient application of analysis techniques requires preliminary image processing for noise reduction.

Thus, development of a mathematical model for quantitative description of processes at interfaces in a broad range of testing media and metals and based on processing of corroded surface images would enable a more comprehensive application of visual monitoring methods and a deeper understanding of reaction mechanisms at phase boundaries. A computer vision system may serve as a system implementing this model.

## 2. Computer Vision. Methods and Goals

Intense research of computer vision started only in the late 1970s when computing systems exceeded a certain productivity threshold and it became possible to process large data arrays such as images. The following typical tasks of computer vision can be pinpointed: recognition, motion, scene reconstruction, and image reconstruction. The goal of computer vision is to generate scene descriptions based on images.

As concerns corrosion damage analysis, of most interest are problems such as recognition of corrosion effects on an image and motion, i.e., variation of corrosion effects in time, as well as their spatial changes (area, position of the center).

Computer vision methods are widely used in studies of corrosion processes [ 12 ]. An example is a study of pitting corrosion of stainless steel in a FeCl3 solution [ 13 ]. Worth mentioning is a study of corrosion as a 3D object, i.e., pit depth and shape determination by computer vision methods [ 14 ]. The application of wavelet analysis for studies of the geometric characteristics of pitting corrosion is also of interest [ 15 ]. In 2002, Szunerits and Walt analyzed pitting corrosion images by means of wavelet analysis. A distinctive feature of the study was that a neuron network with horizontal, vertical, and diagonal directions was used. This approach gave good results [ 16 ]. The corrosion rate can be affected by controlling the process kinetics in the case of electrochemical corrosion. Determination of the optimal conditions from the kinetic model of the process [ 17 - 19 ] can provide control over the phenomenon. Yan Yun Hui presented another method for identification of metal corrosion damage based on the minimum distance between the recognition objects [ 20 ]. Computer vision reduces the general problem of “image understanding” to a much simpler and clearer problem of detection and identification or measurement, based on one or more images, of objects that satisfy some model description known a priori [ 21 ]. Thus, computer vision finds use in corrosion studies, but the development and application of models suitable for efficient solution of the problem of detection of appropriate objects largely remains on the border of science and art, i.e., it requires a special “know-how” or, in other words, knowledge in the subject matter reflecting a long-term experience of studies on specific problems. We will consider the methods and algorithms used in studies and identification of corrosion by computer vision methods.

## 3. Image Processing Methods in the Analysis of Corrosion Development in Metals

The following steps can be distinguished in the recognition of surface defects:

Preliminary image processing

Image binarization and isolation of object contours

Analysis of object characteristics

The images produced by various information systems are generally corrupted by noise. This complicates both their visual analysis by a human operator and automatic computer processing. Various image components can play the role of noise in some image processing tasks. For example, analysis of satellite images of the Earth surface might have the goal of determining the boundaries between its certain parts, i.e., forest and field, water and land, etc. In this task, some image details within the areas to be separated play the role of noise.

Noise reduction is achieved by filtration. The application of filtration methods implies finding a rational computational procedure suitable for the optimal determination of the object and the “noise” corresponding to that object. The common practice is to solve this task using stochastic models of an image and noise, as well as statistical criteria of optimality. After all, even if the models and criteria match, it often happens that the optimal procedure cannot be found due to mathematical difficulties. The complexity of finding exact solutions gives rise to various approximation methods and procedures.

At the next step after noise reduction, the input data are converted to the binary form and the input image pixels are separated into “signal” and “noise”, i.e., image binarization is performed. A binary image is a variety of digital raster images where each pixel can represent only one of two colors. The values of each pixel are arbitrarily coded as “0” or “1”. The value of “0” is arbitrarily referred to as background and “1” as foreground [ 22 ].

Binary images encode only the information about the object contour; their applicability is limited. In this work, attention is focused on such simple geometry characteristics as object area, position, and orientation.

To form a binary image B based on the data of a gray-scale or color image I, an operation can be performed that selects some subset of image pixels as foreground pixels. These pixels are of interest for the image analysis task that we are performing. The remaining pixels are ignored as background ones.

The pixel selection operation may be simple (e.g., a threshold operator that selects pixels with values from a preset brightness range or color subspace) or a complex classification algorithm.

When it comes to the processing of binary images, morphological operations are important. Mathematical morphology operations were originally defined as operations on sets [ 23 ]. In binary morphology, a binary image is represented as an ordered set of black and white pixels. An image domain is usually understood as some subset of image points. Each operation of binary morphology is some transformation of this set. A binary image I and some structural element S are used as source data. The operation also produces a binary image. Structural element S is some binary image (geometric shape). It can have an arbitrary size and arbitrary structure.

The main operations of mathematical morphology are: dilation, erosion, closing and opening.

Dilation is image convolution with some kernel that has a certain supporting point. Usually the kernel is a small square mask or disc with a reference point at the center. As a result of the operation, light areas in the image dilate. Erosion is an operation that is reverse to dilation. Closing is one of the most important operations in mathematical morphology. The result of the operation is equivalent to consecutive application of morphological dilation and erosion. This results in elimination of small dark areas present in the image, while the large ones remain almost unchanged. Opening eliminates all objects smaller than the structuring element, but meanwhile helps to avoid a strong decrease in object sizes. Opening is perfect for removal of lines thinner than the structuring element diameter.

Thus, we obtain an image that explicitly specifies the object boundary. This set of pixels constituting the boundary is the object contour. For handling the contour thus obtained, it has to be represented (encoded) in some way. For example, the ends of the segments that constitute the contour can be specified. Yet another known method of contour encoding employs the Freeman Chain Code. Chain codes are used to represent a boundary as a sequence of straight segments with certain lengths and directions. This representation is based on a 4- or 8-connected lattice. The length of each segment is determined by the lattice resolution, while the directions are specified by the selected code.

The next step involves analysis of characteristics of the objects found. Depending on the problem statement, researchers may be interested in the following information: filtration of contours along the perimeter, area, shape factor, and fractality.

Thus, this section dealt with the main operations involved in the recognition operation. Below we consider various test tasks in which this approach was used. These tasks have been chosen as test data because they are investigated in laboratory of metal corrosion under natural conditions (Frumkin Institute of Physical Chemistry and Electrochemistry).

## 4. Computer Vision Methods for a Local Corrosion Study

### 4.1. Analysis of Aluminum Surface

The first test task was to analyze the images of an aluminum surface under corrosion potential in a 0.1 M NaCl solution (pH 11) ( Fig. 1 ). The task of searching objects in the image was reduced to detection of bubbles of hydrogen being evolved. The intensity of this evolution had to be determined from a series of pictures.

**Fig. 1.**

Defects can be searched using various methods. In this case, the boundaries of the bubbles of interest blend with shadow, hence additional difficulties may appear if a SURF (Speeded Up Robust Features) detector is used. Furthermore, it is possible to convert test images to the binary form and separate objects into types: hydrogen bubble and background. Therefore, it was decided to study the ways of intelligent binarization with elements of template matching.

In this task, color does not carry useful information, so the image is converted to gray scale in order to simplify the processing.

The images to be analyzed are taken with a photographic camera, which inevitably causes a number of problems. As a rule, an image of an object does not match with those in the reference database of the image recognition system in terms of size and scale. Moreover, it is subject to various brightness aberrations. To suppress aberrations of this kind, the brightness histogram is equalized. Automatic determination of bubble parameters was required in the study, so it was decided to use the histogram equalization method where the image histogram obeys the uniform distribution law. The result of applying this algorithm to the test image is shown in Fig. 2 .

**Fig. 2.**

Image after application of the histogram equalization method.

After contrast improvement, the binarization procedure, i.e., the threshold separation operation that results in a binary image, can be started. The brightness of the pixels at bubble boundaries in Fig. 2 is nearly equal to that of the bubble shadow, hence binarization initially fails to discriminate bubbles from the background.

In order to obtain information about a bubble and perform discrimination from shadows, we will use the tools of mathematical morphology.

**Fig. 3.**

Result of applying morphological operations.

After applying morphological operations, it just remains to find all dark regions confined within the white background – these will be the boundaries of the assumed bubbles ( Fig. 3 ).

Otsu’s method [ 24 ] was used for binarization as it does not require that the user should manually choose the binarization threshold. The idea of Otsu’s method is as follows: the image brightness range [0; L] (in this case, L = 255) is divided into two parts by a threshold value T. In Otsu’s algorithm, minimization of the intra-class variance is equivalent to maximization of the inter-class variance.

**Fig. 4.**

Operation of the detector of bubbles on a metal surface.

Once all the required contours have been found, the bubble parameters need to be determined. Since the bubble contour is a circle, we will find the desired bubble radius and bubble center using the least-squares method for a circle. Figure 4 shows an example of operation of a detector of bubbles on a metal surface. Identification of bubbles was successful, except for boundary regions for the bubbles that did not completely fit in the image. This resulted from a fault in the circle drawing algorithm.

### 4.2. Analysis of Pitting Corrosion on a Steel Specimen. Test Task

The next test task involved analysis of pitting corrosion on a steel specimen. In the case of pitting corrosion, some surface sites degrade to form pits, i.e., deep damaged sites.

An algorithmic solution of this task nearly does not differ from that of the bubble formation search problem. The application of the algorithms described in section 3.1 to the current task is demonstrated in Fig. 5 . Subsequently, we intend to apply this detector for analysis of a video sequence showing the development of pitting corrosion.

**Fig. 5.**

Operation of a detector of pitting corrosion on a metal surface. Color indicates the pits rated by size (blue are small, green are medium, and red are large pits).

### 4.3. Analysis of Stress Corrosion Cracking of a Steel Specimen. Test Task

The third test task involved analysis of images obtained in the course of stress corrosion cracking ( Fig. 6 ).

**Fig. 6.**

Specimens subjected to stress corrosion cracking.

The preliminary image treatment involved noise reduction filters and filters for contrast and sharpness enhancement. In particular, sharpness was enhanced using the linear histogram stretching method that has the form:

(1)

where
*
a*
and
*
b*
are stretch factors; max and min are the maximum and minimum brightness values in the image, respectively;
*
src*
and
*
dst*
are the original and processed images, respectively.

A median filter is used as the noise reduction filter. Owing to its characteristics and provided that an optimum aperture (filter window size) is selected, the median filter can keep sharp object boundaries while suppressing non-correlated and weakly correlated noise and small-size details. Under similar conditions, linear filtration algorithms inevitably “blur” sharp boundaries and contours of objects.

After preliminary image processing, segmentation operations have to be performed, i.e., corrosion cracking has to be detected in the image obtained. The image has to be divided into areas within which a certain uniformity criterion is met. To do so, the binarization operation has to be performed. Again, the Otsu method was chosen for binarization.

After binarization, mathematical morphology methods are used: the opening operation is applied, contours of the objects are found, insignificant ones (noise) are filtered out, and fractal analysis is applied to the remaining contours.

**Fig. 7.**

Determination of a stress corrosion cracking boundary.

The corrosion cracking was characterized by fractal analysis. A fractal is a geometriс shape that has a self-similarity property. To estimate corrosion spots, it was decided to compare their fractal dimensions. Dimension is the main characteristics of a fractal object. As a rule, fractal dimension is a non-negative fractional number that in some way reflects the geometric complexity of an object and is calculated as follows:

(2)

where
*
D*
is the fractal dimension and N
_{ε}
is the minimum number of sets with diameter
*
ε*
required to cover the original set. The fractal dimension was calculated using the box-counting method. The idea of the algorithm is described below.

The set of points in question is divided into pixels with size
*
ε*
, and the number of pixels
*
N*
containing at least one point from the set is calculated.

For various
*
ε*
, the corresponding
*
N*
values are determined, i.e., data for plotting the
*
N(ε) *
dependence are accumulated.

The
*
N(ε)*
plot is constructed in double logarithmic coordinates, its slope is determined and then used as the fractal dimension value.

The fractal dimension was calculated for a steel specimen subjected to cracking. Figure 7 demonstrates a steel sample with the boundary found using the above methods. The corresponding calculated fractal dimension is shown in Fig. 8 .

**Fig. 8.**

Fractal dimension of a specimens subjected to stress corrosion cracking.

## 5. Conclusion

The main results are as follows:

computer vision and image processing methods were analyzed in application to corrosion damage search tasks;

an algorithm was developed for processing of data obtained in a chemical experiment of metal surface corrosion: image preprocessing, image binarization and identification of object contours, and analysis of object characteristics;

the described algorithms were used to detect and recognize the corrosion damage for a steel specimen, pitting corrosion, and corrosion of an aluminum specimen;

the mechanism of fractal analysis for the specimens subjected to corrosion cracking was studied and fractal dimension was selected as the characteristics of corrosion damage.

If corrosion happens in several forms in the investigating area (corrosion, cracking, spalling), then our technique can’t distinguish them. Therefore in the following investigation we will offer a recognition method of corrosion type.

The study was financially supported in part by the Russian Foundation for Basic Research (grant No. 14-03-31509 mol_a, 15-07-01764 А).

## References

- Development of a thin ceramic-graphene nanolaminate coating for corrosion protection of stainless steel Mondala J., Marquesb A., Aarika L., Sim A., Sammelselga V.. Corrosion Science.2016;105:161-169.
- Optical coherence tomography for process control of laser micromachining Weisner M., Ihlemann J., Muller H., Lankenau E., Huttmann G.. Review of Scientific Instruments.2010;81:033705.
- Confocal microscopy of the micro and nanostructured surfaces of materials Weber M.. (in Russian), Nanotech Industry.2011;28:42-47.
- Optical scanning of morphology of the protective layers and forecasting of corrosion resistance thermooxidized steel Kotenev V. A.. (in Russian), Protection of Metals.2001;37:565-577.
- Fractal Geometry of Nature Mandelbrot B. B.. San Francisco: Freemen.1982.
- Texture digital analysis for corrosion monitoring Feliciano F. F., Leta F. R., Mainier F. B.. Corrosion Science.2015;93:138-147.
- Improved texture image classification through the use of a corrosion-inspired cellular automaton Silva N. R. da, Wee P. V. der, Baets B. D., Bruno O. M.. Neurocomputing.2015;149:1560-1572.
- Image coding based on a fractal theory of iterated contractive image transformations Jacquin A. E.. IEEE Trans Image Process.1992;1:18-30.
- Results of numerical research of a turbulent stream with influences on the basis of the analysis of fractal dimension of pulsations of pressure Kovalnogov V. N., Hakhalev Yu. A.. (in Russian), Works of Akademenergo.2013;:7-15.
- System of estimation of quality of a surface of metal rolling Krivolapova L. I., Kravtsov O. A., Kravtsov N. A., Kotkin S. D.. (in Russian), Reports of Tomsk State University of Control Systems and Radio Electronics.2011;24:128-132.
- Fractal approach to the analysis features fatigue failure of welded seams Rudakova O. A.. (in Russian), Bulletin of the Perm National Research Polytechnical University. Mechanical Engineering, Materials Science.2012;14:102-107.
- Research of the mechanism of development of corrosion defeats with use of elements computer vision Enikeev M. R., Maleeva M. A., Gubaydulin I. M.. (in Russian), The Magazine of the Middle Volga Mathematical Society.;15:70-75.
- Pitting corrosion evaluation by computer image processing Itzhak D., Dinstein I., Zilberberg T.. Corrosion Science.1981;21:17-22.
- Image-analysis techniques for investigating localized corrosion processes Quin M. J., Bailey M. G., Ikeda B. M.. Atomic Energy of Canada Limited.1993;AECL-10966:1-51.
- Multiscale characterization of pitting corrosion and application to aluminumalloy Frantziskonis G. N, Simon L. B, Woo J.. European Journal of Mechanics, A/Solids.2000;19:309-318.
- Aluminum surface corrosion and the mechanism of inhibitors using pH and metal ion selective imaging fiber bundles Sabine S., David R. W.. Analytical Chemistry.2002;74:886-894.
- Kinetic model of isolated reactions of the catalytic hydroalumination of olefins Nurislamova L. F., Gubaydullin I. M., Koledina K. F.. Reaction Kinetics, Mechanisms and Catalysis.2015;116:79-93.
- Mathematical modeling of induction period of the olefins hydroalumination reaction by diisobutylaluminiumchloride catalyzed with Cp2ZrCl Gubaydullin I. M., Koledina K. F., Sayfullina L. V.. Engineering Journal.2014;18:13-24.
- Kinetic model of the catalytic hydroalumination of olefins with organoaluminum compounds Nurislamova L. F., Gubaydullin I. M., Koledina K. F., Safin R. R.. Reaction Kinetics, Mechanisms and Catalysis.2015;117:1-14.
- Recognition and classification of metal fracture surface models based on wavelet transform Yunhui Y., Jinhe G., Yong L., Yuguang C., Shichao L.. Acta metallurgica sinica.2002;38:309-314.
- Processing and the Analysis of Images in Problems Of Machine Sight Vizilter Y. V., Zheltov S. Y., Bondarenko A. V., Ososkov M. B., Morzhin A. V.. (in Russian). Fizmatkniga, Мoscow.2010.
- Binarization of Black-And-White Images: State and Prospects of Development Fyodorov A.. [Online]. Available: http://it-claim.ru/Library/Books/ITS/wwwbook/ist4b/its4/fyodorov.htm, Accessed on: 21 September 2016..
- Casual Sets and Integrated Geometry Materon Zh.. Moscow: World.1987.
- A threshold selection method from gray-level histograms Otsu N.. IEEE Transactions on Systems, Man, and Cybernetics.1979;9:62-66.

Snapshot from the test task on analysis of evolution of hydrogen bubbles after application of the “conversion to gray” operation