MYA '98 IAPR Workshop on Machine Vision Applications, Nov. 1719, 1998, Makuhari, Chiba, Japan
Average Grain Size Determination using Mathematical Morphology and Texture Analysis Hannu Rautio* Infotech Oulu Machine Vision and Media Processing Group Department of Electrical Engineering Abstract Many industrial processes need information about material grain size. In this work we examined rolled chrome concentrate to determine the average grain size. Test material was sieved into 15 fractions, from 37 pm to 500 pm. The analysis method can be divided in three sections: preprocessing, feature extraction and classification. Mathematical morphology was used as preprocessing method, with grayscale erosion and opening as operations. Feature extraction was implemented with first and secondorder statistics. Finally, classification was performed with kNN and minimum distance classifiers using leaveout method. We conclude that mathematical morphology with texture analysis can be used to determine average grain size of material. It is computationally easy and fast although less accurate to smaller grain classes. This is due to imaging errors and noise but also the fact that the ratio grain size versus size of structuring element must be large enough. Both opening and erosion operations can be used. Erosion is two times faster than opening to perform. Also the number of preprocessing operations can be, for example, reduced to three without the classification result will have a remarkable change.
1 Introduction In process control the information about material grain size can be very important. Measurement method must be simple and fast but accurate enough so that it can be used to control the process. Various methods have been introduced to solve the problem[l]. Traditional method is to use sieves of different size to mechanically separate different size grains. Other methods are for example Fourier analysis and ultrasonic attenuation[2]. Wang and Bergholm used moments to define individual grain edge density[3]. Previously, we have used distribution classification to define the average
* Address FIN  90570 Oulu, Finland Email: (hannu.rautio,
[email protected]
Olli SilvCn* Infotech Oulu Machine Vision and Media Processing Group Department of Electrical Engineering grain size[4]. Our idea is to find analogue method to mechanical sieving process. Mathematical morphology is the key method to solve this problem. The analysis method can be divided in three sections: preprocessing, feature extraction and classification. Firstly, a global histogram equalisation was performed. This smooths the difference between the test images that is caused by asymmetrical light distribution and the ability of different size grains to reflect light. Mathematical morphology was used as preprocessing method, with grayscale erosion and opening as operations (see Figure 1). Feature extraction was implemented with first and secondorder statistics (altogether 21 features). Finally, classification was performed with kNN and minimum distance classifiers using leaveout method. 15 morphological operations
(v1 v2 v3
0..
~15)
feature vector original global prepro feature image histogram cessing extraction equalisation Figure 1. Preprocessing and feature extraction.
2 Background for the Experiments 2.1 Preprocessing Grayscale erosion and opening are used at the preprocessing stage. For every image 15 morphological (erosion or opening) operations were performed with different size disk structuring elements. The size of the elements was chosen to be closest to grain diameter upper boundary. Figure 2a shows a function[5] that describes one line in
grayscale image. The structural function is flat. Typically grayscale erosion darkens the image and particularly reduces lighter areas that are smaller than structure element (Figure 2b). Gray scale opening effects only to areas that are smaller or equal size than structure element (Figure 2 c).
3 Test Setups The material was rolled chrome concentrate from where 15 fractions was separated with mechanical sieves. Sieving was performed according Tylers series, where the sieves change according to geometrical series. The diameter of grains range from 37 pm to 500 pm. Smaller classes are dustlike so individual grain boundaries cannot be clearly separated from each other. The image database consists of over 500 images with size 488x512 pixels (see examples in Figure 3).
(4 (b) (c) Figure 2. a) Function, b) its erosion and c) opening
2.2 Feature Analysis The preprocessed images were analysed with first and secondorder statistics. One image was taken as one sample. From each preprocessed image one scalar feature value was calculated using a single feature. Finally, all 15 feature values were converted to a feature vector that characterise the original image. Firstorder statistics were calculated with Khoros 2 image processing software module called kstats[6]. The following statistics were used: MEAN, VAR, SD, RMS, PSUM, MAXVAL, SKEW and KUR. MEAN calculates the average of the image, VAR is the variance, SD is standard deviation and RMS is root mean square of image. PSUM is the sum of (positive) pixel values and MAXVAL is the maximum value of the image. SKEW is skewness that measures the asymmetry. of . pixel value distribution. Positive SKEW values means that distribution is more focused to positive values of x and vice versa. KUR is kurtosis that measures 'the heaviness of tail distribution'. Bigger values means broader distribution. Cooccurrence features[7] are extracted from a cooccurrence matrix. This included the use of the EPQ method that smooths the histogram of the image[8]. The analysed image was converted to a region graph using a segmented method where the image was divided into squares. These were connected to other neighbour squares using 4 or 8connection rule. Finally, the region graph was turned to sample set that includes the extracted feature values.
2.3 Classification Classification was performed with minimum distance and kNN classifiers using leaveout method.
Figure 3. a) grain fraction 37pm44pm b) 420pm500pm c) mixture of fractions 37pm44pm, 44pm53pm and 53pm62pm d) mixture of fractions 149pm 177pm, 177pm2 10pm and 210pm250pm Also mixtures of two and three different size grain fractions were formed. The pixel size was 7x7 pm. The imaging was performed with a SONY 755 matrix camera and Datacube digitizer. A polarizer was used to eliminate reflections from flat grain surfaces. Our test environment consists of SUN 20 workstation and KHOROS 2 image processing software with MMach morphology toolbox (version 1.2b)[9]. The material in leaveIout tests included 60 images, 4 images per one grain class. The sample size was 488 by 512 pixels.
4 Results 4.1 Opening Firstly, opening operation was tested as a preprocessing method. When calculating cooccurrence features the EPQ smoothing was used with k as 8. The three best results are presented in Table 1.
errors is relatively bigger than for the largest grain fractions. The three best results with stats features are presented in Table 2. Table 2. Three best error rates with opening as the preprocessing method using stats features. Feature
Table 1. Three best
error rates with opening as the preprocessing method using cooccurrence features. Feature
minimum distance classifier 3r rate (% )
kNN (k=l) ror e (%) .
kNN (k=3) Error ra
DV
30.00
36.67
51.67
IDM
30.00
33.33
46.67
IMlC
30.00
28.33
55.00

