Modelling of Patterns and Estimation of Characteristic Parameters Anamarija Borštnik Bračic1, Igor Grabec2, and Edvard Govekar3 Abstract A two-dimensional pattern represents a fingerprint of the process that generated it. It is therefore expected that the information about the production process can be extracted from the pattern. In this paper, a non-parametric statistical method for modelling chaotic two-dimensional patterns and the estimation of the characteristic parameters is proposed. It is based on the joint probability density function of samples taken from known two-dimensional patterns representing a database. A new pattern with an unknown production process is reproduced by comparing parts of the new pattern with samples taken from the database. Because the samples in the database also include information about the production process, relevant parameters and the type of production process can be estimated simultaneously with the reproduction of patterns. 1 Introduction A reproduction of a colour picture printed on paper is a relatively simple procedure, since it only requires the appropriate selection of colours for each pixel. A quality reproduction of an oil painting is a much more difficult task to accomplish well. In addition to the adequate selection of colours, the sequence, thickness and moisture of colour coatings all play an important role. To reproduce a machined part, the type of machining process has to be determined and the machining parameters that were used to produce the sample have to be estimated. The extraction of the properties of the machining process from the sample is called the reverse engineering of machined parts. Since no very efficient methods have been presented so far, this attracts much attention from scientists. If the machining process is implemented on a surface of the sample, the surface is called a functional surface structure. This structure hides information 1 Faculty of Mechanical Engineering, University of Ljubljana, Aškerčeva 6, 1000 Ljubljana, Slovenia; anamarija.bracic@fs.uni-lj.si 2 Amanova Ltd, Technology Park 18, 1000 Ljubljana, Slovenia; igor.grabec@amanova.si 3 3 Faculty of Mechanical Engineering, University of Ljubljana, Aškerčeva 6, 1000 Ljubljana, Slovenia; edvard.govekar@fs.uni-lj.si about its production processes, i.e. it depends on the machining operation itself as well as on the dynamic behaviour of the complete machine-tool-work piece system. For the purpose of the investigation of surface structures, different approaches for modelling the dynamic behaviour of the complete system are possible, including finite elements and multi-body simulations (Altinas et al., 2005; Gang, 2009) or constructive solid geometry techniques (Biermann et al. 2008; Biermann et al. 2010). However, due to the complexity of the system, these simulation techniques are not sufficiently powerful for the detailed modelling and the description of surface structures or images. In contrast, the investigation of complex surface structures can be provided by texture characterisation methods, which have been successfully used for image classification (Ng et al., 2007) or automatic image annotation methods, which extract semantic features using machine learning techniques (Zhang et al., 2012). For production engineering, the capability to estimate the relevant machining parameters required to generate a desired surface structure on the basis of a digital record of the surface would be of great benefit. This information could be used, for example, for the reproduction of a surface structure in the case of reverse engineering. In this study, a nonparametric statistical method for the modelling of complex patterns, which can be functional surface structures or artistic paintings and photographs, is presented. The model is based on the characteristic records of the considered patterns and can be used to reproduce the pattern and to extract information about the production process. In the case of functional surface structures, the model estimates the corresponding machining parameters, while in the case of artistic paintings and photographs, it estimates the picture type. This method was originally developed for the extraction of physical laws from joint experimental data (Grabec et al., 1997; Grabec et al., 2001) and has been successfully used to predict the time evolution of multi-dimensional fields (Mandelj et al., 2000; Borštnik Bračič et al., 2009). The objective of this article is to present the proposed modelling method and its application for the extraction of hidden information about the production process of two types of patterns. How to estimate the characteristic machining parameters from the record of the desired surface structure, produced by intentionally invoked chatter in milling, is shown, as well as how to estimate the picture type of artistic painting and photographs. To present the modelling method and its application, the theoretical background of the method is firstly described. The main body of this paper shows the application of the method on two types of complex patterns. First, the examples of surfaces generated by milling are presented. The results of the statistical modelling of the surfaces as well as the results of the estimation of the corresponding machining parameters are detailed. Then, the statistical modelling and pattern characterisation of artistic paintings and photographs are depicted. The paper ends with conclusions and perspectives for future work. 2 Nonparametric statistical modelling In general, a stationary pattern, which can be a surface structure, an artistic painting or a photograph, can be represented by a two-dimensional field O = O(s), where O denotes the profile amplitude and s denotes a set of points on an x-y plane. Most commonly, the spatial evolution of the field O(s) is described analytically with a system of nonlinear partial differential equations. An analytical form of the field O can be estimated from the recorded data, based on the spatial derivatives (Nadaraya, 1964; Voss et al., 1998; Duda et al., 1973; Bosq, 1998). However, due to the presence of noise in the experimentally obtained data, these derivatives are difficult to estimate. Therefore, for a more general approach, the field evolution should be expressed only in terms of the recorded data. In the proposed approach, the two-dimensional field is expressed in terms of data recorded at the equally spaced discrete points xi and yi. It is assumed that the spatial evolution of the field can be described in terms of the model equation: where ^(s') represents the past structure of the surface record, and y(s) represents its future structure; s' represents the set of x,y points in the neighbourhood of the set s of x,y. The field model G provides for the determination of the future field structure p(s) from its past structure p(s'). 6 is a model parameter, depending on the surface record, and will be specified in more detail later. The source of the information for modelling G is a field record containing the joint sample pairs p(s) and f(s'). These joint sample pairs form a sample or training vector Vi(s) = (^i(s), fi(s')). To make further derivations more transparent, the past fi(s') and the future fi(s) field structures will be denoted by the vectors gi and hi, respectively. Hence, Vi(s) = (gi,hi) while gi and hi could be interpreted as given and hidden data. The samples Vi are further interpreted as random variables and can therefore be used to express the joint probability distribution function (PDF) by the kernel estimator (Nadaraya, 1964; Duda et al., 1973; Bosq, 1998): where N is the number of sample pairs and in which ^v denotes an acceptable kernel function, such as the multivariate Gaussian function 9(s) = G (9(s) ,6) (2.1) N i=1 (2.2) |v-v, 2 (2.3) Here, n is the dimensionality of the vectors V;. Once the samples V;(s) = (gi,hi) from the field record have been acquired, the question as to how to determine the optimal predictor of the future field distribution h becomes relevant. The value hp is considered as an optimal predictor of h, at which the mean square prediction error is minimal: E[(h - hp)2|g] = min (hp). (2.4) Here, E[ ] denotes the average of all the points in the field record. The solution of the mean square prediction error (2.4) yields, together with the PDF (2.2), the conditional average estimator: (2.5) where the coefficients of the expansion Ci(g - gi) can be interpreted as a measure of the similarity between the given vector g and a vector gi from the field record. The conditional average estimator described by (2.5) resembles a radial basis function neural network (Grabec et al., 2001). The parameter 6 can be interpreted as being the width of the receptive fields of neurons and can be estimated from the surface record. 2.1 Quality of the predictor To evaluate the performance of the model, a quantitative measure of the modelling quality is required. For this purpose, a testing field g,h is introduced and a statistic called prediction quality Q is defined, based on the difference between the predicted field hp and the testing field h as: This expression yields 1 for a perfectly correlated hp and h, i.e. hp = h and yields 0 for uncorrelated hp and h with equal mean values (Borštnik Bračič et al., 2009). Is should be noted that even though hp is supposed to minimise the mean square prediction error, as shown in Eq. (2.4), hp does not equal h for an arbitrary finite learning record, since the pool of the memorised contents of neurons does not necessarily contain all the information needed for a perfect reproduction of the testing record. For real records, Q is generally less than 1. It can generally be expected that the quality of modelling increases with an increasing number of sample pairs N. However, with increasing N, the cost of experiments also rises. In order to find an optimal value of N, the dependency of predictor quality Q(N) on the number of sample pairs (N) is studied. 2.2 Estimation of characteristic parameters The objective of this study is to use the modelling method described above to reproduce the two-dimensional field and to estimate the characteristic parameters of the production process from a given sample record g of the surface structure. For this purpose, the characteristic sample pairs gi,hi, used to model the surface structure, are concatenated with vector pt, producing the sample groups gi,hi,pi. Here, vector pt describes the corresponding selected parameters, which were used to produce the field. The reproduction process is based on an estimation of the unknown surface structure in terms of Eq.(2.5). To estimate the corresponding characteristic parameters, the parameter field is firstly calculated by: where the coefficients Ci(g-gi) are the same as in the reproduction (2.5). The estimation of the parameter ppa is then given by averaging pp(g) over the whole two-dimensional field. To summarise, the extraction of characteristic parameters, which is based on the modelling of the two-dimensional fields, consists of three steps: • modelling, which corresponds to forming the basis of joint sample groups (gi,hi,pi) for all given field records; • reproducing the field record hp(g) by using the conditional average estimator (2.5); and • estimating the parameter field pp(g) by using Eq. (2.7) and predicting the machining parameters ppa by averaging pp(g) over the whole two-dimensional field. To statistically test the proposed method quality, the reproduced field record is compared with a testing record and the reproduction quality Q is calculated. However, to optimise the method, the appropriate structure of the surrounding s of a given point s has to be found, the number of joint sample groups (gi,hi,p1) has to be determined and the optimal value of parameter 6 has to be chosen. The optimisation is case dependent and will briefly be addressed in the following sections. 3 Modelling of fields Statistical modelling starts with the formation of a database of sample groups gi,hi,pi. Here, pi denotes the characteristic parameters of the field. To validate the model, a learning field (gi, hb pi) and a testing field (g,h,p) are required. The database of joint sample groups (gi,hi,pi) is formed by extracting many small patterns gi and the corresponding neighbouring patterns hi from the learning field and by adding the appropriate vectors of characteristic parameters pi. This procedure is illustrated in Figure 1, where the shape of gi and the shape of hi were chosen to be squares of different sizes. However, the structures of gi and hi, which result in the best performance of the characterisation method, are subject to the optimisation procedure. Figure 1: Selected structure of sample groups gi, hi, pi. Using many g, which represent selected small parts of the testing surface and have the same shape and size as the gi from the database, the unknown field hp is then reproduced in terms of Eq. (2.5). For best performance, it is compared to testing field h. Based on the quality Q of the reproduced field, the modelling is optimised, i.e. the structure s' of the selected parts g and h is defined and the optimal number of joint sample pairs N and parameter 6 that yields minimal Q are chosen. For the fields that are characterised in this study, the structures of gi and hi were chosen to be squares. The best quality was obtained for gi being a 4 x 4 square and hi being a 1 x 1 square. The change of shape of gi and hi, which might result in a better quality of field reproduction, is left for further consideration. Applications require a quick response from the system. Since the number of operations needed to predict the field distribution at a given g increases linearly with the number N of joint sample groups gi, hi, pi, (Eq. (2.5)), it is necessary to find the smallest number of joint sample groups needed to still be able to reproduce field of good quality. For the fields treated in this study, the dependence of reproduction quality on the number of sample groups is shown in Figure 2. As can be seen, Q increases rather strongly for small values of N (N<500), while for larger values of N, an additional increase of N does not result in a significant improvement of reproduction quality. Thus, N will be set to 1,000 in further calculations. A careful reader has surely noticed that reproduction quality does not always increase smoothly with N. The reason for this behaviour is in the partial self-similarity of the fields. As the learning field is increased to an area that is similar to the area already included in the learning field, no new information is brought to the database and the reproduction quality remains unchanged. Figure 2: Dependence of reproduction quality Q on the number N of sample groups gi, hi, pi, taken from one field. Curves A and B represent Q(N) for two fields shown in Figure 3. 4 Characterisation of fields The applicability of the method described above is demonstrated on two groups of fields. First, the estimation of characteristic parameters is performed on records of surface structures, in which the structuring of surfaces is produced by milling. Then, artistic paintings and photographs are characterised. 4.1 Surface structures produced by milling For the purpose of surface structuring, chatter is intentionally invoked in a milling process to produce 50 mm x 50 mm surface areas on an Al block (Biermann et al., 2008). Different tool types are used, each with the same length and diameter, but with different corner radii (r) of 0 mm, 1 mm, 2 mm, and 3 mm. The rotating speed of the tool, i.e. the spindle speed (n) is varied from 11,000 rpm to 13,000 rpm. Using a confocal white light microscope, the manufactured surface structure is transformed into a two-dimensional field record with 934 x 934 pixels, which is obtained from a sample of size 3 mm x 3 mm. To simplify the method, the record of surface structures is reduced to 154 x 154 pixels by averaging a square of 6 x 6 pixels to one pixel. Figure 3 shows the diversity of possible surface structures obtained at various spindle speeds and various corner radii. As shown in our previous study (Govekar et al. 2005), these surface structures are rather deterministic and can therefore be reproduced very well by nonparametric statistical modelling. Statistical modelling starts with the formation of a database of sample groups gi,hi,pi. Here, pi denotes corner radius r and the spindle speed n. The validation of the model requires a learning field (gi, hi, pi) as well as a testing field (g,h,p). Therefore, each field record is divided into learning and testing part. The learning part has to be large enough to enable formation of a desired N=1000 sample groups. In this characterisation of surface structures, 1/16 of the record represents a learning sample, while the rest serves for testing purposes. It should be emphasised that a part of the record, which serves as a learning field, is not intended for testing. r 0 mm 1mm 2mm 3mm 4mm Figure 3: White light microscope images of surface structures generated by tools with different corner radii r and spindle speeds n. Colours are chosen arbitrarily. After the model (guhupi) is formed, the characterisation of the surface structure proceeds in two steps: surface reproduction and characteristic parameter estimation. The results of surface reproduction are presented in Figure 4, which shows the original testing surface sample h and the model-based reproduced surface sample hp. The parameter 6 used in the reproduction equals 0.05. As can be seen, there is a good qualitative agreement between the surface structure of the testing sample and its reproduction. The visual agreement between the testing and the reproduced sample is quantitatively confirmed by the quality measure Q (2.6), which yields 0.90, 092, and 0.98 for the first, the second and the third surface structure in Figure 4, respectively. Figure 4: Original (top) and reproduced (bottom) surface structures for three selected records from Figure 3 with the following values of original machining parameters r and n: 0 mm, 12,000 rpm (first column), 3 mm, 11,000 rpm (second column), and 4 mm, 13,000 rpm (third column). Parameter 6 equals 0.05. In the second step the characteristic parameters are estimated. The parameter field pp(g) = (rp(g),np(g)) is estimated using Eq. (2.7). The estimated fields of milling tool corner radii rp(g) and spindle speed np(g) for testing surfaces from Figure 4 are shown in Figure 5. The parameter fields in the upper row show the estimation of corner radius r, while the lower row shows the estimation of the spindle speed n. The small coloured square located in the vicinity of each parameter field shows the reference colour, i.e. the colour that indicates the original value of the machining parameter. As can be seen, the major colour of the estimated parameter field is very similar to the reference colour for all parameter fields. In other words, the estimated values of the machining parameter are very close to the values, which were used for manufacturing the investigated surface structures. Figure 5: Estimated parameter fields rp(g) (top) and np(g) (bottom) for the surface structures shown in Figure 4 with the following values of original machining parameters r and n: 0 mm, 12,000 rpm (first column), 3 mm, 11,000 rpm (second column), and 4 mm, 13,000 rpm (third column). Parameter 6 equals 0.05. The estimated characteristic parameters rp and np are obtained as the average values of the estimated parameter fields rp(g) and np(g). In Table 1, the estimations of rp and np are compared with the corresponding true values. The comparison demonstrates that the proposed modelling and characterisation method yields a relatively good estimation of r and a very good estimation of n. Table 1: Comparison of extracted values of characteristic parameters rp and np with the manufacturing parameters of the testing fields r and n for the surface records from Figure 4. Parameter 6 equals 0.05. r[mm] rp[mm] n[rpm] np[rpm] 0 0.47 12,000 12,180 3 2.94 11,000 11,380 4 3.20 13,000 12,690 4.2 Photographs and artistic paintings Concerning artistic paintings and photographs, the applicability of the method is tested on two artistic paintings (Claude Monet, Poppies Blooming, 1873, and Igor Grabec, Winter, 2009) and three landscape photographs. The photographs were taken in Slovenian mountains and at the coast of the Adriatic Sea. As these patterns are images, each point of the field is represented by three types of data, i.e. the intensities of the colours red, green and blue. The resolution of the pictures is adjusted to the size of the picture details; it is taken 200 x 300 pixels. The proposed characterisation is a statistical method, and consequently yields the best performance for statistically shift-invariant fields. Therefore, only those parts of the original photographs and paintings are taken to be the learning fields, which exhibit relatively self-similar properties of the patterns. Those parts are shown in Figure 6. The characteristic parameters have the form of a pattern serial number and a selected colour, and are also shown in the figure. The learning fields and the corresponding characteristic parameters shown in Figure 6 are used for the formation of the model (gi,hi,pi). The performance of the characterisation method is then tested on another artistic painting (Claude Monet, Bridge over a Pond of Water Lilies, 1899), a part of which is taken to be the testing field. Its resolution is adjusted to the resolution of the learning fields. As before, the testing field is reproduced using equation (2.5). Since the calculations show that the best performance of the model is obtained for a very small value of parameter o, its value is set to 10-6. Thus, the Gaussian kernel function (2.2) is very narrow and the weighted average of all hi stored in the database is reduced to the contribution of only one hi. The hi with the relevant contribution is the one for which the corresponding gi exhibits the best similarity to the given g. The original and the testing fields are compared in Figure 7. The reproduced field exhibits the main properties of the original and looks almost the same at first glance. A more detailed comparison shows differences in details, which are quantitatively confirmed by the quality measure Q (2.6), which yields 0.68. • / • ■ ;r • /:= >' Figure 6: Parts of the landscape photographs taken in Slovenian mountains (1 and 2) and at the Adriatic Sea (4) and of the artistic paintings of Claude Monet (3) and Igor Grabec (5). Numbers 1 to 5 and the colours shown in small coloured squares represent the characteristic parameters of the images. Figure 7: The testing field (original) and its reproduction in terms of the proposed characterisation method (reproduction). The third image (estimation of picture type) shows the estimated parameter field. The characteristic parameter field is obtained from the equation (2.7). Since the parameter g has the same value as in the equation (2.5), only one pi contributes to the parameter field p(g). The pt with the relevant contribution is the one for which the corresponding gi shows the best resemblance to the given g. Since the characteristic parameters of the learning fields are taken to be the serial numbers of the learning fields, the estimated parameter field shows the origin of each pixel in the reproduced image. In other words, a violet pixel in the estimated parameter field shows that this part of the reproduced field is taken from learning field #1. In contrast, a green pixel indicates, that the surrounding of this pixel shows the best resemblance to a corresponding part of learning field #3. A glance at the estimated picture type in Figure 7 reveals that the chosen testing field is similar to the poppies blooming (learning field #3) and the bushes (learning field #1). 5 Summary and conclusions In this paper, a novel method for the modelling and characterisation of surface structures produced by milling as well as artistic paintings and photographs was presented. This method is based on a description of the patterns as a two-dimensional stochastic field, and uses a statistical method to model the surface structure and to estimate the corresponding characteristic parameters. The performance of the proposed pattern modelling method was tested by an introduced statistical quality measure of the original and reproduced patterns. This criterion indicates a very good ability for a reproduction of the patterns, which is based on a measured sample. In addition, the model was used to estimate the characteristic parameters of patterns. The estimation of machining parameters that were used when machining the measured sample can be very useful in the reverse engineering of machined parts. A comparison between the predicted parameters with the exact values that correspond to the testing surface structure sample shows that the proposed method returns correct values for the characteristic parameters. The accuracy of the results could even be improved by a more appropriate selection of the surrounding s' - a task for future work. In this study, no attention was paid to the orientation and resolution of patterns. If the unknown surface record was scaled or rotated, the efficiency of the presented method would have been significantly reduced. However, in milling as well as in other machining processes, the main orientation axes are well defined and could be preserved when producing a microscope picture of the structure. Also, the resolution of the unknown surface structure can be adjusted to the resolution of the records in the database. The inclusion of rotation and scale invariance into the method is thus out of the scope of this article. Based on the presented results, it can be concluded that the proposed method for the modelling and characterisation of patterns provides a rather general approach for the intelligent design of surface structures that could be used in the reverse engineering of machined parts. Acknowledgement This work was supported by the Ministry of Higher Education, Science and Technology of the Republic of Slovenia. References [1] Altinas, Y., Brecher, C., Weck, M., and Witt, S. (2005): Virtual machine tool. CIRP Annals - Manufacturing technology, 54,115-138. [2] Biermann, D. and Surmann, T. (2008): Modeling the surface structure created by end milling in the presence of tool vibrations. Proceedings of the 11th CIRP International Conference on Modeling of Machining Operation, 16-18 September 2008, Gaithersburg, MD USA, p.171-177. [3] Biermann, D., Surmann, T., Odendahl, S., Brüggemann, T., and Krebs, E. (2010): Surface structuring by milling with intentionally invoked chatter. Proceedings of the CIRP 2nd International Conference Process Machine Interactions, 10-11 June 2010, Vancouver, BC, Canada. [4] Borštnik Bračič, A., Grabec, I., and Govekar, E. (2009): Modeling spatio-temporal field evolution. European Physical Journal B, 69, 529-538. [5] Bosq, D. (1998): Nonparametric Statistics for Stochastic Processes: Estimation and Prediction. Berlin: Springer-Verlag, second edition. [6] Duda, R.O. and Hart, P.E. (1973): Pattern Classification and Scene Analysis. New York: J. Wiley and Sons. [7] Gang, L. (2009): Study on deformation of titanium thin-walled part in milling process. Journal of Materials Processing Technology, 209, 2788-2793. [8] Govekar, E., Gradišek, J., Kalveram, M., Insperger, T., Weinert, K., Stepan, G., and Grabec, I. (2005): On stability and dynamics of milling at small radial immersion. Annals of the CIRP, 54/1, 357-362. [9] Grabec, I. and Sachse, W. (1997): Synergetics of Measurement, Prediction and Control. Berlin: Springer-Verlag. [10] Grabec, I. (2001): Experimental modeling of physical laws. European Physical Journal B. 22, 129-135. [11] Mandelj, S., Grabec, I., and Govekar, E. (2000): Statistical modeling of stochastic surface profiles. CIRP Journal of Manufacturing Systems, 30, 281287. [12] Nadaraya, E.A. (1964): On estimating regression. Theory of Probability and its Applications, 9, 141-142. [13] Ng, W.W.Y., Dorado, A., Yeung, D.S., Pedrycz, W., and Izquierdo, E. (2007): Image classification with the use of radial basis function neural networks and the minimization of the localized generalization error. Pattern Recognition, 40, 19-32. [14] Voss, H.U., Bünner, M.J., and Abel, M. (1998): Identification of continuous, spatiotemporal systems. Physical Review E, 57, 2820-2823. [15] Zhang, D., Islam M.M., and Lu. G. (2012): A review on automatic image annotation techniques. Pattern Recognition, 45, 346-362.