A kind of product method of calibration based on picture comparison
Technical field
The present invention relates to a kind of product methods of calibration based on picture comparison, belong to image processing technology.
Background technique
With economic development, personalized trend is gradually presented in the material requisite of the people, be also proposed to plant produced and is newly wanted
It asks.Past, plant produced are mass produced in a producing line, and are the same products of production.But from now on,
The production requirement of small-scale multi items will be presented.It is labeled on product, the quality certification and nameplate etc., although not being product ontology,
But be also a part as product, need accurate information.For on product ontology and nameplate/label/quality certification etc.
The inconsistent situation of information, will be named as defect ware, so whether nameplate/label/quality certification is correctly also vital.
Currently, preparing according to 2 steps of sample and batch inside factory nameplate/label/quality certification production.Sample is done
After good, will generally there are more people to carry out confirmation signature, to ensure correctness.Then when bulk print, by first of bulk print
It is compared with sample, is still that more people confirm signature.This process causes worker's stress big, and personnel cost is high.In order to
First efficiency compared with sample of raising bulk print, improves the psychosomatic health of worker, proposes and pass through figure
As technology realizes a kind of solution accurately compared.
Summary of the invention
The purpose of the invention is to provide a kind of product method of calibration based on picture comparison.
The technical solution adopted by the present invention is that: it is a kind of based on picture comparison product method of calibration include the following steps:
Step 1: first sample of sample form and bulk print is scanned, template picture and sample are respectively obtained
This picture, and binary conversion treatment is carried out respectively to the template picture and the samples pictures;
Step 2: the samples pictures and the template picture are subjected to template-matching operation, setting matching precision is not small
In 50-90%, if successful match, the matching coincidence point of the samples pictures Yu the template picture is obtained;If matching
It is unsuccessful, then it can not obtain matching coincidence point, suspension processing;
Step 3: on the basis of matching coincidence point, by the comparison datum mark of samples pictures according to vertical X-direction and the side Y
Multiple dimensioned translation is carried out by setting translation scale to for coordinate system, translates samples pictures set, the translation sample graph to obtain
Piece collection is combined into { translation samples pictures 1, translate samples pictures 2, translate samples pictures 3 ..., translate samples pictures N };
Step 4: each translation samples pictures in the template picture and the translation samples pictures set are common
Multiple small pictures are divided into according to identical division position, to obtain template segmentation picture set and N number of translation sample point respectively
Picture set is cut, the template segmentation picture set is that { template divides picture 1, and template divides picture 2, and template divides picture
3 ..., template divides picture N };
Step 5: by template obtained in step 4 segmentation picture set and each described translation sample decomposition pictures
The segmentation picture of same position in conjunction carries out xor operation respectively, the pixel that selected pixels value is 1 from xor operation result
The picture of minimum number is as exclusive or result picture.
Preferably, further include following steps after step 5:
Step 6: the segmentation figure in exclusive or result picture and N number of translation sample decomposition picture set that step 5 is obtained
Piece is carried out or is operated according to same position;
Step 7: by or the obtained result picture of operation carry out being spliced to form the first new picture according to division position, and will
The exclusive or result picture that xor operation obtains carries out being spliced to form the second new picture according to division position, is subtracted with the second new picture
The new picture of third is obtained after first new picture;
Step 8: the location information that pixel value in the new picture of third is 1 is fed back to the template picture after binaryzation, that is, is obtained
Obtain the different content of template picture and samples pictures.
Preferably, in step 7, morphological dilations processing is carried out to the first new picture, and is subtracted with the second new picture swollen
The new picture of third is obtained after swollen treated the first new picture.
Preferably, the coefficient of expansion and the size of connected domain in picture are positively correlated, and the coefficient of expansion is according to the size of connected domain
Carry out ladder value.
Preferably, in step 2, the central area ROI and template picture for choosing samples pictures carry out template matching behaviour
Make, and the area of central area ROI is no less than the 1/4 of samples pictures.
The beneficial effects of the present invention are:
The present invention provides a kind of product methods of calibration based on picture comparison to pass through to template picture and samples pictures point
Not carry out after binary conversion treatment, be split, xor operation and/or operation, thus not only can efficiently accurately to the two into
Row matching operation, but also different location can be accurately exported, it improves to specific efficiency and comparison accuracy.
Specific embodiment
To be easy to understand the technical means, the creative features, the aims and the efficiencies achieved by the present invention, below with reference to
Specific embodiment, the present invention is further explained.
The present invention provides a kind of product method of calibration based on picture comparison, the product verification based on picture comparison
Method is for carrying out matching comparison to first samples pictures of template picture and bulk print, so that it is determined that inscription inside factory
The planographics indicating labels such as board/label/quality certification are not in mistake, thus reduction in the numbers of seconds.
Specifically, a kind of product method of calibration based on picture comparison comprising following steps:
Step 1: first sample of sample form and bulk print is scanned, template picture and sample are respectively obtained
This picture, and binary conversion treatment is carried out respectively to the template picture and the samples pictures;
Step 2: the samples pictures and the template picture are subjected to template-matching operation, setting matching precision is not small
In 50-90%, if successful match, the matching coincidence point of the samples pictures Yu the template picture is obtained;If matching
It is unsuccessful, then it can not obtain matching coincidence point, suspension processing;
Step 3: on the basis of matching coincidence point, by the comparison datum mark of samples pictures according to vertical X-direction and the side Y
Multiple dimensioned translation is carried out by setting translation scale to for coordinate system, translates samples pictures set, the translation sample graph to obtain
Piece collection is combined into { translation samples pictures 1, translate samples pictures 2, translate samples pictures 3 ..., translate samples pictures N };
Step 4: each translation samples pictures in the template picture and the translation samples pictures set are common
Multiple small pictures are divided into according to identical division position, to obtain template segmentation picture set and N number of translation sample point respectively
Picture set is cut, the template segmentation picture set is that { template divides picture 1, and template divides picture 2, and template divides picture
3 ..., template divides picture N }, translation samples pictures 1 are { to translate samples pictures 1 to divide in the translation sample decomposition picture set
1 is cut, translation samples pictures 1 segmentation 2, translation samples pictures 1 segmentation 3 ..., translation samples pictures 1 divide N }, and so on;
Step 5: by template obtained in step 4 segmentation picture set and each described translation sample decomposition pictures
The segmentation picture of same position in conjunction carries out xor operation respectively, the pixel that selected pixels value is 1 from xor operation result
The picture of minimum number is as exclusive or result picture, such as such as: template divides picture 1 and translation samples pictures 1 segmentation 1 carries out
Xor operation, template divides picture 1 and translation samples pictures 2 segmentation 1 carries out xor operation ..., and template divides picture 1 and translation
Samples pictures N segmentation 1 carries out xor operation, and so on;
Step 6: the segmentation figure in exclusive or result picture and N number of translation sample decomposition picture set that step 5 is obtained
Piece is carried out or is operated according to same position, to guarantee the integrality of comparing result;
Step 7: by or the obtained result picture of operation carry out being spliced to form the first new picture according to division position, and will
The exclusive or result picture that xor operation obtains carries out being spliced to form the second new picture according to division position, is subtracted with the second new picture
The new picture of third is obtained after first new picture;
Step 8: the location information that pixel value in the new picture of third is 1 is fed back to the template picture after binaryzation, that is, is obtained
Obtain the different content of template picture and samples pictures.
It should be noted that the central area ROI and template picture for choosing samples pictures carry out template in step 2
Area with operation, and central area ROI is no less than the 1/4 of samples pictures;It is further preferred that matching precision is not less than 90%,
To improve the accuracy of matching coincidence point selection.
In addition, in step 7, being carried out at morphological dilations to the first new picture to remove the noise problem in picture
Reason, and the new picture of third is obtained after the first new picture after subtracting expansion process with the second new picture.Moreover, the coefficient of expansion and figure
The size of connected domain is positively correlated in piece, and the coefficient of expansion carries out ladder value according to the size of connected domain.
The above description is only an embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair
Equivalent structure or equivalent flow shift made by bright specification is applied directly or indirectly in other relevant technical fields,
Similarly it is included within the scope of the present invention.