Automatic Feature Region Searching Algorithm for Image Registration in Printing Defect Inspection Systems

: Image registration is a key step in printing defect inspection systems based on machine vision, and its accuracy depends on the selected feature regions to a great extent. Aimed at the current problems of low e ﬃ ciency and crucial errors of human vision and manual selection, this study proposes a new automatic feature region searching algorithm for printed image registration. First, all obvious shapes are extracted in the preliminary shape extraction process. Second, shape searching algorithms based on contour point distribution information and edge gradient direction, respectively, are proposed. The two algorithms are combined to put forward a relatively e ﬀ ective and discriminative feature region searching algorithm that can automatically detect shapes such as quasi-rectangular, oval, and so on, as feature regions. The entire image and the subregional experimental results show that the proposed method can be used to extract ideal shape regions, which can be used as characteristic shape regions for image registration in printing defect detection systems.


Introduction
Product surface defect detection is an important application field of machine vision, and it has been widely used in various industries, including the steel industry [1], textile industry [2], semiconductor manufacturing industry [3,4], and printing industry [5,6].For surface defect detection systems based on machine vision, one key technology is image registration.Image registration is an image processing technique that aligns two images spatially.Machine vision inspection systems ensure that each detected image captured by the camera is aligned with the standard template image in a spatial position [7].Selecting the appropriate registration features for different detection contents is a critical in improving registration accuracy.
At present, image registration algorithms can be roughly divided into three types: pixel grayscale-, image feature-, and transform domain-based image registration algorithms [8].The pixel grayscale-based image registration algorithm usually finds the optimal match through a grayscale similarity measure, such as the normalized cross-correlation registration algorithm [9] and the sequential similarity detection algorithm [10].This type of algorithm is stable and usually uses full grayscale information to measure the similarity of two images.However, pixel grayscale-based registration methods are often computationally intensive and thus achieve poor real-time performance.The image feature-based registration algorithm mainly uses image features such as corner, edge, texture, and shape.This method extracts the features of two images and uses a similarity measure to determine the spatial transformation relationship [11].The extracted feature types determine the accuracy of image registration.The existing feature extraction operators mainly include the Harris operator [12], Forstner operator [13], SIFT operator [14], SURF operator [15], FAST operator [16], PCA-SIFT [17], SAR-SIFT [18], AB-SIFT [19], and other operators.This type of algorithm entails a minimal amount of computation and achieves strong robustness.However, for images with inconspicuous features, this type of algorithm seems to be ineffective [17].The transform domain-based registration algorithm transforms images from the spatial domain to the frequency domain and then analyzes the image in the frequency domain to determine the registration parameters.The commonly used frequency domain transform-based image registration algorithms mainly include wavelet transform registration technology [20,21], Fourier transform registration technology [22][23][24] and composite registration algorithm combined with the space and frequency domain [25,26].This type of image registration method has a strong anti-noise ability, but the calculation amount is relatively large.
Pixel grayscale-based and shape feature-based image registration algorithms are widely used in the field of printing defect detection systems based on machine vision.However, as mentioned previously, the pixel grayscale-based image registration algorithm entails a large amount of calculation, achieves low real-time performance, and is greatly influenced by illumination.In addition, the registration feature regions based on pixel grayscale are difficult to establish and are not robust because the image contents of different prints vary widely.Therefore, the current study adopts the shape feature-based image registration algorithm to align captured printed images with a standard reference template image.In existing printing defect detection systems, feature regions are selected manually.However, manual selection results in inconsistent selected regions and low efficiency.These drawbacks affect the precision of registration and cause systems to fail to meet the requirements of the highly automated visual inspection of printed matter.Hence, this study proposes an automatic feature region searching algorithm for image registration without manual marking to improve the real-time results and accuracy of the registration process.In addition, an automatic method for identifying registration subregions is proposed on the basis of the region partition of printed images and a subregional-associated searching method.The proposed method can cope with the misregistration of partial areas caused by paper deformation or slight rotation.Moreover, we propose a method of how to represent a good shape and give an effective feature region searching method.To the best of our knowledge, no previous research has explored this topic.
The main contributions of this work are fourfold.The details are as follows.
(1) An automatic feature region searching algorithm based on a combination of contour point distribution information and edge gradient direction information for image registration in printing defect detection systems was proposed for the first time.Despite the real-time requirements, the proposed algorithm is not complicated, and it solves the problems in printing defect inspection systems, such as low efficiency and inconsistent standards in the manual selection of registration feature regions.(2) We innovatively described the elements of a good shape for registration and proposed good feature shape region searching algorithms using contour and edge gradient direction information.The descriptions of good shapes are discussed in Section 2.2.1.(3) The registration feature region searching algorithm can be implemented on the basis of the region partition of printed images.Doing so can resolve uniform paper deformation, rotation, and registration errors.In the printing process, the paper may show minimal deformation, shift, or rotation.The deformation of each part of the paper after printing varies.In image registration, the adoption of the same transformation parameter in a whole printed image easily results in the partial registration of areas and obvious errors.The method is described in Section 3.2.(4) This study proposes not only a registration feature region determination strategy for subregions based on region partition but also a feature region searching method associated with neighborhood subregions.In the actual automatic feature region searching process, some subregions may not have stable registration feature regions.The proposed feature region searching method associated with neighborhood subregions can address this problem.
The paper is organized as follows.Section 2 presents the methodology, including the problem description, shape feature analysis, proposed shape searching method based on contour point distribution information, shape searching method based on edge gradient direction, and the improved algorithm based on the combination of contour point distribution information and edge gradient direction information.Section 3 discusses the experimental results of the automatic searching of entire image registration feature regions and subregions.Section 4 provides the conclusions.

