IMAGE INSPECTION APPARATUS AND NON-TRANSITORY COMPUTER READABLE MEDIUM STORING IMAGE INSPECTION PROGRAM

An image inspection apparatus includes a processor configured to: divide a read image obtained by reading a printed image and a reference image representing an original shape of the printed image into plural regions having the identical shape, respectively; set a movement direction of the region for each of the divided regions of the reference image according to a feature of the reference image in the region; and inspect a deviation between the read image and the reference image for each of corresponding regions of the read image and the reference image by moving the region of the reference image in the movement direction which is set for the region.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is based on and claims priority under 35 USC 119 from Japanese Patent Application No. 2020-198468 filed Nov. 30, 2020.

BACKGROUND

(i) Technical Field

The present invention relates to an image inspection apparatus and a non-transitory computer readable medium storing an image inspection program.

(ii) Related Art

JP2013-186562A discloses an image inspection apparatus that performs inspection by collating a read image obtained by reading an image formed on paper by using an image forming apparatus with an original reference image. The image inspection apparatus includes an inspection and comparison unit for comparison and collation. In the image inspection apparatus, the inspection and comparison unit divides the entire image into a plurality of blocks, performs first alignment in a plurality of regions in the vicinity of the image, calculates a misalignment amount of each block of the read image based on a result of the first alignment, and performs alignment while slightly shifting the block of the read image shifted according to the misalignment amount and the block of the reference image. Further, the inspection and comparison unit selects a predetermined block in the image, performs second alignment by recalculating a misalignment amount of the selected block, and corrects the misalignment amount of each block of the read image based on a result of the second alignment.

SUMMARY

The read image obtained by reading the image, which is formed on paper by the image forming apparatus, using an optical apparatus such as a scanner is an input image of the image inspection apparatus. Due to, for example, a misalignment of the paper, the read image may be misaligned with respect to the reference image as a source of the read image.

In the related art, in a case of inspecting whether or not there is a deviation between the read image and the reference image, the deviation between the read image and the reference image is calculated from a movement amount of the reference image by dividing the read image and the reference image into a plurality of regions and detecting a position at which the image included in the region of the corresponding read image and the image included in the region of the reference image maximally match with each other while moving the region of the reference image in all directions for each region.

However, in a case of the inspection method, it is necessary to detect the position at which the image included in the region of the corresponding read image and the image included in the region of the reference image maximally overlap with each other while moving the region of the reference image by trial and error. As a result, it takes a time to complete the inspection.

Aspects of non-limiting embodiments of the present disclosure relate to provide an image inspection apparatus and a non-transitory computer readable medium storing an image inspection program capable of shortening an inspection time as compared with a case of inspecting a deviation between the read image and the reference image for each region obtained by dividing the read image as an image inspection target and the reference image while moving the region without setting the movement direction of the region.

According to an aspect of the present disclosure, there is provided an image inspection apparatus includes a processor configured to: divide a read image obtained by reading a printed image and a reference image representing an original shape of the printed image into a plurality of regions having the identical shape, respectively; set a movement direction of the region for each of the divided regions of the reference image according to a feature of the reference image in the region; and inspect a deviation between the read image and the reference image for each of corresponding regions of the read image and the reference image by moving the region of the reference image in the movement direction which is set for the region.

DETAILED DESCRIPTION

Hereinafter, an exemplary embodiment of the present invention will be described with reference to the drawings. The same components and the same processing are denoted by the same reference numerals throughout the drawings, and repeated descriptions will be omitted.

FIG. 1is a diagram illustrating a functional configuration example of an image inspection apparatus10according to the exemplary embodiment of the present invention. The image inspection apparatus10inspects whether a deviation of a read image2with respect to a reference image4is within an allowable range by comparing a deviation between the read image2and the reference image4. The read image2is a printed image printed on paper by an image forming apparatus (not illustrated), that is, an image obtained by reading a printed matter using an optical apparatus such as a scanner, andFIG. 2illustrates an example of the read image2. Further, the reference image4is an original image of a printed image printed by an image forming apparatus (not illustrated), that is, an image representing an original shape of the read image2.FIG. 3illustrates an example of the reference image4with respect to the read image2illustrated inFIG. 2.

