1. Introduction
The task of metallography is to determine and analyse, at a certain chemical composition, the structure and constituting components of metals and alloys. This task is completed by analysing images of the macro- and microstructures. Furthermore, utilising metallography, it is possible to detect defects in the metal material and to find the causes of these defects. In this way, it is possible to determine the most favourable microstructure for a certain production process, which, further, leads to better process control and its improvement and development. By macroscopic examination, the macrostructure is evaluated, and larger defects such as cracks, pores, and similar are detected. Macroscopic techniques are often used for quality control, fracture analysis, and as an introduction to microscopic examinations. A microscopic examination determines the details of the microstructure (phases, boundaries, size, orientation, and shape of the grains), the transformations in solid state, it detects smaller defects (inclusions, inhomogeneities, cracks), and the thickness of layers. Furthermore, it is possible to measure the microhardness of the identified microstructure constituents by additional mechanical testing.
The development of a new microscopy technique enabled the achievement of a high resolution and obtained the image of the microstructure. However, the, interpretation of the obtained results is still a process, where the knowledge of the examiner (scientist, researcher, engineer) determines the performance in interpreting the obtained image and therefore the understanding of material behaviour and properties. This understanding is limited by the education of the examiner, his/her concentration, experience, and knowledge. Consequently, it follows that although the development of microscopic techniques enabled the results to be obtained fast and easily, the interpretation of these results is still highly susceptible to the subjective assessment of the examiner.
In recent years, research in microstructure data science has begun to explore the utilisation of machine vision and image processing. Image processing and analysis can help handle large volumes of image data and facilitate the work of the examiners [
1]. The use of filters, which represent projection functions, has been applied to different image processing problems [
2,
3,
4]. Decost et al. [
5] applied unsupervised and supervised machine learning techniques to yield insight into microstructural trends and their relationship to processing conditions in ultrahigh carbon steel. Zhang et al. [
6] implemented fuzzy logic to extract the grain boundaries of high-strength aluminium alloy microstructure digital images, while Dengiz et al. [
7] combined a fuzzy logic algorithm and Neural Network (NN) algorithms for grain boundary detection of super alloy steel optical microstructure images. Gajalakshmi et al. [
8] developed an image processing algorithm to determine an average grain size in metallic microstructures by counting the number of grains, with the use of Otsu and Canny edge detection techniques and a support vector regression. Vanderesse et al. [
9] employed image processing techniques to distinguish between inter- and intra-granular delta phase precipitates in Inconel 718. Griesser and O’Leary [
4] used orientational entropy filtering to determine the orientation of dendrites in metallurgical micrographs of solidified steel. Heilbroner [
10] used a gradient-based filtering method named Lazy Grain Boundary (LGB) for grain boundary detection with the stacking of multiple images. Ma et al [
11] employed a deep learning-based method for 2D semantic segmentation for grain boundary detection.
However, all the approaches described in the literature mentioned above have some drawbacks: a higher degree of complexity (except when using filters or kernels for instance), the need for training data (in the case of the use of machine learning techniques) and also the end result is never compared directly to a skilled human examiner’s measurements. For that reason, a new grain boundary detection procedure is presented in this paper. The proposed sequence of image processing tasks enables the detection of the grain boundary and edge concatenation by connecting the edges. The developed method is used for grain size measurements and is compared to other conventional and edge retrieval procedures.
3. Results
The implementation of practical image processing using our newly proposed approach and discussion of implementation details is given in the subsequent text.
Firstly, the edge retrieval process is explained, which is used to extract the binary image (representing the edges) that serves as a basis for grain size calculations.
Figure 4a shows an original (unaltered) specimen’s microstructure image. The Laplacian and Gaussian filters are used for further pre-processing. The local Laplacian filter is an edge-aware processing filter, meaning the large discontinuities (such as edges) remain in place. It is defined with local contrast manipulation parameter
, controlling the image detail smoothing, the edge amplitude parameter
and large-scale variations parameter
. With the Laplacian filter (
Figure 4b), the detail enhancement and the balance is controlled between global and local contrast. The increase in contrast with Laplacian filters enables a better distinction between different grains. After the Laplacian filter use stage, the image is processed further with the use of the Gaussian filter (
Figure 4c).
The idea is to use a 2D isotropic Gaussian distribution function, transformed to a discrete kernel form, as a convolution filter for smoothing. The Gaussian filter blurs the processed image to eliminate small image imperfections (such as inclusions or etching artefacts, seen as little black spots on the microstructure image), which have been additionally enhanced with Laplacian, and could disturb the later-on edge extraction. The Gaussian filter also ensures homogeneous colour, along with the specific grain structure. The choice of standard deviation and convolution kernel values (a Gaussian kernel requires
values to be used for convolution) depends on the application; in this case, the most suitable vales are adopted as given in
Figure 4, and further on.
A binary image with enlarged edges was retrieved in the discussed step, wherein a gradient filter based on a Sobel operator with a certain threshold is used on the pre-processed image. The Sobel operator is represented as a 3 × 3 approximation kernel to a derivative of an image. By performing kernel convolution, meaning the gradient matrix is placed over each pixel of an image, we can find out the amount of difference between specific regions in the picture, indicating the presence of an edge. For edge detection, the Sobel-based gradient filter with different threshold values was used, and is depicted in
Figure 5. In the case of setting the threshold value too low, too many edges are recognised (
Figure 5a), and vice versa for too big threshold values (
Figure 5c). The best-suited edge representation is achieved, with a moderate threshold value in case of which only the representative edges are recognised (
Figure 5b).
The first part of the proposed method is concluded in the following step, wherein enlarged edges are altered morphologically with the Zhang thinning algorithm.
Figure 6 depicts the workings of the thinned edge retrieval procedure, based on the implementation of Zhang’s thinning algorithm after different numbers of iterations. Zhang’s thinning algorithm computed the thinned binary edge (BE) image (BE will also serve as a basis for the BE+ procedure), which can be seen in
Figure 6, where edges are only one pixel wide after
iterations. Moreover, the edges can be inserted manually by the examiner (before, or after the thinning phase), to improve the grain size detection rate further.
The binary thinned edges image (BE) is processed with the connected components labelling method to find and index the continuously connected edges. Connectivity is determined as an eight-connected neighbourhood. The number of different sets
is computed representing continuously connected edge regions. In every iteration, the two closest points (belonging to different continuously connected edge regions) are found and connected with a straight line, representing the newly formed edge, previously missed by the edge retrieval process (stressing the moderate Sobel filter threshold value is adopted, resulting in multiple unconnected edges as seen in
Figure 5b). The so-called connected binary edge image BE+ is computed after all the edge regions are connected into a single region. The workings of the proposed edges connecting procedure BE+ is depicted in
Figure 7, where the newly formed edges are shown as red lines, while green regions represent BE.
The precision rates of the edge detection procedures presented, BE (without connecting the edges) and BE+ (with connecting the edges procedure), are compared with the conventional method (EN ISO 643:2012) and the Canny-based edge detection procedures. All test images (TIs), depicted in
Figure 8, are enhanced with the local Laplace filter with parameters
,
and
. The value of the Gaussian blur standard deviation and convolution kernel values (a Gaussian kernel requires
values to be used for convolution) was set to
for a smaller resolution TI, and
for a larger resolution TI. The threshold of the Sobel gradient filter for the smaller-resolution TI set was equal to
and for the larger-resolution TI was set to
. The thinned binary edge image in the case of BE and BE+ was retrieved within
iterations for all TIs.
The basic parameters of the linear intercept method [
18] were set as follows. The vertical and horizontal intercept line spacings were set to
pixels, while
° and
° were set to
pixels since
ensured equal line spacings compared to the horizontal and vertical directions.
The results of grain size measurements with conventional, Canny, BE and BE+ methods, for all TI are stated in
Figure 9. On TI6 the best accuracy achieved with BE, was
% higher compared to the conventional method (supposing the conventional method achieved 100% accuracy). Meanwhile, TI3 BE achieved the worst accuracy—
% higher compared to conventional methods. With the BE+ method, the best accuracy of
% was achieved when processing TI2, while the worst accuracy of
% was achieved when processing TI3 (compared to the conventional method). Test images with higher resolutions, TI4, TI5 and TI6, achieved lower grain size accuracy rates compared with the lower-resolution test images (TI1, TI2 and TI3) via the Canny edge detection technique [
3]. BE and BE+ precision rates indicate the robustness of the proposed method. In concordance with logic, the grain size measurement of BE is always greater compared to BE+, since BE is a subset of BE+ (BE⊆BE+).
Popular edge detection kernels, such as Roberts, Sobel and Prewitt, were not able to recognize the grain boundaries adequately, and were, therefore, omitted from the study. The results for the Canny filter were achieved by setting the threshold ratio to , and the high threshold value was defined as 70% of pixels not considered as edges, meaning, among all recognised edges, only 70% of the pixels will be considered as edges. The standard deviation of the Gaussian filter sigma was equal to for all TI using the Canny edge detection procedure.
The graphs in
Figure 10 display the grain size measurements of the discussed methods on images TI2 (
Figure 10a) and TI4 (
Figure 10b), and their dependence on the increase in the vertical (equal to horizontal) spacing among intercept lines from 500 to 5 pixels (the
° and
° directions spacings are equal to vertical spacing/sin45° pixels). Image processing parameters were kept fixed as in the previous processings of TI2 and TI4. The graphs indicate that using
or less pixels for vertical spacing should provide a converged result for grain size measurements, even if the TI4, which has higher resolution, has an earlier and more stable convergence rate. Changing the gradient filter’s threshold value has a noticeable impact on grain size measurements, since lower threshold values give lower grain size measurements and vice versa. This stresses the enduring importance of visual conformation in precise edge detections and grain size measurements with image processing techniques.