Identification method of two-dimensional information of liquid drop
Technical Field
The invention relates to the technical field of image recognition, in particular to a method for recognizing two-dimensional information of liquid drops by adopting an image recognition mode to recognize the two-dimensional information of the liquid drops, and further realizing the reading of anti-counterfeiting data on an anti-counterfeiting label.
Background
Chinese patent CN104966463B discloses an anti-counterfeit label, which uses a unique anti-counterfeit ink composition to form an anti-counterfeit pattern in an ink bag array on a bottom plate with a thickness of 0.2-2.0mm, in order to ensure the anti-counterfeit pattern to be effective, the anti-counterfeit ink needs to be filled into the ink bags in the ink bag array, the depth of the ink bags is in a microporous shape of 0.0019-1.99mm, and the anti-counterfeit ink is in a flowing shape. The product formed based on the prior patent finally sets at least four groups of ink bag lattices at equal intervals in a 7x18mm area, 24 ink bags which are arranged at equal intervals are arranged in each group of ink bag lattices, the distance between adjacent ink bags is smaller than 0.5mm, and in the practical application process, the anti-counterfeiting pattern carried by the anti-counterfeiting label is ensured to be rapidly and accurately identified in the color development period, so that the key for realizing the anti-counterfeiting effect is realized.
However, after the ink bag in the anti-counterfeit label is filled with liquid, the liquid drops have the problems of light reflection and the like, so that the difficulty is brought to the identification of information.
Disclosure of Invention
Aiming at the difficulties existing in the prior art, the invention provides a method for identifying the two-dimensional information of liquid drops, which can quickly and accurately identify the anti-counterfeiting pattern consisting of the liquid drops in the color development period of the anti-counterfeiting ink.
The invention is achieved by the following measures:
the method for identifying the two-dimensional information of the liquid drop is characterized by comprising the following steps of:
Step 1, defining a calculation Template for subsequent recognition according to original design size data of a small hole matrix, and defining position representation data 1 of liquid drops, wherein the position representation data is otherwise 0;
Step2, acquiring an image I 0 of the matrix of the bearing liquid drops through a camera,
Step 3-converting I 0 into a grayscale image I 1,
Step 4, acquiring a binarization threshold T by using a minimum cross entropy image segmentation algorithm,
Step 5, performing binarization processing on the I 1 by using a threshold T to obtain an image I 2;
Step 6, performing morphological dilation operation on the image I 2, eliminating noise to obtain an image I 3,
I3=Dilate(I2,kernel=5x5,iterations=2)
Due to the special physical form of the liquid drops, the reflection condition can occur, so that part of image positions containing the liquid drops are incomplete, black dot images are incomplete, the later recognition accuracy can be influenced, and the defects are complemented as much as possible by using morphological corrosion, so that an image I is obtained 4,
I4=Erode(I3,kernel=3x3,iterations=3);
Step 7, performing horizontal and vertical projection operation on the I 4 to obtain an ROI of a droplet image, obtaining four corner sets R 0 of the ROI, constructing a set R t of four corner points of a rectangle according to Template, calculating a perspective transformation matrix of R 0 to R t, and performing perspective transformation on the image I 4 according to the transformation matrix to obtain an image I 5;
Step 8, constructing a horizontal coordinate set P tx and a vertical coordinate set P ty of all matrix points according to Template, respectively calculating the scale factors F x and F y in the horizontal and vertical directions by combining the width and the height of I 5 and the width and the height of Template, calculating to obtain the matrix point coordinate set of all the liquid drop positions (including the small holes without liquid drops) of I 5, namely the horizontal coordinate set P ix=Ptx*Fx and the vertical coordinate set P iy=Pty*Fy, calculating to obtain the liquid drop Radius radius=Min (Template. Radius) F x,Template.Radius*Fy,
Combining P ix and P iy, the positions of the liquid drop points can be sequentially positioned, whether the liquid drop exists at the positions or not is determined by acquiring whether the pixel value of the coordinate positions is 255, if the pixel value is 255, the liquid drop exists, the code is 1, if the pixel value is 0, the liquid drop does not exist, and the code is 0, so that the decoding identification of the liquid drop information is realized.
In the actual verification process, the invention also comprises a step 9 of performing median filtering treatment on the I 1 which is not subjected to binarization treatment to obtain an image I 6, wherein the condition that small bubbles possibly occur when liquid drops drop into small holes is found, and the identification accuracy in a given test set can not reach 100% up to the above step,
I6=MedianBlur(I1,ksize=5)
Determining the coordinates of the central points of the matrixes of the liquid drops (including small holes without the liquid drops) for the I 6 by combining the P ix and the P iy obtained in the step 8, and summing up pixel values in a range according to Radius for the central point of each matrix to obtain a set S 0;
The sorting of S 0 results in S 1, and then the discrete difference Diff for each element is found. Finding out the index i of the element with the largest difference, wherein the pixel value of the range corresponding to the matrix point is larger than S1[ i ], the pixel value is free of liquid drops, the code is 0, otherwise, the code is 1, so that the decoding identification of the liquid drop information is realized, and the identification accuracy reaches 100% in a given test set after the processing of the step 9.
In the step 6, the morphological dilation operation is performed on the image I 2 to eliminate noise, when the image I 3 is obtained, the morphological dilation operation is performed for more than two times according to the image processing requirement, and when the image I 4 is obtained by complementing the defect as much as possible by using the morphological erosion, the morphological erosion treatment is performed for more than two times according to the image processing requirement.
The invention can effectively improve the identification efficiency and accuracy of the label information on the anti-counterfeiting label by processing the droplet information, and has the remarkable advantages of low calculation complexity, high working efficiency, high accuracy and the like.
Drawings
Fig. 1 is a schematic diagram of the present invention for forming a security pattern in a security tag product.
Fig. 2 is a binarized image of example 1.
FIG. 3 is an image of example 1 after 2 rounds of inflation.
FIG. 4 is an image of example 1 after 3 rounds of corrosion.
The anti-counterfeiting label comprises an anti-counterfeiting label base plate 1, an ink bag 2, a blank ink bag 3 and an ink bag 4 filled with liquid drops.
Detailed Description
The invention will be further described with reference to the drawings and examples.
Example 1:
The embodiment provides a method for identifying drop anti-counterfeiting information on an anti-counterfeiting label, which specifically comprises the following steps:
according to the original design size data of the aperture matrix, defining a calculation Template for subsequent identification, defining position representation data 1 of liquid drops, and otherwise, defining the position representation data as 0;
Acquiring an image I 0 carrying a liquid drop matrix by a camera (a mobile phone camera, a digital camera, an industrial camera and the like);
The image I 2 is obtained by using the threshold T and performing binarization processing on the I 1, wherein most noise pixels are filtered, but partial fine noise pixels (mostly because small holes without liquid drops are formed in part and heavier shadows are formed in imaging) need to be processed (as shown in figure 2);
performing morphological dilation operation on the image I 2 to eliminate noise and obtain an image I 3 as shown in FIG. 3;
I3=Dilate(I2,kernel=5x5,iterations=2)
Due to the special physical form of the liquid drop, reflection causes to occur, so that part of the image position containing the liquid drop is incomplete, the black dot image is incomplete, the later recognition precision is affected, and the incomplete is complemented by morphological corrosion, so that an image I 4 is obtained, as shown in fig. 4.
I4=Erode(I3,kernel=3x3,iterations=3)
Performing horizontal and vertical projection operation on the I 4 to obtain an ROI of the droplet image and obtaining four corner sets R 0 of the ROI;
Constructing a set R t of four corner points of the rectangle according to the Template;
Calculating perspective transformation matrixes from R 0 to R t, and performing perspective transformation on the image I 4 according to the transformation matrixes to obtain an image I 5;
According to the Template, a horizontal coordinate set P tx and a vertical coordinate set P ty of all matrix points are constructed, the scale factors F x and F y in the horizontal and vertical directions are calculated respectively by combining the width and the width of I 5 and the width and the height of the Template, and the matrix point coordinate sets of all liquid drop positions (including small holes without liquid drops) of I 5 are calculated, namely a horizontal coordinate set P ix=Ptx*Fx and a vertical coordinate set P iy=Pty*Fy. And calculate the droplet Radius = Min (template. Radius F x,Template.Radius*Fy)
Combining P ix and P iy, the positions of the liquid drop points can be sequentially positioned, whether the liquid drop exists at the positions or not is determined by acquiring whether the pixel value of the coordinate positions is 255, if the pixel value is 255, the liquid drop exists, the code is 1, if the pixel value is 0, the liquid drop does not exist, and the code is 0, so that the decoding identification of the liquid drop information is realized.
In the actual verification process, the situation that small bubbles are generated possibly occurs when the liquid drops drop into the small holes is found, and the identification accuracy in the given test set cannot reach 100% by the steps, and for the situation, median filtering processing is performed on the I 1 which is not subjected to binarization processing, so that an image I 6 is obtained:
I6=MedianBlur(I1,ksize=5)
Determining the coordinates of the central points of the matrixes of the liquid drops (including small holes without liquid drops) for the I 6 by combining the obtained P ix and P iy, and summing up pixel values in the range according to Radius for the central point of each matrix to obtain a set S 0;
S 0 is sequenced to obtain S 1, then the discrete difference value Diff of each element is obtained, the index i of the element with the largest difference value is found, the pixel value of the range corresponding to the matrix point is larger than S1[ i ], no liquid drop exists, the code is 0, otherwise, the liquid drop exists, the code is 1, and therefore decoding identification of liquid drop information is achieved.
The identification method provided by the invention has the obvious advantages of high efficiency, high accuracy and the like in a given test set, the identification accuracy reaches 100%, and the identification method is suitable for industrial production and application.