It is noted that positions of pixels of the read image2and the reference image4are represented by, for example, two-dimensional coordinates on an X-axis and a Y-axis in a case where an upper left vertex of each image is set as an origin. The Y-axis is an axis along a vertical direction of each of the read image2and the reference image4, and the X-axis is an axis along a horizontal direction of each of the read image2and the reference image4. For this reason, the vertical direction of each of the read image2and the reference image4is represented by a “Y-axis direction”, and the horizontal direction of each of the read image2and the reference image4is represented by an “X-axis direction”.

In a case where the deviation of the read image2with respect to the reference image4is not within the allowable range, the printed matter corresponding to the read image2is a defective product, and thus a procedure such as non-shipping of the printed matter is performed.

Therefore, in response to input of the read image2, the image inspection apparatus10outputs an inspection result including whether or not the deviation of the read image2with respect to the reference image4is within the allowable range.

The image inspection apparatus10includes functional units of an input unit11, a division unit12, a movement direction setting unit13, an inspection unit14, and an output unit15, and a data storage DB16that stores the reference image4.

The input unit11receives the read image2as an inspection target, and notifies the division unit12of the received read image2.

In a case where the division unit12receives the read image2from the input unit11, the division unit12acquires the reference image4which is an original image of the read image2from the data storage DB16. Then, the division unit12divides the read image2and the reference image4into a plurality of regions. Hereinafter, each of the plurality of divided regions is referred to as a “block”.

FIGS. 4A and 4Bare diagrams illustrating an example of the read image2and the reference image4which are divided into blocks by the division unit12.FIG. 4Aillustrates an example of the reference image4divided into blocks, andFIG. 4Billustrates an example of the read image2divided into blocks.

There is no restriction on a shape and a size of each of the blocks divided by the division unit12. In this description, as an example, the read image2and the reference image4are respectively divided in a grid pattern along the X-axis direction and the Y-axis direction. In the blocks divided in a grid pattern, the shape of each block is rectangular, and the size of each block is identical. In addition, the blocks are divided in a predetermined size.

Each block of the reference image4is represented as “a reference image block400”, and each block of the read image2is represented as “a read image block200”. In a case where the read image2and the reference image4are overlapped with each other, the read image block200and the reference image block400at the identical position are represented as “the read image block200corresponding to the reference image block400”.

After the division unit12divides the read image2and the reference image4into the plurality of blocks, the division unit12notifies the movement direction setting unit13of division completion.

In a case where the movement direction setting unit13receives, from the division unit12, a notification that the division into the blocks is completed, the movement direction setting unit13sets a movement direction of the reference image block400for each reference image block400according to a feature of an image in the reference image block400, that is, a feature of a block image of the reference image block400.

The movement direction setting unit13sets, as a movement direction of the reference image block400, a specific direction in which the reference image block400may move, instead of setting a movement direction of the reference image block400such that the reference image block400can move in any direction of 360 degrees in a case of being viewed from a center of the reference image block400. That is, the movement direction of the reference image block400is restricted.

FIG. 5is a diagram illustrating an example of a movement direction which is set for the reference image block400. In the example illustrated inFIG. 5, the movement direction for the reference image block400is set along the X-axis direction and the Y-axis direction. In this case, the reference image block400can move in directions along the X-axis direction and the Y-axis direction, and cannot move, for example, in a direction in which an angle formed by the X-axis direction is 45 degrees.

The movement direction setting unit13sets the movement direction for each of the reference image blocks400divided from the reference image4, and then notifies the inspection unit14of movement direction setting completion.

In a case where the inspection unit14receives a notification of movement direction setting completion from the movement direction setting unit13, for example, the inspection unit14overlaps the reference image block400and the read image block200such that vertexes of the reference image block400and vertexes of the read image block200corresponding to the reference image block400match with each other for each reference image block400. A position at which the reference image block400and the read image block200are overlapped with each other such that at least one vertex of the reference image block400and at least one vertex of the read image block200match with each other is referred to as a “reference position”.

From this state, the inspection unit14detects a position at which the block image of the reference image block400and the block image of the read image block200most overlap with each other (hereinafter, referred to as a “collation position”) while moving the reference image block400in the movement direction which is set by the movement direction setting unit13.