Description of the Problem
The schematic diagram of a web printing machine is shown in Figure 1.This machine usually consists of four color units, namely, cyan, magenta, yellow, and black.The printing cylinder is continuously rotating, and the printed image of one plate is repeating [5]. Figure 2 shows a schematic diagram of the entire printed image of one plate.The registration marks on the two sides of the image are used to register the cyan, magenta, yellow, and black color units.Printing defect detection generally uses the entire printed image of a cylinder plate as the basic detection unit.The images captured by the line camera are compared with the standard reference template image, which requires image registration.The paper is organized as follows.Section 2 presents the methodology, including the problem description, shape feature analysis, proposed shape searching method based on contour point distribution information, shape searching method based on edge gradient direction, and the improved algorithm based on the combination of contour point distribution information and edge gradient direction information.Section 3 discusses the experimental results of the automatic searching of entire image registration feature regions and subregions.Section 4 provides the conclusions.

Description of the Problem
The schematic diagram of a web printing machine is shown in Figure 1.This machine usually consists of four color units, namely, cyan, magenta, yellow, and black.The printing cylinder is continuously rotating, and the printed image of one plate is repeating [5]. Figure 2 shows a schematic diagram of the entire printed image of one plate.The registration marks on the two sides of the image are used to register the cyan, magenta, yellow, and black color units.Printing defect detection generally uses the entire printed image of a cylinder plate as the basic detection unit.The images captured by the line camera are compared with the standard reference template image, which requires image registration.The paper is organized as follows.Section 2 presents the methodology, including the problem description, shape feature analysis, proposed shape searching method based on contour point distribution information, shape searching method based on edge gradient direction, and the improved algorithm based on the combination of contour point distribution information and edge gradient direction information.Section 3 discusses the experimental results of the automatic searching of entire image registration feature regions and subregions.Section 4 provides the conclusions.

Description of the Problem
The schematic diagram of a web printing machine is shown in Figure 1.This machine usually consists of four color units, namely, cyan, magenta, yellow, and black.The printing cylinder is continuously rotating, and the printed image of one plate is repeating [5]. Figure 2 shows a schematic diagram of the entire printed image of one plate.The registration marks on the two sides of the image are used to register the cyan, magenta, yellow, and black color units.Printing defect detection generally uses the entire printed image of a cylinder plate as the basic detection unit.The images captured by the line camera are compared with the standard reference template image, which requires image registration.Previous printing defect inspection systems utilize the cross-line registration marks on both sides of a printed image as the registration feature.They also inspect the entire printed image of the plate as a whole.However, with the increase in printing speed, the stretching, deformation, and vibration of printing materials cause inconsistencies in the physical size of printed images.Moreover, registration with a whole plate image may cause false detection.Therefore, an increasing number of printing defect inspection systems require partition detection of entire printed images, that is, a printed image is divided into several subregions for sub-area detection.At present, the printed images of each region are not necessarily the same, and the traditional manual method of selecting a registration area is inefficient.Meanwhile, the selection of the feature regions of every sub-area by human vision is unstable and prone to errors.Therefore, an intelligent and automatic registration feature region searching method is urgently needed to achieve an effective selection of the registration feature regions of subdetection area.
Figure 3 presents the flowchart of the online printing defect detection system.We use printing defect visual inspection machine to capture the standard reference template images and other printed images in real time.During printed image defect detection, the image to be detected and the standard reference template image need to be registered initially.We propose an automatic feature region searching algorithm for image registration.
Appl.Sci.2019, 9, x FOR PEER REVIEW 4 of 18 Previous printing defect inspection systems utilize the cross-line registration marks on both sides of a printed image as the registration feature.They also inspect the entire printed image of the plate as a whole.However, with the increase in printing speed, the stretching, deformation, and vibration of printing materials cause inconsistencies in the physical size of printed images.Moreover, registration with a whole plate image may cause false detection.Therefore, an increasing number of printing defect inspection systems require partition detection of entire printed images, that is, a printed image is divided into several subregions for sub-area detection.At present, the printed images of each region are not necessarily the same, and the traditional manual method of selecting a registration area is inefficient.Meanwhile, the selection of the feature regions of every sub-area by human vision is unstable and prone to errors.Therefore, an intelligent and automatic registration feature region searching method is urgently needed to achieve an effective selection of the registration feature regions of subdetection area.
Figure 3 presents the flowchart of the online printing defect detection system.We use printing defect visual inspection machine to capture the standard reference template images and other printed images in real time.During printed image defect detection, the image to be detected and the standard reference template image need to be registered initially.We propose an automatic feature region searching algorithm for image registration.In this work, a region with discriminative shapes is used as the registration feature region for aligning the printed image collected online with the standard template image.A good shape region requires significant contour features and can be highly differentiated from other regions, such as geometric shapes, text, and characters, in printed images.

Shape Feature Analysis
As shown in Figure 4, several shapes are extracted from a printed image after the preliminary shape extraction process (Section 2.2.2).The shape in Figure 4a is mainly composed of several horizontal lines.These shapes are often included in the edges of graphics or in the complicated strokes of the characters in graphics-rich printed matter.Hence, this type of registration region shape is likely to cause a mismatch.The shape in Figure 4b belongs to a segment of a barcode.The shape feature is not obvious, and it is surrounded by many similar shapes, which could cause a mismatch.The shape in Figure 4c consists of the numeral 2 and a horizontal line.The contour of the numeral 2 is relatively regular and highly recognizable and may thus be an ideal shape feature.By contrast, the horizontal line contains little characteristic information and is almost meaningless for shape In this work, a region with discriminative shapes is used as the registration feature region for aligning the printed image collected online with the standard template image.A good shape region requires significant contour features and can be highly differentiated from other regions, such as geometric shapes, text, and characters, in printed images.

