Software Tool Development for Semiautomatic Grain Size Measurement. Thanongsak Sirawattanachai ... image processing techniques are used to filter out irrelevant ..... R.E., Digital Image. Processing, Addison-Wesley Publishing Company,.
Software Tool Development for Semiautomatic Grain Size Measurement Thanongsak Sirawattanachai Department of Production Engineering King Mongkut Inst. of Tech. North Bangkok THAILAND Siriporn Daopiset Department of Production Engineering King Mongkut Inst. of Tech. North Bangkok THAILAND Jaramporn Hassamontr Department of Production Engineering King Mongkut Inst. of Tech. North Bangkok THAILAND Abstract: This research focuses on the development of a software tool to assist the validation of heat treating process through grain size measurement. Specifically, the software developed is to semi-automatically compute the average grain size from a black-andwhite bitmap image taken from an image acquisition system. The technique used here is the intersection count method. The magnification scale must be attached or input by users for calibration purpose. The image processing techniques are used to filter out irrelevant information and improve picture’s quality. The software will follow the standard guideline provided by ASTM E1382-91 to compute the average grain size. The software is developed as a stand-alone program running on a personal computer. Its performance is validated comparing its result with known input. The software developed is efficient in terms of space requirement and computation time while requiring minimal user’s input. Moreover it is relatively inexpensive as compared to those software packages included with new image capturing systems.
Introduction: In a typical manufacturing environment, mechanical parts are designed with forms and functions. Both forms and functions are then translated into measurable engineering requirements that the part must possess. Such requirements can be of geometric properties, material properties, or other physical performances. How one chooses to manufacture parts will affect these engineering requirements significantly. During the prototyping period, several manufacturing parameters must be determined and tested in order to assure that all the requirements are met. Furthermore, the final manufacturing plan must be able to achieve all the requirements consistently in production.
Most mechanical components are specified with required strength which, in turn, depends highly on surface characteristics. Grain size is an important indicator for surface and material characteristics. In the past, grain size measurement requires a great deal of effort. The image of material surface must be taken using a scanning electron microscope (SEM) or a high-resolution microscope. The number of grains is then examined and counted manually. The American Society of Testing Materials (ASTM) has established standards [1] to perform grain size measurement manually. The process is inherently human dependent and does not allow adjustments on picture’s quality. Moreover, these SEM images are difficult to maintain as database records. There are several image processing software available nowadays, but only a few can perform grain size measurement according to the standard provided by the ASTM. Some software offers the capability to compute the average grain size as a specialized module that must be purchased separately at high price. This research focuses on the development of a software tool to assist the validation of heat treating process through grain size measurement. Specifically, the software developed is to semi-automatically compute the average grain size from a black-andwhite bitmap image taken from an image acquisition system. The technique used here is the Intersection Count Method as specified by the standard ASTM E1382-91 guideline. The magnification scale must be attached or input by users for calibration purposes. The image processing techniques are used to filter out irrelevant information and improve picture’s quality. The software is developed as a stand-alone program running on a personal computer. It is written
in Visual Basic programming language version 5.0 Its performance is validated comparing its result with known input. The software developed is efficient in terms of space requirement and computation time while requiring minimal user’s input. Moreover, it is relatively inexpensive as compared to those packages included with new image capturing systems.
The software developed in this research will use the Intersection Count Method in semiautomatic image analysis setup to measure the average grain size in single-phased grain structure. Therefore, this technique will be reviewed briefly in the next section. Readers can consult ASTM [2] for other methods.
Algorithmic Approach: Literature Review: American Society of Testing and Materials (ASTM) has established the standard guideline [2] to determine the average grain size using image analysis techniques. Since the software developed in this paper follows the ASTM methods, it is important to review their scope for readers who are not familiar with the ASTM guideline. The methodology proposed by the ASTM is applicable to any type of grain structure as long as grain boundaries can be clearly identified. This includes polycrystalline metals and nonmetallic materials with equiaxed or deformed grain shapes. The grain can be of single or multiple phase structure.
The specimen must be prepared through polishing and etching to remove scratches from machining processes. The surface prepared must be large enough to take at least 5 field measurements to assure that the average grain size computed is statistically sound. The field measurement must be sampled randomly. It is recommended that the surface area should be at least 160 mm2. When capturing the surface image from a microscope, the photomicrograph should contain at least 50 grains. Each grain should be at least 5 mm in diameter on the photomicrograph to ensure measurement accuracy. It is possible to perform grain size measurement manually from the photomicrograph as described in the ASTM [1]. ASTM distinguishes between semiautomatic and automatic image analysis methods. In an automatic image analysis setup, the image processing function such as threshold setting is available before capturing the appropriate image. In a semiautomatic image analyzer, however, the captured image cannot be processed a priori. ASTM allows the aids of image processing techniques to enhance and modify the image before the measurement. Techniques such as skeletonization or watershed segmentation may be used to complete missing grain boundaries. However, these techniques must be used with caution since it may produce false grain boundaries or it may not produce grain boundaries between two adjacent grains when some peculiarity takes place.
The software developed is to be run on a stand-alone personal computer. It is to take black-andwhite bitmap files as input. The image is usually acquired using a microscope connected to a CCD camera. The captured image is then saved as a graphic file. Several graphic programs allow file conversion to bitmap format. It should be noted also that the requirements on photomicrographs described in the previous section must be met. An example of such bitmap file is shown in Figure 1. As the bitmap file is input to the software, several steps must be taken before the average grain size can be obtained. This section describes each step in details. Conversion to gray scale The bitmap file input must be converted to gray-scale image. Gray scale image consists of pixels each with certain gray level. Maximum gray scale of 255 is used, with gray level of 0 being completely black and 255 being completely white. Typical digitization process can be done on each pixel to convert the entire image to gray scale. Figure 2 illustrates the gray scale image converted from the example bitmap file. Gray scale processing The gray scale image obtained from the previous step is usually not well contrasted. Several image enhancement techniques are available both in spatial and frequency domains. In this research, techniques in spatial domain are found sufficient and reasonably fast. Such techniques include filtering to remove noise and histogram equalization for contrast manipulation. Noises in an image occur due to instability in the light source or detector during image acquisition. In a gray-scale image, noises appear as variations in brightness or gray level. Filtering techniques available in this software are low pass, high pass and Gaussian filters. If the image contains negligible amount of noise, the filtering may not be necessary. In general, however, high pass filter is used to sharpen lines in the images. Figure 3(a) denotes the image obtained after being filtered by high pass filter in the software. Filtering techniques alone are usually not sufficient to improve image quality. Histogram equalization is used to enhance image contrast. To achieve this, first, the software generates an image
brightness histogram, a histogram between the pixel’s brightness value and the number of pixels with the corresponding brightness value. Here, brightness value and gray level are used interchangeably. Then, the software attempts to “equalize” the histogram by spreading the peak (of the histogram) out and compress others. To compress pixels with low frequency of occurrences, the software assigns the same or close brightness values to them. Therefore, after histogram equalization, about the same number of pixels show each of the possible brightness values. The new histogram after the equalization process will be rather flat. The image obtained from histogram equalization is illustrated in Figure 3(b). Image Segmentation Once the image is enhanced, the software can start to extract the information of interest from it. Image processing scientists refer to this stage as image segmentation. The segmentation process subdivides the image into its constituent parts or objects that are of interest, such as grain boundaries in this case. Two image segmentation techniques are used in this software, namely edge detection and thresholding. An edge is the boundary between two regions with relatively distinct gray-level properties. In this case, an edge is a line representing grain boundary. The edge detection algorithm is to detect discontinuities of gray level in the image. The edge detection scheme used in this software is simply gradient operator. Even though grain boundaries are detected using gradient operator, the software must separate the objects of interest from the background. To do this, the software attempts to group pixels of objects and backgrounds into two dominant gray levels. Users must input lower and upper threshold values to convert the entire gray scale image into binary image. Pixels with gray level between the lower and upper values can be set to 1 while the other two tails set to 0, or vice versa. Certainly, different threshold values will result in different “look” on the images. Users must use trial-and-error approach to obtain the appropriate image. Figure 4 denotes the binary image obtained from setting the lower and upper threshold values at 10 and 100 respectively. Binary Processing To extract features from binary images, there are two possible approaches, Boolean operations and morphological methods. This software primarily utilized morphological methods for binary image processing. Morphological schemes used in this software are thinning and intersection counting. Thinning, as the name suggests, is the algorithm to thin the grain boundaries so that the line
thickness is unity at almost all positions, except at the junction between grain boundaries. Figure 5 illustrates the resulting image from thinning process. Intersection Counting is primarily used for the grain size measurement stage described in the next section. The test procedure used in this software is Intersection Count Method with circular test grid. That is, the software generates a circle superimposing on the image, then it will count grain boundary intersections. The radius of the circle should be large enough to result in 25 to 150 grain boundary intersections. A tangential intersection with grain boundary is counted as one intersection, whereas the intersection on the junction of three grain boundaries is counted as 1½ intersections. Rarely the test line will intersect the junction of four grain boundaries as this will be counted as 2 intersections. Figure 6 denotes the test circle at the middle of the image. In actual measurement, the test circle must be place randomly within the image. In this image, several lines were extended to complete missing grain boundaries. In Figure 6 the intersection count is found to be 49. Measurement After several image processing techniques, grain size measurement can be performed. At least 5 field tests must be done for statistical accuracy. For the ith field test, the software will determine the number of grain boundary intersections per unit length of test line, PLi, by P PLi = i (1) Lti where Pi is the number of intersections, and Lti is test circle circumference. For a single circle of diameter d and magnification M, the test circumference can be computed from πd Lti = (2) M
PL , can be found along with the mean lineal intercept length, l . Then the average value of all n fields, n
∑P
Li
PL = l =
i =1
1 PL
n
(3) (4)
The conversion of the lineal intercept length to ASTM grain size number, G, is given by G = −3.2877 − 6.6439 log 10 l , (5) when l is in mm. The standard deviation of the grain boundary intersections can be computed accordingly. ASTM provides the anticipated standard deviation of the measurements (ie. l , G ) as a function of intersection counts [1].
•
Examples: The software is tested with an image taken from Voort [6] where the grain structure is known to have mean lineal length of 0.01118 mm., which corresponds to ASTM grain size number 9.7 The result is obtained from extensive manual measurements of 428 fields, therefore it is reliable. Figure 7 shows the binary image of the test specimen. It exhibits duplex grain structure, having both finegrained and coarse-grained regions. Since the coarsegrained region accounts to only a small portion of the image, fine-grained region will be of interest here. The image is re-calibrated in the software to obtain the appropriate scale before the grain measurement is performed. Figure 8 denotes an example of field measurement on the test specimen along with the attached, calibrated scale. The mean PL is found to be 78.57 mm-1, therefore the mean lineal length is found to be 0.0127 mm and the ASTM grain size number is 9.30 Figure 9 illustrates the screenshot of the calculation result reported by the software. The result from the software and that reported in Voort[6] is within the accuracy of 13.6% on the mean lineal length and 4.12% on ASTM grain size number.
Conclusion: The software tool to measure grain size is developed in this research. The measurement follows the standard guideline according to ASTM E1382-91. Here, only the Intersection Count method with one test circle is used. The software is tested with know image. The result is quite satisfactory in terms of grain size prediction within the accuracy of 4.12% on the value of ASTM grain size number (G) The software developed is still far from completion. Several possible future works include the following.
•
•
•
More test specimens are necessary to assure the measurement effectiveness and accuracy. Other test methods specified in the ASTM should be included on the software. Comparative study between these test methods is also useful for better understanding on the grain size measurement accuracy. Several image processing tools should be refined. For example, threshold setting is performed manually in this software to determine the appropriate threshold values. The software should be able to determine the optimal threshold setting automatically. The test method considered in this paper is primarily for single phase grain structure. For multi-phase grain structure, test methods as well as other image processing techniques are necessary.
References [1] American Society for Testing Materials, “Standard Test Methods for Determining Average Grain Size,” E112, 1988. [2] American Society for Testing Materials, “Standard Test Methods for Determining Average Grain Size Using Semiautomatic and Automatic Image Analysis,” E1382, 1991. [3] Sid-Ahmed, M.A., Image Processing Theory, Algorithms, and Architectures, Prentice-Hall, 1995. [4] Russ, J.C., The Image Processing Handbook, CRC Press 1992. [5] Gonzalez, R.C. and Woods, R.E., Digital Image Processing, Addison-Wesley Publishing Company, 1992. [6] Voort, Practices,
V., Metallography: Principles and McGraw-Hill, Inc., 1984.
Figure 1: Example of input bitmap file.
Figure 2: Gray scale image obtained from gray scale conversion.
(a)
(b) Figure 3: Image obtained from gray scale processing, (a) after being filtered, (b) after histogram equalization.
Figure 4: Image obtained after thresholding.
Figure 5: Image obtained after binary processing (thinning)
Figure 6: Placing the test circle on the image
Figure 7: Binary image of the test specimen from Voort[6]
Figure 8: Field measurement of the test specimen
Figure 9: Screenshot of the result of the measurement