The inspection unit14represents a movement amount of the reference image block400from the reference position to the collation position by the number of pixels. For example, in a case where an average value of the movement amounts of each reference image block400is equal to or larger than a predetermined reference threshold value, the inspection unit14determines that there is a deviation between the read image2and the reference image4, and sets an inspection result to “fail”. On the other hand, in a case where the average value of the movement amounts of each reference image block400is smaller than the predetermined reference threshold value, the inspection unit14determines that there is no deviation between the read image2and the reference image4, and set an inspection result to “pass”. The inspection unit14notifies the output unit15of the inspection result for the read image2.

In a case where the output unit15receives the inspection result from the inspection unit14, the output unit15outputs the received inspection result. Thereby, whether the printed matter corresponding to the read image2is a non-defective product or a defective product is specified. The “output” according to the exemplary embodiment of the present invention refers to making the inspection result into a recognizable state, and includes a form of displaying the inspection result, a form of printing the inspection result on a recording medium such as paper, a form of notifying the inspection result by voice, a form of storing the inspection result in a storage device, and a form of transmitting the inspection result to an apparatus other than the image inspection apparatus10(hereinafter, referred to as an “external apparatus”) via a communication line (not illustrated).

The data storage DB16stores the reference image4. The “DB” is an abbreviation for a database, and the data storage DB16provides a management function of the reference image4such as storing of the reference image4, reading of the reference image4, and deletion of the reference image4.

The image inspection apparatus10is configured by using, for example, a computer20.

FIG. 6is a diagram illustrating a configuration example of a main part of an electric system of the image inspection apparatus10in a case where the image inspection apparatus10is configured by using the computer20.

The computer20includes a central processing unit (CPU)21, which is an example of a processor that handles processing of each functional unit of the image inspection apparatus10illustrated inFIG. 1, a read only memory (ROM)22that stores an image inspection program, a random access memory (RAM)23that is used as a temporary work area of the CPU21, a non-volatile memory24, and an input/output interface (I/O)25. The CPU21, the ROM22, the RAM23, the non-volatile memory24, and the I/O25are connected to each other via a bus26.

The non-volatile memory24is an example of a storage device that maintains the stored information even in a case where power supplied to the non-volatile memory24is cut off. As the non-volatile memory24, for example, a semiconductor memory is used. On the other hand, a hard disk may be used. The non-volatile memory24does not necessarily have to be built in the computer20, and may be a storage device such as a memory card that is detachably attached to the computer20. The data storage DB16is stored in the non-volatile memory24.

For example, a communication unit27, an input unit28, and an output unit29are connected to the I/O25.

The communication unit27is connected to a communication line (not illustrated) and includes a communication protocol for performing communication with an external apparatus connected to the communication line. The communication line (not illustrated) includes a known communication line such as the Internet or a local area network (LAN). The communication line (not illustrated) may be wired or wireless.

The input unit28is a device that receives an instruction from a user and notifies the CPU21of the instruction, and includes, for example, a button, a touch panel, a keyboard, a pointing device, and a mouse. The image inspection apparatus10may receive an instruction from a user by voice, and in this case, a microphone is used as the input unit28.

The output unit29is a device that outputs information processed by the CPU21, and includes, for example, a liquid crystal display, an organic electro luminescence (EL) display, a display device such as a projector that projects a video on a screen, a speaker, an image forming unit that forms texts and figures on a recording medium, and a storage device that stores information.

The image inspection apparatus10does not necessarily include all the units connected to the I/O25and illustrated inFIG. 6, and the necessary units may be connected to the I/O25depending on a situation. For example, in a case where the image inspection apparatus10operates offline, the communication unit27is not always necessary.

Next, an operation of the image inspection apparatus10will be described in detail.

FIG. 7is a flowchart illustrating an example of a flow of inspection processing executed by the CPU21in a case where the image inspection apparatus10receives the read image2. The image inspection program that defines the inspection processing is stored in advance in, for example, the ROM22of the image inspection apparatus10. The CPU21of the image inspection apparatus10reads the image inspection program stored in the ROM22, and executes the inspection processing.

In step S10, the CPU21acquires the reference image4corresponding to the received read image2from the non-volatile memory24. Specifically, the CPU21may acquire the reference image4corresponding to the read image2from the non-volatile memory24by referring to an image ID assigned to the read image2.

The CPU21may acquire the reference image4from an external apparatus via a communication line (not illustrated) instead of acquiring the reference image4from the non-volatile memory24.