Shape Feature Analysis
As shown in Figure 4, several shapes are extracted from a printed image after the preliminary shape extraction process (Section 2.2.2).The shape in Figure 4a is mainly composed of several horizontal lines.These shapes are often included in the edges of graphics or in the complicated strokes of the characters in graphics-rich printed matter.Hence, this type of registration region shape is likely to cause a mismatch.The shape in Figure 4b belongs to a segment of a barcode.The shape feature is not obvious, and it is surrounded by many similar shapes, which could cause a mismatch.The shape in Figure 4c consists of the numeral 2 and a horizontal line.The contour of the numeral 2 is relatively regular and highly recognizable and may thus be an ideal shape feature.By contrast, the horizontal line contains little characteristic information and is almost meaningless for shape matching.In addition, it increases time consumption and is consequently undesirable.Other shapes are formed by the boundaries of the two patterns.The shape shown in Figure 4d is common in texture-rich printed matter; it is irregular and can easily cause a mismatch.On the contrary, the shape region shown in Figure 4e is a Chinese character "period" with obvious features, regular contours, and high degree of recognition feature.Thus, it is a good shape region for image registration during printed image defect detection.
Appl.Sci.2019, 9, x FOR PEER REVIEW 5 of 18 matching.In addition, it increases time consumption and is consequently undesirable.Other shapes are formed by the boundaries of the two patterns.The shape shown in Figure 4d is common in texture-rich printed matter; it is irregular and can easily cause a mismatch.On the contrary, the shape region shown in Figure 4e is a Chinese character "period" with obvious features, regular contours, and high degree of recognition feature.Thus, it is a good shape region for image registration during printed image defect detection.No research or strict definition describes the ideal shape for registration in printing defect inspection.Considering the requirements of the automatic searching of registration feature regions in online printing defect inspection, we innovatively propose a description of an ideal shape.It preferably contains the following three elements: (1) The ideal shape should be a completely closed contour, that is, the contour points should be distributed in all direction bins.(2) The closed shape contour should include approximately vertical and horizontal line points, that is, the gradient directions of 0°, 90°, 180°, and 270° have abundant edge points.(3) Aside from the vertical and horizontal edge points, a good shape contour should have rich edge gradient information.In addition to the edge points in the horizontal and vertical directions, the shape contour should have many changes in contour edge direction and shape.The distribution of edge points in each gradient direction should be uniform.
The analysis shows that the feature region for printed image registration requires a completely closed contour shape, a rich contour edge gradient direction, horizontal and vertical lines, and so on.Therefore, we conclude that regions containing any one shape, such as quasi-rectangle, ellipse-like shapes, or a shape with numerous changes in edge direction, can be used as a feature region for image registration.This feature region should be easy to identify and exhibit strong robustness.This study proposes an automatic shape feature region detection algorithm that can detect quasi-rectangle, ellipse-like shapes, etc.The results should address the inaccurate and time-consuming problems of the manual selection of registration feature regions.

Flow of Proposed Feature Shape Region Searching Algorithm for Image Registration
The proposed feature shape region searching algorithm is shown in Figure 5. Here, "Capture printed images online" means that the printed matter for defect detection is captured on an actual printing press in real time.The proposed algorithm mainly includes four main steps.
(1) Prior to the implementation of the good shape searching algorithm, all shapes in the printed image should be extracted.The step is called the preliminary shape extraction.In this step, all the shapes are preprocessed, and the shape with the appropriate size is selected.The shape regions that are too small or too large are removed because excessively small shape feature affects the accuracy of image registration and an oversized shape greatly reduces the speed of the process.During the preliminary shape extraction process, we implement a series of processes No research or strict definition describes the ideal shape for registration in printing defect inspection.Considering the requirements of the automatic searching of registration feature regions in online printing defect inspection, we innovatively propose a description of an ideal shape.It preferably contains the following three elements: (1) The ideal shape should be a completely closed contour, that is, the contour points should be distributed in all direction bins.(2) The closed shape contour should include approximately vertical and horizontal line points, that is, the gradient directions of 0 • , 90 • , 180 • , and 270 • have abundant edge points.(3) Aside from the vertical and horizontal edge points, a good shape contour should have rich edge gradient information.In addition to the edge points in the horizontal and vertical directions, the shape contour should have many changes in contour edge direction and shape.The distribution of edge points in each gradient direction should be uniform.
The analysis shows that the feature region for printed image registration requires a completely closed contour shape, a rich contour edge gradient direction, horizontal and vertical lines, and so on.Therefore, we conclude that regions containing any one shape, such as quasi-rectangle, ellipse-like shapes, or a shape with numerous changes in edge direction, can be used as a feature region for image registration.This feature region should be easy to identify and exhibit strong robustness.This study proposes an automatic shape feature region detection algorithm that can detect quasi-rectangle, ellipse-like shapes, etc.The results should address the inaccurate and time-consuming problems of the manual selection of registration feature regions.

