The method of quantitative automatic metallographic analysis

A brief analysis of the existing softwares for computer processing of microstructure photographs is presented. The descriptions of the the software package developed by the author are demonstrated. This software product is intended for quantitative metallographic analysis of digital photographs of the microstructure of materials. It allows calculating the volume fraction and the average size of particles of the structure by several hundred secants (depending on the photographs resolution) in one vision field. Besides, a special module is built in the software allowing assessing the degree of deviation of the shape of different particles and impurities from the spherical one. The article presents the main algorithms, used during the creation of the software product, and formulae according to which the software calculates the parameters of the microstructure. It is shown that the reliability of calculations depends on the quality of preparation of the microstructure.


Introduction
A quantitative assessment of the parameters of the materials structure is one of the tasks of research work on determination of the influence of technological factors and different types of materials processing. Such assessment can be conducted both for a visible two-dimensional microstructure and for a spatial structure [1,2]. One of the tasks of this paper was to make a qualitative assessment of the parameters of impurities of a low-melting phase. The most labour-consuming part of the structure assessment is primary measurement of geometric parameters of structural constituents. Conducting such researches manually requires a large amount of time and results in a researcher's error. Earlier, there was costly equipment, such as, for example, metallographic complexes 'EPIQUANT' or 'Kwantimak' for automatic structural analysis. Owing to the development of digital technology, an opportunity to conduct research with much greater productivity and less equipment investments has appeared. Thus, the authors of paper [3] suggest using such general-purpose computer programmes for images processing as 'Adobe PhotoShop' and 'Corel Photo Paint'. However, the drawback of this method is availability of several programmes and the necessity to acquire a skill to work with them, as well as the possibility of obtaining only one parametervolume fraction. These programmes are unable to define the average size of particles of the structure, dispersion and a correlation coefficient. There are software packages for conducting quantitative analysis of microstructures developed by companies 'SIAMS' and 'Carl Zeiss', but these products are costly, too complicated for study and, in a number of cases, lack special modules for specific analysis of impurities of the contrasting phase, for instance, determination of the average particles size of impurities, deviation of the particles from a round shape and so on.
In this paper, a computer programme 'System KOI' designed for images processing and a quantitative assessment of microstructure parameters was created [4]. The programme was coded in the с++ language with application of the software package 'Borland C++Builder'. The developed programme ( Figure 1) serves for computation of the fraction volume and the average particles size of the structure and allows calculating by several hundred secants (depending on the photograph resolution) in one vision field [2].

Materials and methods
The algorithm of the programme operation consists in the following: being in the digital form, the image under study is represented in the form of a large amount of dotspixels, which are sequentially arranged in the form of the horizontal chains. The file itself contains the codes of pixels colours, and their coordinates are obtained automatically. The programme extracts the colours codes, compares them with the values preset by a user and, depending on the result, adds them to the data bank of the white or black phase. This is the way of accumulating information on the quantity of the black and white phase; the percent of the grey phase is calculated as a remainder.
One of the potentials realised in the developed programme is a construction of a histogram in accordance with the particles length for different studied phases with the help of this programme. This allows conducting more thourough studies on distribution of impurities in the samples under study by the shape and sizes depending on the cooling rates. For construction of the histogram in accordance with the sought phase, the programme scans the image in a horizontal direction in the field outlined by a user, making a linear search of the chains of pixels, getting into the colour range specified by the settings of the gray level of the phase. Having found such areas, we measure their length in pixels. Image scanning is conducted a large quantity of times (approximately several hundred times). After primary processing of the image by the programme, a mathematical calculation of the obtained data is made. The maximal value is computed, and the whole range of particles sizes is divided into ten equal segments. Then, the number of line sections, got into each of the dimensional ranges, is calculated. According to the obtained data, a histogram is built, and the calculation of the data for it is made according to the method stated in paper [4]. The histogram of the white or black phase is obtained by means of the line search of monochrome pixels chains along with the calculation of their length and subsequent sorting by sizes. The total amount of points for the white and black phase (about several tens of thousands of points), is sorted and summed [5].
The calculation of necessary parameters of the microstructure is made using the obtained statistical data from the photograph according to the following formulae: The reconstructed number of particles of a three-dimensional structure [2] is where n i -the number of particles in the i-th dimensional interval; l i -the average size of particles in the i-th dimensional group.
where N i -the number of particles in the i-th dimensional interval; D m -the mean diameter of particles; D i -the particles diameter in the i-th dimensional group.
The coefficient of variation (grain size nonhomogeneity of the structure) [4] is where D mthe mean diameter of particles; σ Dthe root-mean-square deviation of the mean diameter.
To assess the parameters of the shape of impurities in the photograph of the materials microstructure, an additional module to the above-stated programme was created. It allows assessing mean deviation of the particles shape from the sherical one. This task is of particular importance when assessing mechanical properties of materials, when the mechanical article strength as a whole depends on the shape of low-strength impurities.
The assessment of shape parameters of lead impurities was made by the coefficient of sphericity. Since impurities in the overwhelming majority represent a similarity of the simplest geometrical shapes (ellipse, trapezoid, rectangle) with ragged edges, we used a centre of gravity of the figure for determining the coefficient of sphericity. Two circumferences were drawn from the centre of gravity: the incircle of the maximum diameter and the circumcircle of the minimum diameter; it is their relation that yielded the sought coefficient. This coefficient does not give the full understanding of the morphology of lead impurities and boundaries imperfections, but along with this, it allows pointing to their circularity and the degree of prolateness. It is significantly simpler and quicker to carry out such analysis rather than fractal image analysis.
To reduce the time for making similar calculations, a computer programme has been developed. The mathematics on determining the centre of mass of the figures with irregular shapes from [7] underlie it. As it has been already stated earlier, an image in the digital form consists of the dotspixels. Abstracting from reality, it is possible to take each pixel as a square; at that we can calculate the sizes of this square, knowing the physical size of the photograph and its resolution (or a transformation coefficient in pixels per millimeter). The whole figure of the impurity will consist of small squares with similar areas. Then, the centre of mass of the figure is calculated according to the following formulae:  -the coordinate of square (pixel) 1, 2, …, n along axes x and y, correspondingly.
The maximal diameter of the incircle and the minimal diameter of the circumcircle were defined by the pixel which is the most distant from the centre of gravity and reentrant into the figure, and by the closest one which is not reentrant.

Conclusion
The assessment of the reliability of the study was made on the basis of sample figures obtained from paper [7] and on real microstructures from [8,9]. The assessment has proven a high accuracy of the programme operation. It was established that the error of measurements depends on the photograph resolution and the sizes of the object under study. The greater the quantity of squares that the computed figure is divided into, the more accurate the results. For the used equipment 'ZEISS AXIO Observer.A1m' and the photocamera 'ZEISS AXIO CAM' with resolution 7 Мpx, the error of determination of the coefficient of sphericity in the real photographs of the microstructure of leaded bronzes, taken at 200 time magnification, amounted to ~1.3 %. To preserve the obtained accuracy of calculations, such magnification was used at which the investigated impurity occupies not less than 0.5 % of the area of the whole photograph. Lead impurities were highlighted during preparation of the photograph for calculations in the programme by means of the software product 'PhotoShop CS3'.