In step S20, the CPU21respectively divides the read image2and the reference image4which is acquired in step S10into read image blocks200and reference image blocks400as illustrated inFIGS. 4A and 4B.

FIGS. 8A and 8Bare diagrams illustrating a division example of the read image2and the reference image4.FIG. 8Ais a division example of the reference image4illustrated inFIG. 3, andFIG. 8Bis a division example of the read image2illustrated inFIG. 2. In the example ofFIGS. 8A and 8B, the reference image4and the read image2are respectively divided in a grid pattern to have a predetermined size such that each reference image block400and each read image block200do not respectively overlap with the adjacent reference image block400and the adjacent read image block200.

In step S30, the CPU21selects, from a plurality of reference image blocks400divided in step S20, any one reference image block400that is not yet selected. For the convenience of explanation, the selected reference image block400will be referred to as a “selected reference image block400”.

In step S40, the CPU21extracts edge information of the block image from the selected reference image block400. An “edge” is a set of pixels located at a boundary at which color information of a pixel that is represented by a pixel value changes by a predetermined threshold value or more between adjacent pixels, and is also called a “contour line”. As the color information of a pixel, at least one of a hue, a chroma, or brightness is used. Thus, in addition to a line, boundaries in color and brightness are also extracted as edges.

For example, inFIG. 8A, in a case where the reference image block400A is selected as the selected reference image block400, an edge along the X-axis direction is extracted from the reference image block400A. In a case where the reference image block400B is selected as the selected reference image block400, an edge is not extracted because the block image of the reference image block400B is all colored with the identical density. In a case where the reference image block400C is selected as the selected reference image block400, edges represented by a curved line and a straight line are extracted from the reference image block400C. In a case where the reference image block400D is selected as the selected reference image block400, an edge along the Y-axis direction is extracted from the reference image block400D.

In step S50, the CPU21specifies a direction of the edge of the block image of the selected reference image block400based on the edge information extracted in step S40, and classifies the selected reference image block400into a category according to the direction of the edge.

FIG. 9is a diagram illustrating a classification example in which the reference image blocks400are classified into categories according to the directions of the edges. In the exemplary embodiment of the present invention, the reference image blocks400are classified into four categories according to the directions of the edges.

Specifically, the CPU21classifies the reference image blocks400into four categories including a category for no-edge (referred to as “category 0”), a category for which the directions of the edges include an X-axis direction component and a Y-axis direction component (referred to as “category 1”), a category for which the directions of the edges include only a Y-axis direction component (referred to as “category 2”), and a category for which the directions of the edges include only an X-axis direction component (referred to as “category 3”).

Since an edge is not extracted from the reference image block400B, the CPU21classifies the reference image block400B into the category 0.

Edges represented by a curved line and a straight line are extracted from the reference image block400C. Since the curved line includes both of the Y-axis direction component and the X-axis direction component, the CPU21classifies the reference image block400C into the category 1.

Since an edge along the Y-axis direction is extracted from the reference image block400D, the CPU21classifies the reference image block400D into the category 2.

Since an edge along the X-axis direction is extracted from the reference image block400A, the CPU21classifies the reference image block400A into the category 3.

In step S60, the CPU21determines whether or not there is an unselected reference image block400that is not yet selected in step S30among the reference image blocks400divided from the reference image4. In a case where there is an unselected reference image block400, the process proceeds to step S30, and any one reference image block400is selected from the unselected reference image blocks400. By repeatedly executing processing of each of steps S30to S60until it is determined that there is no unselected reference image block400in the determination processing of step S60, the CPU21classifies all the reference image blocks400divided from the reference image4into the categories.

In the determination processing of step S60, in a case where it is determined that there is no unselected reference image block400, the process proceeds to step S70.

In step S70, the CPU21sets the movement direction of the reference image block400for each category classified according to the directions of the edges.

For example, since the reference image block400included in the category 3 includes only edges along the X-axis direction, even in a case where the reference image block400is moved in the X-axis direction, it is difficult to detect a collation position between the reference image block400and the read image block200corresponding to the reference image block400.

Therefore, a direction intersecting with the direction of the edge, specifically, a direction orthogonal to the direction of the edge may be set as the movement direction of the reference image block400. That is, the CPU21sets the movement direction of each reference image block400included in the category 3 to the Y-axis direction.

For the same reason, since the reference image block400included in the category 2 includes only edges along the Y-axis direction, the CPU21sets the movement direction of each reference image block400included in the category 2 to the X-axis direction orthogonal to the Y-axis direction.