Flow of Proposed Feature Shape Region Searching Algorithm for Image Registration
The proposed feature shape region searching algorithm is shown in Figure 5. Here, "Capture printed images online" means that the printed matter for defect detection is captured on an actual printing press in real time.The proposed algorithm mainly includes four main steps.
gradient directions is retained.The shape contours that do not satisfy the judgment condition are eliminated.( 4) The contour point distribution information and the edge gradient histogram information are combined to propose an improved automatic feature region searching algorithm for image registration in printing defect inspection systems.The detailed description is provided in Section 2.5.(1) Prior to the implementation of the good shape searching algorithm, all shapes in the printed image should be extracted.The step is called the preliminary shape extraction.In this step, all the shapes are preprocessed, and the shape with the appropriate size is selected.The shape regions that are too small or too large are removed because excessively small shape feature affects the accuracy of image registration and an oversized shape greatly reduces the speed of the process.During the preliminary shape extraction process, we implement a series of processes on the printed images captured online.First, the adaptive segmentation of the captured image is performed, and a connected region analysis is conducted to remove the regions that are excessively small and large.Second, the shape extraction method similar to Canny edge detection is performed, and a high and low threshold idea similar to the hysteresis threshold method is used to exclude the partially inconspicuous edge contour shape.At the same time, the initially extracted shapes are recorded, and each shape is given a label number for the subsequent steps of further searching for a good shape region.(2) The shape feature region is searched on the basis of the contour point distribution information (Section 2.3).In this step, the shape, including the edge points in several direction bins, is retained, and the shape contours that do not satisfy the judgment condition are eliminated.(3) The shape feature region is searched on the basis of the histogram information of the edge gradient direction (Section 2.4).In this step, the shape that includes several contour edge points in four main gradient directions and contour edge points that are evenly distributed in other The outline of a shape is composed of points, and the positional relationship of the points constitutes different shapes.The positional relationship of the shape contour points can be used to describe a shape [27].The specific steps of the proposed algorithm are as follows.
First, the centroid position of the shape is calculated and taken as the pole to establish a polar coordinate system.
Second, the azimuth direction is divided into 12 intervals, and the number of contour points falling into each direction bin is counted, as shown in Figure 6.In this figure, point O is the centroid position, and point P is a point on the shape contour falling within the first direction bin.The outline of a shape is composed of points, and the positional relationship of the points constitutes different shapes.The positional relationship of the shape contour points can be used to describe a shape [27].The specific steps of the proposed algorithm are as follows.
First, the centroid position of the shape is calculated and taken as the pole to establish a polar coordinate system.
Second, the azimuth direction is divided into 12 intervals, and the number of contour points falling into each direction bin is counted, as shown in Figure 6.In this figure, point O is the centroid position, and point P is a point on the shape contour falling within the first direction bin.Third, we count the number of contour points in each direction bin with the assumption that the number of contour points in each direction bin is stored in a variable named Direct, where Direct = (d1, d2, d3, …, d12).The contour points of a regular shape are usually evenly distributed over all directions.Therefore, we propose the following judgement conditions as Formula (1) to determine whether or not a shape is regular: Deviation( ) where d N is the number of direction bins covered by all shape contour points.The operator

D eviation( )
 is used to calculate the normalized standard deviation of the number of contour points in each direction bin.Take Figure 3 as an example.The number of direction bins covered by the contour points of the shape is 8, N is a threshold value that defines the minimum number of direction bins covered by the contour points, and d S is the normalized standard deviation of the number of contour points in each direction bin.The normalized standard deviation is calculated with the standard deviation of the number of contour points in each direction bin divided by the largest standard deviation of all direction bins to adapt to the contour shapes of different sizes.min d and max d , respectively, denote the low threshold and high threshold.The thresholds define the allowable range of the normalized standard deviation of the number of contour points in each direction bin; the more uniform the distribution direction is, the lower the standard deviation will be, resulting in a high upper-limit threshold.Note that the standard deviation of the circle contour is considerably low, that is, it is close to 0. As the circular registration region cannot determine the rotation angle of the Third, we count the number of contour points in each direction bin with the assumption that the number of contour points in each direction bin is stored in a variable named Direct, where Direct = (d 1 , d 2 , d 3 , . . ., d 12 ).The contour points of a regular shape are usually evenly distributed over all directions.Therefore, we propose the following judgement conditions as Formula (1) to determine whether or not a shape is regular: where N d is the number of direction bins covered by all shape contour points.The operator Deviation(•) is used to calculate the normalized standard deviation of the number of contour points in each direction bin.Take Figure 3 as an example.The number of direction bins covered by the contour points of the shape is 8, N is a threshold value that defines the minimum number of direction bins covered by the contour points, and S d is the normalized standard deviation of the number of contour points in each direction bin.The normalized standard deviation is calculated with the standard deviation of the number of contour points in each direction bin divided by the largest standard deviation of all direction bins to adapt to the contour shapes of different sizes.d min and d max , respectively, denote the low threshold and high threshold.The thresholds define the allowable range of the normalized standard deviation of the number of contour points in each direction bin; the more uniform the distribution direction is, the lower the standard deviation will be, resulting in a high upper-limit threshold.Note that the standard deviation of the circle contour is considerably low, that is, it is close to 0. As the circular registration region cannot determine the rotation angle of the image, the circle shape is not suitable as an image registration region.Therefore, we must define the minimum value of the standard deviation.In the actual test, the values of the above parameters are N = 8, d min = 0.01, d max = 0.07.The maximum value of n can be 11.