(%I

From 13 cooccurrence features best results (28,33%) gave IMlC feature when using kNN classifier (k as 3). Nearly same results (30,00%) gave features DV, IDM and IMlC (kNN classifier, value of k as 1). From the confusion diagram (Figure 4) it can be seen that the worst results focus on the first four classes of samples. TIP Confusion Matrix created our of an Sample Set Confusion mnmx has 60 samples Confusion matrix has 15 classes Total error is 2R.33 % Confusion mamx is: d d d d d d d d d d d d d d d
u U U u u u U U U U U U U U m m m m m m m m m m m m m m m
undefined 0
Figure 4. Confusion matrix for feature IMlC (kNN classifier when value of k is 3). One reason for this is that for the smallest grain fractions the amount of pixel noise and geometrical image
kNN
(= ,'
\K=J)
'
Erv rate 

\
Error rate  (%)
minimum distanIce classiliier Error rate (%) 
MEAN
13.33
23.33
33.33
PSUM
13.33
23.33
33.33
RMS
16.67
31.67
46.67
The best results (13,33%) with stats features gave MEAN and PSUM features (kNN classifier, k as 1). The second best results (16,67%) gave feature RMS with k as 1. The results of features MEAN and PSUM are identical. One reason for this is that their discrimination ability is equally good.
4.2 Erosion Next step was to investigate erosion as a preprocessing method with the same test material as before. Table 3 presents the three best error rates with cooccurrence features. Table 3. Three best error rates with erosion as the preprocessing method using cooccurrence features. !
U
kNN
kNN &=I) Error rate (%)