Since the reference image block400included in the category 1 includes edges along the X-axis direction and the Y-axis direction, the CPU21sets the movement direction of each reference image block400included in the category 1 to the X-axis direction and the Y-axis direction.

In a case of the reference image block400that does not include an edge as in the reference image block400included in the category 0, there is no information that serves as a mark for detecting the collation position. For this reason, it is difficult to detect a collation position regardless of the movement direction of the reference image block400. Therefore, the CPU21does not set the movement direction for each reference image block400included in the category 0 to any direction.

That is, the movement direction which is set for the reference image block400is restricted to a movement direction in which a collation position is most easily detected among all the movement directions.

In step S80, the CPU21selects any one reference image block400from the reference image blocks400classified into categories.

In step S90, the CPU21determines whether or not the selected reference image block400includes an edge, that is, whether or not the selected reference image block400is a reference image block400classified into the category 0. In a case where the selected reference image block400includes an edge, the process proceeds to step S100.

In step S100, the CPU21moves the selected reference image block400in the movement direction which is set for the selected reference image block400, detects a collation position between the selected reference image block400and the read image block200corresponding to the selected reference image block400, and calculates a deviation between the selected reference image block400and the read image block200from a movement amount of the selected reference image block400. A known method such as pattern recognition may be used to detect the collation position.

For example, in a case where the selected reference image block400is classified into the category 1, the CPU21moves the selected reference image block400in the X-axis direction and the Y-axis direction, and calculates the deviation from the corresponding read image block200.

In a case where the selected reference image block400is classified into the category 2, the CPU21moves the selected reference image block400in the X-axis direction, and calculates the deviation from the corresponding read image block200.

In a case where the selected reference image block400is classified into the category 3, the CPU21moves the selected reference image block400in the Y-axis direction, and calculates the deviation from the corresponding read image block200.

Specifically, in a case where the selected reference image block400is the reference image block400A ofFIG. 8A, the CPU21moves the reference image block400A from the reference position in the Y-axis direction, and calculates the deviation from the read image block200A illustrated inFIG. 8B, the read image block200A being the read image block200corresponding to the reference image block400A.

In a case where the selected reference image block400is the reference image block400C ofFIG. 8A, the CPU21moves the reference image block400C from the reference position in the X-axis direction and the Y-axis direction, and calculates the deviation from the read image block200C illustrated inFIG. 8B, the read image block200C being the read image block200corresponding to the reference image block400C.

In a case where the selected reference image block400is the reference image block400D ofFIG. 8A, the CPU21moves the reference image block400D from the reference position in the X-axis direction, and calculates the deviation from the read image block200D illustrated inFIG. 8B, the read image block200D being the read image block200corresponding to the reference image block400D.

In step S110, the CPU21stores, in the RAM23, the deviation between the selected reference image block400and the read image block200corresponding to the selected reference image block400, the deviation being calculated in step S100.

On the other hand, in the determination processing of step S90, in a case where it is determined that the selected reference image block400does not include an edge, it is more difficult to calculate the deviation from the corresponding read image block200using the selected reference image block400as compared with a case where the deviation from the corresponding read image block200is calculated using the reference image block400including an edge.

Therefore, the CPU21proceeds to step S120without executing processing of step S100and processing of step S110.

In a case where the reference image block400that does not include an edge is used to calculate the deviation from the read image block200corresponding to the reference image block400, since there is no information that serves as a mark for detecting the collation position in the reference image block400, it is more difficult to detect the collation position as compared with a case where the collation position is detected using the reference image block400including an edge. Further, in this case, even in a case where the collation position can be detected using a certain known method, an accuracy in detection of the obtained collation position is low.

Therefore, by not using the reference image block400that does not include an edge in the inspection of the deviation between the reference image block400and the read image block200, an inspection time may be shortened and an inspection accuracy may be improved.

In step S120, the CPU21determines whether or not there is an unselected reference image block400that is not yet selected in step S80among the reference image blocks400classified into the categories. In a case where there is an unselected reference image block400, the process proceeds to step S80, and any one reference image block400is selected from the unselected reference image blocks400classified into the categories. By repeatedly executing processing of each of steps S80to S120until it is determined that there is no unselected reference image block400in the determination processing of step S120, for each reference image block400, the deviation from the read image block200corresponding to the reference image block400is calculated.