Experimental Results and Analysis
As shown in Figure 7a,b, the red shape region is the result of the shape search algorithm based on the contour point distribution information, as proposed in Section 2.2.1.Figure 7 shows that the algorithm selects the regular shape region and eliminates the similar shapes in Figure 4c,d.However, the effect of the elimination is poor, as shown in Figure 4a,b.

Experimental Results and Analysis
As shown in Figure 7a,b, the red shape region is the result of the shape search algorithm based on the contour point distribution information, as proposed in Section 2.2.1.Figure 7 shows that the algorithm selects the regular shape region and eliminates the similar shapes in Figure 4c,d.However, the effect of the elimination is poor, as shown in Figure 4a The analysis reveals that the method takes the shape centroid as the reference point and describes the shape according to the distribution of the other points around the centroid.Although the method can judge the regularity of the shape as a whole, it cannot reflect the shape feature well.The shape shown in Figure 2a,b presents a regular contour, but the characteristics are not obvious.Therefore, the proposed method is not suitable for such cases.

Shape Searching Algorithm Based on Edge Gradient Direction
The shape of the image is outlined by the edge, and the edge is the location of gray level changes.The edge also corresponds to the boundary between the foreground and the background.Therefore, the edge gradient direction information can also reflect the shape of the image to some extent [28,29].In general, the regular contour and obvious shape have a regular histogram of the edge gradient direction.Otherwise, the histogram of the edge gradient direction appears random.Therefore, the shape can be described on the basis of the histogram of the edge gradient direction, which is a suitable shape description method.The calculation steps of the histogram of the edge gradient direction are as follows.
First, the edge gradient of the shape is calculated using the Sobel gradient operator shown in Formulas ( 2) and (3), where 1 w is the horizontal gradient operator and 2 w is the vertical gradient operator: The analysis reveals that the method takes the shape centroid as the reference point and describes the shape according to the distribution of the other points around the centroid.Although the method can judge the regularity of the shape as a whole, it cannot reflect the shape feature well.The shape shown in Figure 2a,b presents a regular contour, but the characteristics are not obvious.Therefore, the proposed method is not suitable for such cases.