VN minimum distance! classifier =3) ror rate ._._Error r:
(%)
DE
21.67
36.67
50.00
IDM
21.67
23.33
46.67
IMlC
13.33
3 1.67
45.00
IMlC feature gave best results (13,33%) from cooccurrence features with kNN classifier (k as 1). The second best results (21,67%) was obtained with features DE and IDM (kNN classifier, k as 1). Three best results with stats features are presented in Table 4. The best results (20,00%) gave features MEAN and PSUM (kNN classifier with k as 1). The second best result (25,00%) was obtained with SD, also with kNN classifier and k as 1. If we compare opening and erosion as preprocessing methods we found that erosion gave better results with co
Table 4. Three best error rates with erosion as the preprocessing method using stats features.
erosion operations. Erosion is two times faster than opening to perform. Also the number of preprocessing operations can be reduced, for example, to three without the classification result will have a remarkable change.
Acknowledgments We wish to thank Outokumpu Oy for providing us rolled chrome concentrate.
References occurrence features. On the other hand, opening with stats features was better than with cooccurrence features. Computationally erosion takes only half of opening time. With 15 operations this time save is considerable.
4.3 Reduction of operations So far we have used 15 preprocessing operations per image. The calculation time can be shortened if for example only three operations are used. Table 5 shows the effect when the number of preprocessing operations was reduced to three with PSUM feature. Only first, 8th and last preprocessing operation was performed. The value of k in knearestneighbour classification was 1. Table 5. The effect of reducing preprocessing operations to three with PSUM feature operatio
The error rate is much bigger with opening operations than with erosion. This leads to conclusion that the reduction method can be used with erosion because error rate (21,6774~)does not considerably differ from 15 preprocessing erosion operation error rate (20,00%).
5 Discussion The number of samples per class is only four, because one image is one sample.
6 Conclusions Morphology as preprocessing method can characterize average grain size of material. It is computationally easy and fast but less accurate to smaller grain classes. This is due to imaging errors and noise but also the fact that the ratio grain size versus size of structuring element must be large enough. In this way the morphological filtering, which is analogue to mechanical sieving, can be effective. The same results can be achieved with opening and
[ l ] T. Meloy, "Shape Characterization of Particles Problems and Progress", Advanced Materials Application of Mineral and Metallurgical Processing Principles, Society of Mining Engineers of AIME, Littleton, CO, USA, pp. 195203, 1990. [2] D. W. Nicoletti, N. Bilgutay, B. Onaral, "PowerLaw Relationships Between the Dependence of Ultrasonic Attenuation on Wavelength and the Grain Size Distribution", Journal of the Acoustical Society of America, v. 91, n. 6, pp. 32783284, 1992. [3] W. Wang, F. Bergholm, "On MomentBased Edge Density for Automatic Size Inspection", Proceedings of the 9th Scandinavian Conference on Image Analysis v. 2, Swedish Society for Automated Image Analysis, Uppsala, Sweden, pp. 895904, 1995. [4] H. Rautio, 0 . Silvtn, T. Ojala, "Grain Size Measurement using Distribution Classification", Proc. 10th Scandinavian Conference on Image Analysis, June 911, Lappeenranta, Finland, pp. 1:353358, 1997. [5] H .J .A .M. Heijmans, "Mathematical Morphology: a Geometrical Approach in Image Processing", Nieuw Archief voor Wiskunde, 28 p., 1992. [6] Khoros2.0.2 Image processing Software kstats Module OnLine Help, KRI Research Inc., Albuquerque, NM, USA, 1995. [7] R. M. Haralick, K. Shanmugan, I. Dinstein, "Textural Features for Image Classification", IEEE Transactions on System, Man, and Cybernetics, Vol. SMC3, No 6, pp. 610621, 1973. , Harlow, ''Equal Probability Quantiz[81 R. ~ o n n e r s C. ing and Texture Analysis of Radiographic Images", Computer Graphics and Image Processing, Vol. 8, NO. 3, pp. 447463, 1978. r91 J. Barrera, G. J. F. Banon, R. A. Lotufo, "Mathematical Morphology Toolbox for the KHOROS System", Documentation of MMach Morphology Toolbox, Sao Paulo, Brazil, 1995. >