On the other hand, in the determination processing of step S120, in a case where it is determined that there is no unselected reference image block400, the process proceeds to step S130.

In step S130, in a case where an average value of the deviations between the reference image blocks400and the read image blocks200corresponding to the reference image blocks400is smaller than the reference threshold value, the deviation being stored, for example, in the RAM23for each reference image block400in step S110, the CPU21sets an inspection result to “pass”. On the other hand, in a case where the average value of the deviations is equal to or larger than the reference threshold value, the CPU21sets an inspection result to “fail”. The CPU21outputs the inspection result of the printed matter corresponding to the read image2, and ends the inspection processing illustrated inFIG. 7.

As described above, the image inspection apparatus10according to the exemplary embodiment of the present invention calculates the deviation from the read image block200corresponding to the reference image block400by setting the movement direction of the reference image block400from the directions of the edges included in the reference image block400and detecting the collation position while moving the reference image block400only in the movement direction which is set. Therefore, a time required for the inspection can be shortened as compared with a case of detecting the collation position while moving the reference image block400in all directions without setting the movement direction of the reference image block400.

In the inspection processing described above, the reference image blocks400are classified into four categories according to the directions of the edges. On the other hand, there is no restriction on the number of categories for classification. For example, the category may be subdivided as in a case where an edge including only components in a direction at an angle of 45 degrees with respect to the X-axis direction is classified into a category 4. The movement direction of the reference image block400classified into the category 4 may be set to a direction orthogonal to the direction of the edge, similarly to the reference image block400classified into other categories. Therefore, in this case, the CPU21moves the reference image block400in a direction at an angle of 45 degrees with respect to the X-axis direction, and detects the collation position between the reference image block400and the read image block200corresponding to the reference image block400.

Further, the CPU21may set a direction orthogonal to the direction of the edge included in the reference image block400to the movement direction of the reference image block400without classifying the reference image block400into a category, and associate the reference image block400with the movement direction which is set.

Further, in the inspection processing described above, since the reference image block400B ofFIG. 8Adoes not include an edge, the deviation between the reference image block400B and the read image block200B is not calculated. On the other hand, in a case where there is a deviation in the read image2, the read image block200B may include an edge as illustrated inFIG. 8B.

In step S20ofFIG. 7, the CPU21divides the reference image4such that the adjacent reference image blocks400do not overlap with each other. On the other hand, as illustrated inFIG. 10, in a case where the reference image block400B is expanded to a size larger than a predetermined size, the extended reference image block400B (referred to as a “reference image block400BB”) may include an edge of the block image, and the deviation from the read image block200B may be calculated.

Therefore, in step S20ofFIG. 7, the CPU21may divide the reference image4into the reference image blocks400, which are expanded to a size larger than a predetermined size according to a degree of the deviation of the read image2.

The CPU21determines whether or not to expand the size of the reference image block400, and determines an amount of expansion of the reference image block400in a case where it is determined to expand the size of the reference image block400, based on history information in which a tendency of the deviation between the read image2and the reference image4is recorded so far. For example, in a case where, in each of a plurality of printed matters having the identical type, an average value of deviations between the read image2and the reference image4is 3 pixels, the CPU21divides the reference image4into the reference image blocks400which are respectively enlarged by 3 pixels in the X-axis direction and the Y-axis direction from a predetermined size. Each of the expanded reference image blocks400overlaps with the expanded range, that is, the adjacent reference image block400by 3 pixels.

Further, the CPU21may divide only a specific reference image block400into an expanded size larger than a predetermined size. For example, the reference image block400that does not include an edge in a case of being divided into a predetermined size may be expanded to a size such that the reference image block400includes any edge.

Further, the CPU21may divide the reference image4into the reference image blocks400which are reduced to a size smaller than the predetermined size. By reducing the reference image blocks400to a size smaller than the predetermined size, an amount of information included in each reference image block400becomes smaller than an amount of information included in each reference image block400in a case where the reference image block400is divided into the predetermined size. Therefore, it becomes easier to detect the collation position than in a case where the collation position is detected using the reference image block400having a predetermined size as it is.

Further, in step S20ofFIG. 7, the CPU21may change the size of each reference image block400according to complexity of the reference image4at a position of the reference image block400, instead of dividing the reference image4into the reference image blocks400having the predetermined identical size.