Shape Searching Algorithm Based on Edge Gradient Direction
The shape of the image is outlined by the edge, and the edge is the location of gray level changes.The edge also corresponds to the boundary between the foreground and the background.Therefore, the edge gradient direction information can also reflect the shape of the image to some extent [28,29].In general, the regular contour and obvious shape have a regular histogram of the edge gradient direction.Otherwise, the histogram of the edge gradient direction appears random.Therefore, the shape can be described on the basis of the histogram of the edge gradient direction, which is a suitable shape description method.The calculation steps of the histogram of the edge gradient direction are as follows.
First, the edge gradient of the shape is calculated using the Sobel gradient operator shown in Formulas (2) and (3), where w 1 is the horizontal gradient operator and w 2 is the vertical gradient operator: Second, with the assumption that the image corresponding to the shape region is I(i, j), the gradient along the x direction is its horizontal gradient denoted by G x (i, j), which is given in Formula (4).Here, i, j, respectively, denote the horizontal and vertical position of the convolution calculation center at the time of Sobel extraction.The calculation is performed on the image corresponding to the minimum circumscribed rectangle of each shape region.
Third, the gradient along the y direction, i.e., the vertical gradient is denoted by Gy(i, j), which is given in Formula (5): Therefore, the gradient direction is given in Formula ( 6): where angle θ is quantized every 5 • as a direction.Thus, the interval between 0 and 2π is divided into 72 direction bins.The histogram of the edge gradient direction can be obtained by counting the number of edge points in each direction.Figure 8 illustrates the histogram of the edge gradient direction, in which every 5 • is a column.
Appl.Sci.2019, 9, x FOR PEER REVIEW 10 of 18 Formula (4).Here, i, j, respectively, denote the horizontal and vertical position of the convolution calculation center at the time of Sobel extraction.The calculation is performed on the image corresponding to the minimum circumscribed rectangle of each shape region.
Third, the gradient along the y direction, i.e., the vertical gradient is denoted by ( ) which is given in Formula ( 5): Therefore, the gradient direction is given in Formula ( 6): ( , ) arctan( ) 0 2 ( , ) where angle θ is quantized every 5° as a direction.Thus, the interval between 0 and 2π is divided into 72 direction bins.The histogram of the edge gradient direction can be obtained by counting the number of edge points in each direction.Figure 8 illustrates the histogram of the edge gradient direction, in which every 5° is a column.Variables L and g H represent the edge perimeter of a shape and the histogram of the edge gradient direction for storing the number of edge points in each direction.These two variables are given in Formula (7).Parameter i h represents the number of edge points in the i-th gradient direction of each shape region.
( ) As shown in Figure 9, several differently shaped regions (marked as green portions) and the Variables L and H g represent the edge perimeter of a shape and the histogram of the edge gradient direction for storing the number of edge points in each direction.These two variables are given in Formula (7).Parameter h i represents the number of edge points in the i-th gradient direction of each shape region.
As shown in Figure 9, several differently shaped regions (marked as green portions) and the corresponding histograms of their edge gradient directions are given.The shape shown in Figure 9a is particularly close to a rectangle.Figure 9b shows that the edge gradient direction of the shape is mainly concentrated in the horizontal and vertical directions, that is, π/2, π, 3π/2, and 2π.The four directions respectively correspond to 18, 36, 54, and 72 gradient direction bins.The histogram of the edge gradient direction distribution resembles a cross shape and a quasi-cross shape.
The four directions respectively correspond to 18, 36, 54, and 72 gradient direction bins.The histogram of the edge gradient direction distribution resembles a cross shape and a quasi-cross shape.
Figure 9c shows an elliptical shape.The number of edge points in the vicinity of the two gradient directions ( /2 π , 3 /2 π ) is large, that is, the numbers of edge points in the 18th and 54th direction or nearby sections are large.The numbers of edge points in the 36th and 72nd directions or nearby sections are also large, and the numbers of edge points in the other gradient directions are relatively close.In general, the histogram distribution of the edge gradient direction is relatively uniform, as shown in Figure 9d, and is similar to the histogram distribution of the edge gradient direction of the quasi-elliptical shape.The values of the Y axis in Figure 9b,d,f are of a gradient magnitude, that is, the number of contour point falling into the direction bin.
( In addition, many shapes exhibit the characteristics of the two types of regions described previously.Figure 9e shows a good shape, which has several edge points in 18, 36, 54, and 72 gradient direction bins.In addition, the numbers of edge points in the other gradient direction bins are relatively close.In general, the histogram distribution of the edge gradient direction is relatively uniform, as shown in Figure 9f. Figure 9c shows an elliptical shape.The number of edge points in the vicinity of the two gradient directions (π/2, 3π/2) is large, that is, the numbers of edge points in the 18th and 54th direction or nearby sections are large.The numbers of edge points in the 36th and 72nd directions or nearby sections are also large, and the numbers of edge points in the other gradient directions are relatively close.In general, the histogram distribution of the edge gradient direction is relatively uniform, as shown in Figure 9d, and is similar to the histogram distribution of the edge gradient direction of the quasi-elliptical shape.The values of the Y axis in Figure 9b,d,f are of a gradient magnitude, that is, the number of contour point falling into the direction bin.
In addition, many shapes exhibit the characteristics of the two types of regions described previously.Figure 9e shows a good shape, which has several edge points in 18, 36, 54, and 72 gradient direction bins.In addition, the numbers of edge points in the other gradient direction bins are relatively close.In general, the histogram distribution of the edge gradient direction is relatively uniform, as shown in Figure 9f.
Figure 9 shows that the aforementioned shapes have obvious features and regular contours and are thus suitable as registration feature regions.Hence, we propose to use the histogram of the edge gradient direction to detect the shape regions with rectangle, cross shape, quasi-rectangle, and quasi-cross shape types as the image registration feature regions.The detection method is defined by Formula (8): where T m is a threshold value used to define the number of edge points in the four gradient direction bins.Alternatively, we can select the shape region in which the overall distribution of the edge points in the gradient direction bins is relatively uniform as a feature region for image registration.The judgment conditions are as follows: where N g is the number of directions covered by the contour points; T n is the threshold of the number of directions, which limits the total number of directions in the lowest gradient and ensures that the shape has obvious features; S g is the normalized standard deviation of the number of edge points in each gradient direction bin and reflects the uniformity of the distribution of edge points in each gradient direction.The size of each shape is different from the inconsistent number of edge points.Therefore, the standard deviation of the number of edge points distributed in each gradient direction bin must be normalized to ensure its versatility for differently shaped regions.T g is a threshold that limits the maximum standard deviation of the edge points distributed over each gradient direction bin.
If the condition is satisfied, then the overall distribution of the edge points of the shape in the gradient direction bin is considered to be uniform.In the actual test, the values of the above threshold parameters are follows: T m = 32, T n = 25, T g = 0.035.The proposed method can extract shapes with rich features and regular contours.For example, the poor shapes of types (a) to (b) in Figure 4 show a good exclusion effect.The reason is that the edge gradient direction of the shape (a) in Figure 4 is mainly concentrated in the horizontal direction, whereas the edge gradient direction of the shape in Figure 4b is mainly concentrated in the vertical direction, and it has a single gradient direction.However, this method is also capable of extracting the shape regions of types (c) to (d) shown in Figure 4.The reason is that the edge gradients of the types (c) to (d) regions are rich and the shape is irregular.Although the basic principle of this method is based on changes in the edge gradient, it does not consider the shape as a whole.Consequently, the method cannot exclude the types (c) to (d) regions shown in Figure 4.In view of the above reasons, we propose a new feature region search method that combines the contour point distribution information and edge gradient direction.

Shape Search Algorithm Based on Combination of Contour Point Distribution and Edge Gradient Direction
The previous analysis reveals that the histogram of the edge gradient direction can effectively represent the shape feature of a region, which belongs to the global feature.The contour point distribution information can reflect the uniformity of the contour point distribution with respect to the centroid, that is, the regularity of the shape contour.The contour point distribution information belongs to local features.Therefore, a new shape searching algorithm based on the combination of the two criteria is proposed.
For a shape region with a rectangular shape, a cross shape, a quasi-rectangular shape, and a quasi-cross shape, the condition shown in Formula (10) should be satisfied, with consideration for the regularity of the shape contour.Then, the shape region can be used as the feature region for printing image registration.
h i > T m , i = 18, 36, 54, 72 d min < S d = Deviation(Direct) < d max (10) For the shape region in which the overall distribution is relatively uniform, the determination condition shown by Formula ( 11) is employed: where the definition of each parameter is the same as the above equations.

Results of Automatic Feature Region Searching for Image Registration
The experimental results show that the proposed shape searching algorithm based on the combination of contour point distribution information and edge gradient direction can select the good shape in the image stably and quickly.Figure 10 provides an example of the result of a printed image.Figure 10a shows all shapes extracted after edge detection and the connected component analysis.Figure 10b shows the good shapes searched.Figure 10c presents a partially enlarged view.
For the shape region in which the overall distribution is relatively uniform, the determination condition shown by Formula ( 11) is employed: Deviation( ) Deviation( ) where the definition of each parameter is the same as the above equations.

Results of Automatic Feature Region Searching for Image Registration
The experimental results show that the proposed shape searching algorithm based on the combination of contour point distribution information and edge gradient direction can select the good shape in the image stably and quickly.Figure 10 provides an example of the result of a printed image.Figure 10a shows all shapes extracted after edge detection and the connected component analysis.Figure 10b shows the good shapes searched.Figure 10c  In addition to the results in Figure 10, the results of the test on the automatic registration feature region searching algorithm for other printed packaging images are given.The red contours in Figures 11a and 12a present all the shapes detected by the preliminary shape extraction method, and the red In addition to the results in Figure 10, the results of the test on the automatic registration feature region searching algorithm for other printed packaging images are given.The red contours in Figures 11a and 12a present all the shapes detected by the preliminary shape extraction method, and the red contours in Figures 11b and 12b represent good shapes searched.Figures 11c and 12c represent, respectively, the partially enlarged image of Figures 11b and 12b

Results of Automatic Feature Region Searching for Subregion Image Registration
A printed image is usually divided into many detection areas to overcome the influence of paper deformation during printing defect inspection.Moreover, a registration feature region is determined for each detection area.If more than one feature region is searched in a detection area, then the feature region near the center of the detection area is generally taken as the feature region for the registration of the area, and the others are discarded.If no feature region is searched in one detection area, then

Results of Automatic Feature Region Searching for Subregion Image Registration
A printed image is usually divided into many detection areas to overcome the influence of paper deformation during printing defect inspection.Moreover, a registration feature region is determined for each detection area.If more than one feature region is searched in a detection area, then the feature region near the center of the detection area is generally taken as the feature region for the registration of the area, and the others are discarded.If no feature region is searched in one detection area, then

Results of Automatic Feature Region Searching for Subregion Image Registration
A printed image is usually divided into many detection areas to overcome the influence of paper deformation during printing defect inspection.Moreover, a registration feature region is determined for each detection area.If more than one feature region is searched in a detection area, then the feature region near the center of the detection area is generally taken as the feature region for the registration of the area, and the others are discarded.If no feature region is searched in one detection area, then the neighboring feature region is taken as the registration feature region to align with the detection area.This approach is called the subregion-associated feature region searching method.
The steps of the detection zone partition and extraction of registration feature region are as follows.
(1) The detection zone is divided automatically according to the size of the printed image, which is mainly based on the appropriate number of partition lines and columns.One registration feature shape region is selected in each subregion of the large printed image.(2) As described above, the setting of the subregion detection is no longer done by manually drawing a rectangular box.It is instead performed by an automatic division method, which can conveniently increase the number of detection areas on the detected sample image and greatly improve the automation of the modeling of the standard template reference image.As shown in Figure 13, the printed images adopt a 3 × 2 partition mode.
Appl.Sci.2019, 9, x FOR PEER REVIEW 15 of 18 the neighboring feature region is taken as the registration feature region to align with the detection area.This approach is called the subregion-associated feature region searching method.The steps of the detection zone partition and extraction of registration feature region are as follows.
(1) The detection zone is divided automatically according to the size of the printed image, which is mainly based on the appropriate number of partition lines and columns.One registration feature shape region is selected in each subregion of the large printed image.(2) As described above, the setting of the subregion detection is no longer done by manually drawing a rectangular box.It is instead performed by an automatic division method, which can conveniently increase the number of detection areas on the detected sample image and greatly improve the automation of the modeling of the standard template reference image.As shown in Figure 13, the printed images adopt a 3 × 2 partition mode.(3) The index of the detection of subregions and feature shape regions adopts the method of automatic nearby index, that is, each detected subregion selects the feature region closest to its own center point as its own index of the registration shape feature region.(4) If the feature region is not searched in the current detected subregion, then the method of searching for the feature region associated with the adjacent subregion is adopted.That is, the feature region closest to the current subregion among all neighboring regions is selected as the registration feature region.
Figure 13 shows the subregion processing result of Figure 10.The printed image size is 1604 × 888, which is divided into six detection areas.As shown in Figure 13, each detection area is automatically searched for a suitable feature region, i.e., the green region in Figure 13.

Shape Search Parameter
After many experiments, the required parameters in the search strategy are determined.The value of each parameter is suitable when searching for shapes (Table 1).Therefore, in the actual search strategy, the parameter in Table 1 is taken as the initial value of the parameter if the condition is not found under this condition.The appropriate parameter limits of the shape can be further relaxed.(3) The index of the detection of subregions and feature shape regions adopts the method of automatic nearby index, that is, each detected subregion selects the feature region closest to its own center point as its own index of the registration shape feature region.(4) If the feature region is not searched in the current detected subregion, then the method of searching for the feature region associated with the adjacent subregion is adopted.That is, the feature region closest to the current subregion among all neighboring regions is selected as the registration feature region.
Figure 13 shows the subregion processing result of Figure 10.The printed image size is 1604 × 888, which is divided into six detection areas.As shown in Figure 13, each detection area is automatically searched for a suitable feature region, i.e., the green region in Figure 13.

Shape Search Parameter
After many experiments, the required parameters in the search strategy are determined.The value of each parameter is suitable when searching for shapes (Table 1).Therefore, in the actual search strategy, the parameter in Table 1 is taken as the initial value of the parameter if the condition is not found under this condition.The appropriate parameter limits of the shape can be further relaxed.In the experiment, the time required to search for the best shape region in the printed image with size of 1604 × 888 pixel is 4 s.In an actual printing defect detection system, searching the feature region in the detected reference template image is set offline.Therefore, this speed of 4 s can meet the needs of the printing defect detection industry.

Conclusions
Automatic methods for searching feature regions in printed image registration are studied in this work, and the existing problems of the manual marker feature regions are addressed.The automatic feature region searching method for image registration without manual marking is proposed.First, the characteristics of different shapes are analyzed.The characteristics of feature region shapes for image registration are proposed.Second, the contour point distribution information and the edge gradient direction are combined.The decision conditions of the corresponding shape searching algorithm are given.The experimental results show that the proposed method can extract the ideal shape, such as a quasi-rectangle region and a quasi-ellipse region, and use it as the image registration feature region in a printing defect detection system.
The contributions of the proposed automatic feature region searching algorithms are as follows.First, despite the real-time requirements of printing defect inspection systems, the proposed algorithm for the automatic searching of registration feature regions is not particularly complicated and solves the problem in printing defect online detection systems.It also solves the problem of automatically, efficiently, and accurately establishing the registration feature regions in printing defect detection systems.The method can establish a detection standard reference template image automatically and quickly during online printing defect detection.The problem of low efficiency and unreliability of registration regions in manual searching is overcome by the proposed method, which provides an effective solution for image registration feature region searching in printing defect detection systems.Second, the description of a good shape region for image registration for printing defect inspection is proposed.Lastly, the proposed feature region extraction method for subregion registration and the subregion-associated feature region searching method solve the problem of local registration errors for the registration of entire printed images caused by the deformation and rotation of printed images.The proposed method is successfully applied to an actual online printing defect detection system for a certain enterprise.

Figure 2 .
Figure 2. Entire printed image of one plate and the color registration mark.

Figure 2 .
Figure 2. Entire printed image of one plate and the color registration mark.Figure 2. Entire printed image of one plate and the color registration mark.

Figure 2 .
Figure 2. Entire printed image of one plate and the color registration mark.Figure 2. Entire printed image of one plate and the color registration mark.

Figure 3 .
Figure 3. Flowchart of online printing defect inspection.

Figure 3 .
Figure 3. Flowchart of online printing defect inspection.

Figure 5 .Figure 5 .
Figure 5. Flow chart of the proposed feature region searching algorithm.

Figure 6 .
Figure 6.Shape and its contour point distribution information.

Figure 6 .
Figure 6.Shape and its contour point distribution information.

Figure 7 .
Figure 7. Experimental results of shape searching algorithm based on contour point distribution information.(a) Shape 1; (b) Shape 2.

Figure 7 .
Figure 7. Experimental results of shape searching algorithm based on contour point distribution information.(a) Shape 1; (b) Shape 2.

Figure 8 .
Figure 8. Histogram of edge gradient direction for the shape region.(a) Schematic diagram of gradient direction.(b) Histogram of gradient direction of one shape region

Figure 8 .
Figure 8. Histogram of edge gradient direction for the shape region.(a) Schematic diagram of gradient direction.(b) Histogram of gradient direction of one shape region

Figure 9 .
Figure 9. Experiment results of the method based on the histogram of the edge gradient direction.(a) Approximate rectangular shape; (b) shape's histogram of edge gradient direction; (c) elliptical shape; (d) shape's histogram of edge gradient direction; (e) good shape; (f) shape's histogram of edge gradient direction histogram.

Figure 9 .
Figure 9. Experiment results of the method based on the histogram of the edge gradient direction.(a) Approximate rectangular shape; (b) shape's histogram of edge gradient direction; (c) elliptical shape; (d) shape's histogram of edge gradient direction; (e) good shape; (f) shape's histogram of edge gradient direction histogram.

Figure 10 .
Figure 10.First set of searching results for good shapes.(a) All shapes detected; (b) good shapes searched; (c) partially enlarged image of Figure (b).

Figure 10 .
Figure 10.First set of searching results for good shapes.(a) All shapes detected; (b) good shapes searched; (c) partially enlarged image of Figure (b). .
Appl.Sci.2019, 9, x FOR PEER REVIEW 14 of 18 contours in Figures 11b and 12b represent good shapes searched.Figures 11c and 12c represent, respectively, the partially enlarged image of Figures 11b and 12b .

Figure 11 .Figure 12 .
Figure 11.Second set of searching results for good shapes.(a) All shapes detected; (b) good shapes searched; (c) partially enlarged image of Figure (b).

Figure 11 .
Figure 11.Second set of searching results for good shapes.(a) All shapes detected; (b) good shapes searched; (c) partially enlarged image of Figure (b).

Figure 11 .Figure 12 .
Figure 11.Second set of searching results for good shapes.(a) All shapes detected; (b) good shapes searched; (c) partially enlarged image of Figure (b).

Figure 12 .
Figure 12.Third set of searching results for good shapes.(a) All shapes detected; (b) good shapes searched; (c) partially enlarged image of Figure (b).

Figure 13 .
Figure 13.Results of subregion searching of shape feature region for image registration.

Figure 13 .
Figure 13.Results of subregion searching of shape feature region for image registration.
directions is retained.The shape contours that do not satisfy the judgment condition are eliminated.(4)The contour point distribution information and the edge gradient histogram information are combined to propose an improved automatic feature region searching algorithm for image registration in printing defect inspection systems.The detailed description is provided in Section 2.5. gradient

Table 1 .
Selected parameter values for shape search.