Optimisation of Image Registration for Print Qualit Control J. Rakun and D. Zazula Sstem Software Laborator Facult of Electrical Engineering and Computer Science Smetanova ul. 7, Maribor, Slovenia E-mail: jurij@mozirje.com, zazula@uni-mb.si Kewords: image registration, affine transform, wavelet transform, Fourier domain Abstract This paper describes image registration techniques that were used to develop print error detection sstem. In order for error detection to be successful optimal image registration must be achieved. Purposed optimal image registration achieves optimal fit in combination of affine transform, Fourier domain and wavelet transform.. INTRODUCTION Error detection of printed matter proves to be quite a burden for modern companies. The must compl and use printed matter that is compatible with regulations and trading restrictions that differ from one countr s market to the other, not to mention errors that occur due to imperfect printing techniques. Ever printed matter, such as labels, instructions, wrappings must therefore be inspected prior their usage. In order to develop an accurate and reliable computer error detection sstem, that will automate error detection and will need no special hardware to operate, image registration techniques can be used. Error detection using registered images is trivial and works b comparing color values of two images as described in []. Firstl, referential printed matter that does not contain an errors must be selected. It serves as a template that the inspected printed matter is to be compared with. Secondl, referential and inspected image are digitalized using either a document scanner, digital camera or an other capturing device. Image registration techniques are then applied in order to register images, so their motives coincide on the same piel locations. Finall, analsis is preformed that compares colour values of coinciding piels or regions. As discussed in [], additional steps can also be applied to further refine the results. Error detection qualit relies heavil on the qualit of image registration techniques applied. To minimize doubtful errors, optimal image registration must be achieved prior the analsis. We propose to use affine transforms, Fourier domain and wavelet transform that together combine a ke to achieving optimal image registration fit. In section II we start with fine image registration, continue onward with coarse image registration which is based on Fourier domain (Section III), discuss possible image registration optimizations using wavelet transforms (Section IV) and finall conclude the paper with results b Section V.. FINE IMAGE REGISTRATION Fine image registration is borrowed from medical imaging []. It utilizes affine transforms to register images. Iterative affine transforms produce a kind of elastic correction to images that ma or ma not be of eactl the same sizes. Elastic correction is most welcome in cases where printed matter is involved, which can be stretched due to printing drum mechanical hiccups and/or medium viscosit that is being printed on. We can formulate image registration problem as show b Eq. () and start with p(,, t) and p(,, t ) that represent piels of referential and inspected images, respectivel. Affine transformation is used to describe transformation from one image to another: p(,, t), () p( m + m + m5, m3 + m4 + m6, t ) where parameters from m to m 6 denote the affine transformation parameters. Smbol in Eq. () represents the best approimation possible that leads to equalit when we deal with contetuall identical motives. Based on simplified first order Talor series, eplicit form of Eq. () for affine parameters can be achieved, using spatial differences instead of derivatives. Affine parameters m to m 6 can so be calculated using Eq. (): M N M N T m = ( cc )( ck), () = = = = Where M and N stand for image dimensions and, in order to simplif the result, c and k are introduced and calculated with the help of spatial differences f, f, f t as depicted in Eqs. (3) and (4): T c = [ p, p, p, p, p, p ], (3) k = pt + p + p. (4) Spatial differences f and f are computed b subtracting neighbouring piel values on and ais, respectivel, while f t is computed b subtracting coinciding piel values between the registered images.the registration parameters obtained b Eq. () are merel one step when converging towards the best image fit. It should be understood that the compared images ma not have eactl the same contents and size. Searching for the global optimum must continue over several iterations, until the mean square error (MSE) decreases suitabl. After each iteration, an interim interpolation is applied to both the referential and inspected images, a half of the calculated rotational and translational adjustment to each image. Such a solution keeps the interpolation-caused degradation at approimatel the same 454
level in both images, and prevents the generation of artificial discrepancies. Unfortunatel, fine image registration cannot be used as a sole image registration technique for an optimal fit. It is prone to miss alignment in cases where local optimum is encountered during registration iterations. The second problem lies with its computational compleit that quickl becomes overwhelming when we deal with larger images. To cope with this problem, we introduce two additional optimization steps which are described in the following sections. 3. COARSE IMAGE REGISTRATION To speed up fine image registration and prevent it from reaching local optimum, a preliminar step of coarse image registration is introduced. It works b transforming images to Fourier domain [3], where translation and rotation parameters are calculated and then applied to rigidl register images. In contrast to spatial domain, rotation and translation in Fourier domain appear separated in the amplitude and phase spectrum, respectivel. Two simple images were selected in order to illustrate how to determine registration parameters and are depicted in Fig.. In the following subsections we will refer to them as I (,), I (,), while S (,), S (,) are their discrete Fourier domain transforms. S (,) and S (,) are centred, so that their DC values, corresponding to average brightness across image and originall positioned at coordinates (0,0), coincide at the figure center, on the same location. Rotation difference can clearl be observed between the two amplitude spectra. S (,) and S (,) possess Hermitian smmetr so rotational difference can be calculated with the help of reflection [3]. We choose either S (,) or S (,) and calculate reflection with respect to one of the ais. The reflected transform is then subtracted from the other one, as stated b Eq. (5): S (, ) S ( R H[, ] ) Δ (, ) =, (5) S (0,0) S (0,0) where H and R stand for reflection and rotation matri, respectivel. The resulting difference for S (,) and S (,) is shown in Fig. 3. T Fig. 3. Subtraction results depicted in the default coordinate sstem (black aes). Fig.. Images that are to be registered; the are of the same dimensions of 0000 piels. 3. Rotation To determine rotational differences between images, I (,) and I (,) are first inverted, shrunk b a factor of and zero padded to their original size. The produce Fourier transforms S (,), S (,) with higher resolution that have more distinct lower frequencies as depicted in Fig.. S (,) and reflected S (,) are smmetrical, therefore the subtract to zero at half the rotation angle. This effect is most prominent in the area around the center (e.g. in a radius of 00 units). Zero-valued locations obtained after subtraction in Eq. (5), the so called zero-crossing points, must be detected to determine the rotation of original motives. Fig. 4 depicts the binar results of zero-crossing points for images I (,) and I (,). Fig.. Rotated amplitude spectrum which was produced using the images from Fig.. Fig. 4. Resulting zero-crossing points for the difference of S (,) and S (,). 455
Fourier transform produces smmetrical transforms, so we focus onl to the (-45, 35 ] area. Calculations in the area (35, 35 ] are identical. Rotation angle is determined using two histograms. The first represents the area of (-45, 45 ], while the second the area of [46, 35 ). The reason for two histograms lies with the fact that zero-crossing points are sometimes more obvious in the first and sometimes in the second area. Therefore, to refine the results, the are superimposed. The position of maimum value is looked for in the resulting histogram and multiplied b a factor of two. We must not forget that the zero-crossing points occur at half rotational angles. The estimated rotations range from -90 to 90. 3. Translation To determine translational differences we choose phase correlation algorithm [4], which is the most common and widel used method for estimating planar translations when dealing with Fourier transforms. Firstl, either S (,) or S (,) is selected to compute its comple conjugate. This conjugate is then multiplied b the other transform as shown in Eq. (6): * SS ( Δ, Δ) = argma[ F ( )]. (6) SS F - stands for the inverse discrete Fourier transform, which is applied to the normalized element wise multiplication of S (,) and S (,). This produces the correlation function whose maimum-value coordinates indicate the translation difference between the images. Such correlation function for S (,), S (,) is depicted in Fig. (5). The ke to good, fast and reliable sstem is to coarsel register images as much as possible. This prevents fine image registration to wonder off toward local optimum and also reduces iteration ccles needed b fine image registration. Theoreticall, coarse image registration would be enough to register two images with the same motives, but in practice, mainl because no two printed material are totall alike, fine image registration is still needed. In order to make this registration more robust and also quicker, wavelet transform [5] was implemented. Robustness can be improved in the step of coarse registration b using continuous wavelet transform, and discrete wavelet transform to speed up fine image registration step. For the time being, we implemented the transforms using Haar wavelets whose sensitivit to the edges is beneficial in our case. 4. Fine image registration Computational compleit of fine image registration relates to the quantit of data processed within each iteration. If smaller images are to be registered, less time is needed to determine affine parameters. Wavelet transform offers a unique solution to the problem. Discrete wavelet transform can be used to build a multiresolution pramid of images. We start with original images, reduce them in size b a factor of, to produce a second pair of images, which is used to produce the net, even smaller pair of images. If we deal with larger images, the reduction steps can continue until images are still large enough to make out the motives. Reduced images are then used to determine affine parameters the other wa around, from smaller to bigger images. In each step, new affine parameters are calculated and minor adjustments applied to the images with higher resolution. In each step, translation parameters are multiplied b a factor of, as the size increases b the same factor. Fig. 6 illustrates 4-level pramid used to calculate the affine parameters. Fig. 5. Planar correlation function for S (,) and S (,). This correlation estimate ma return a translation to the net period. We must not forget that we are dealing with Fourier transform which implicitl considers periodic functions. 4. WAVELET TRANSFORM The described registration methods work hand in hand toward achieving optimal image registration. Coarse image registration is the first to be applied. It is quick and able to register images with such precision that the subsequent fine image registration achieves optimal fit much easier. Fig. 6. A pramid of images used to calculate the affine parameters. Because smaller images are used, affine transform produces partial affine parameters quicker and because the images with higher dimensions are alread registered, 456
based on partial affine parameters, fine image registration at ever level finishes faster. 4. Coarse image registration The wavelet transform model offers also additional improvement of coarse image registration step. Instead of resizing the images, wavelet-based image smoothing can be used. The noise in images can heavil hinder the coarse image registration b reducing its qualit. A solution to this problem is frequenc filtering, of coarse, which eliminates high-frequenc noise and smoothes the images. In our eperiments we used 4 different scales, as shown in Fig. 7. Fig. 7. Images having different levels of details: a full detailed image (left) and progressivel less detailed images (to the right). General description of images Label Size [piels] Initial MSE Note FA 49 775 564 Images with simple motives. FA LS 459 668 56 Partl different motives. SCHAUMA 48 43 655 Images with simple motives. STY-GEL 7 066 7060 Motives containing a lot of tet. Results Coarse image registration using wavelet based smoothing Label Original images Wavelet scale Wavelet scale 3 MSE Time[sec] MSE Time[sec] MSE Time[sec] FA 80 8 80 6 80 4 FA LS 3007 8 3007 5 3007 SCHAUMA 66 5 0579 0 853 6 STY-GEL 57375 564 5 48935 39 Results Fine image registration using wavelet based shrinkage Label Original images Wavelet scale Wavelet scale 3 MSE Time[sec] MSE Time[sec] MSE Time[sec] FA 4307 8 3999 98 405 95 FA LS 44 0836 8 55 SCHAUMA 3 3 083 9 860 5 STY-GEL 797 493 846 474 087 30 Table. Results of coarse and fine image registration steps using wavelet transform for selected sample images. 457
We started coarse image registration with images having onl the third level of details, which were used to calculate angular histograms. The procedure was repeated for images at second level of details and also for original images. All angular histograms were summed up in order the rotational parameters to be calculated Appling this procedure the noise level reduces, so that the registration parameters are calculated using onl the most prominent features of the images. This also reduces high frequenc details that are subsequentl respected in lower scales, whereas the parameters from higher scales initialise the search spaces in lower scales, which further introduces lower computational compleities. caused a small error in coarse registration when using wavelet scale three. Fine image registration using wavelets, on the other hand, has proven our epectations. B using images having smaller resolution, elasticall registering them and adjusting the results through the higher scales, resulted in faster image registration. In general, differences in speed can be even more prominent in the cases where larger displacements appear. The onl eception proved to be FA-LS, where partl different motives were registered. This was epected as the registration procedure of unequal motive produces small iteration steps. 5. RESULTS Four different sets of images were used to quantif the purposed optimization. Firstl, images were coarsel registered using three different wavelet scales, producing three pairs of images for each image set, containing decreasing detail levels. With each step, MSE was estimated and time measured. Secondl, the results after fine image registration were measured using the best coarsel registered pairs of images from the first step. Three different wavelet scales were once more used, producing multiresolution pramid of images. Measurements were performed using a PC with Pentium M class processor at.6 GHz, having 5 MB of RAM and an implemention in the Matlab environment. Results are depicted in Table. A short comment on pairs of images is necessar in order to better understand the results. Real printed matter eamples were used from cosmetics industr that was provided to us, b our industrial partner. FA and SCHAUMA represent pairs of images that contain simple, colourful motives. In contrast, STY-GEL pair contains a lot of tet. Furthermore, STY-GEL motives slightl differ in size, which complicates registration steps even more. The last pair, FA-LS, represents images containing the same logo, whereas the tet languages differ. It was introduced in order to determine what can be epected from registration steps when dealing with partiall different motives. Measurements made for coarse image registration show that wavelet-based registration produces better registration results, but onl in the cases where images differ because of noise, size or content. In the cases where optimal coarse registration is initiall reached, as shown for FA and FA-LS, the purposed solution onl prolongs the eecution. An elastic correction is still needed, and it is provided b the fine image registration step. The test pair SCHAUMA appeared as a special case, where the scale three wavelet-based registration produced higher MSE than at lower scales. Although the MSE differences are small, we were interested in what caused them. The problem is caused b the resolution that our current implementation can determine registration parameters with. The rotation can be measured at and translation b piel of accurac. Angular histograms produced b coarse registration proved to miss the right angle b in one and was correct at two other scales. This 6. CONCLUSION The presented techniques proved to work well in achieving optimal registration steps. The coarse image registration step is used to speed up the registration and to initiall register images precise enough to protect the fine image registration ending in a local optimum. Although the coarse registration can achieve optimal registration in some cases, it must be followed b fine image registration in general. When dealing with images containing discrepancies, it proved to be useful to appl wavelet transform. Especiall in cases where we deal with slightl different contents or noise. This makes coarse image registration more robust and speeds up fine image registration. The latter can be additionall optimized b using multiresolution scaling that works especiall well in the case of large displacements. To further improve image registration used in our print error detection sstem, we focus on improving the coarse image registration resolution. As it was eplained in the previous section, it can produce undesirable registration errors which can be compensated using a further fine image registration step, but results in longer eecution ccles. REFERENCES [] J. Rakun, D. Zazula, Ra unalniško odkrivanje tiskarskih napak, Zbornik elektrotehniške in ra unalniške konference ERK 005, vol. B, pp. 38-38, Portorož, 005 (in Slovene). [] S. Periaswam, H. Farid, Elastic Registration in the Presence of Intensit Variations, IEEE transactions on medical imaging, vol., no. 7, pp. 865-874, 003. [3] L. Lucchese, G.M. Cortelazzo, A Noise-Robust Frequenc Domain Technique for Estemating planar Roto- Translations, IEEE transactions on signal processing, vol. 48, no. 6, pp. 769-786, 000. [4] E. De Castro, C. Morandi, Registration of Translated and Rotated Images Using Finite Fourier Transforms, IEEE Transactions on pattern analsis and machine intelligence, vol. 9, pp. 700-703, 987. [5] R. C. Gonzales, R. E. Woods, S. L. Eddins, Digital image processing using Matlab, st edition, pp. 4-8, Upper Saddle River, 004. 458