For example, as the reference image4includes a more complicated portion, edges are entangled with each other, and as a result, it becomes difficult to detect the collation position between the read image block200and the reference image block400. Thus, in step S20ofFIG. 7, as the reference image4includes a more complicated portion, the CPU21further reduces the size of the reference image block400including the portion. Therefore, it becomes easier to detect the collation position between the read image block200and the reference image block400. A fact that the collation position between the read image block200and the reference image block400can be easily detected leads to an improvement in the inspection accuracy of the deviation between the read image2and the reference image4.

The CPU21sets the complexity at each position of the reference image4according to, for example, the number of edges at each position of the reference image4. On the other hand, the CPU21may set the complexity at each position of the reference image4according to, for example, a variation in the directions of the edges, that is, a variance value in the directions of the edges, instead of the number of edges at each position of the reference image4. As the reference image4includes a portion having a larger variation in the directions of the edges, it is considered that the reference image4includes a more complicated portion. Thus, the CPU21divides the reference image4such that a size of the reference image block400including the portion is smaller than a predetermined size.

FIG. 11is a diagram illustrating an example in which the reference image4illustrated inFIG. 3is divided into the reference image blocks400having different sizes according to the complexity of the reference image4. As illustrated inFIG. 11, as the reference image block400is located at a position at which the number of the included edges is larger, the reference image block400is divided into a smaller size.

Further, in step S20ofFIG. 7, the CPU21divides the received read image2into the read image blocks200. On the other hand, in a case where the read image2and the reference image4are divided after rough alignment such that the read image2and the reference image4overlap with each other as much as possible, a matching degree between the read image2and the reference image4is higher than a matching degree between the read image2and the reference image4before alignment. Thereby, in step S100, it becomes easier to calculate the deviation between the reference image block400and the read image block200corresponding to the reference image block400.

Therefore, preferably, for example, the CPU21performs affine transformation on the read image2such that the read image2and the reference image4match with each other as much as possible, and then respectively divides the read image2and the reference image4into the read image blocks200and the reference image blocks400. The affine transformation is processing such as enlargement, reduction, or rotation on the read image2, and a linear deviation between the read image and the reference image4is corrected by the affine transformation.

Since the linear deviation between the read image2and the reference image4is corrected by the affine transformation, a deviation obtained by detecting the collation position by moving the reference image block400with respect to the read image block200corresponding to each reference image block400is a non-linear deviation between the read image2and the reference image4.

One aspect of the image inspection apparatus10has been described based on the exemplary embodiment of the present invention. On the other hand, the disclosed form of the image inspection apparatus10is an example, and the form of the image inspection apparatus10is not limited to the scope described in the exemplary embodiment. Various modifications and improvements may be added to the exemplary embodiment without departing from the spirit of the present disclosure, and an exemplary embodiment obtained by adding the modifications and improvements falls within a technical scope of the present disclosure. For example, the order of the inspection processing illustrated inFIG. 7may be changed without departing from the spirit of the present disclosure.

Further, in the exemplary embodiment, a form in which the inspection processing is realized by software has been described as an example. On the other hand, the same processing as the flowchart illustrated inFIG. 7may be performed by hardware. In this case, the processing speed may be increased as compared with a case where the inspection processing is realized by software.

In the above exemplary embodiment, an example in which the image inspection program is stored in the ROM22of the image inspection apparatus10has been described. On the other hand, a storage destination of the image inspection program is not limited to the ROM22. The image inspection program according to the present disclosure may also be provided by being recorded on a storage medium which can be read by the computer20. For example, the image inspection program may be provided by being recorded on an optical disk such as a compact disk read only memory (CD-ROM) and a digital versatile disk read only memory (DVD-ROM). Further, the image inspection program may be provided by being recorded in a portable semiconductor memory such as a USB (Universal Serial Bus) memory and a memory card. The ROM22, the non-volatile memory24, the CD-ROM, the DVD-ROM, the USB, and the memory card are examples of a non-transitory storage medium.

Further, the image inspection apparatus10may download the image inspection program from an external apparatus via the communication unit27, and store the downloaded image inspection program in, for example, the non-volatile memory24. In this case, the CPU21of the image inspection apparatus10reads the image inspection program downloaded from the external apparatus, and executes the inspection processing.