CN110348264A - A kind of QR image in 2 D code bearing calibration and system - Google Patents

A kind of QR image in 2 D code bearing calibration and system Download PDF

Info

Publication number
CN110348264A
CN110348264A CN201910601467.4A CN201910601467A CN110348264A CN 110348264 A CN110348264 A CN 110348264A CN 201910601467 A CN201910601467 A CN 201910601467A CN 110348264 A CN110348264 A CN 110348264A
Authority
CN
China
Prior art keywords
image
dimensional code
gray
code image
pixel point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910601467.4A
Other languages
Chinese (zh)
Other versions
CN110348264B (en
Inventor
王俊卿
高丽欣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Institute of Electronic System Engineering
Original Assignee
Beijing Institute of Electronic System Engineering
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Institute of Electronic System Engineering filed Critical Beijing Institute of Electronic System Engineering
Priority to CN201910601467.4A priority Critical patent/CN110348264B/en
Publication of CN110348264A publication Critical patent/CN110348264A/en
Application granted granted Critical
Publication of CN110348264B publication Critical patent/CN110348264B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1443Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/146Methods for optical code recognition the method including quality enhancement steps
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/60Rotation of whole images or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Toxicology (AREA)
  • Electromagnetism (AREA)
  • Health & Medical Sciences (AREA)
  • Quality & Reliability (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses a kind of QR image in 2 D code bearing calibration and systems, which comprises is pre-processed to obtain gray level image to the QR image in 2 D code;Binary conversion treatment is carried out to the gray level image and obtains binary image;Transformation parameter matrix is obtained by the positioning image in QR image in 2 D code;Image in 2 D code after the binary image is corrected by the transformation parameter matrix conversion can carry out correction rapidly and efficiently to QR image in 2 D code, improve the accuracy for the information extracted from image in 2 D code.

Description

QR two-dimensional code image correction method and system
Technical Field
The invention relates to the technical field of two-dimensional code image correction. And more particularly, to a QR two-dimensional code image correction method and system.
Background
A two-dimensional barcode (two-dimensional code) is a type of barcode that stores information in two-dimensional spaces in both the horizontal direction and the vertical direction. Compared with the one-dimensional bar code, the two-dimensional bar code has the advantages of high information density, large information capacity, variable shape of bar code symbols, wide coding range, strong error correction capability, high safety strength and the like, so that the two-dimensional bar code is widely applied to numerous fields of logistics management, safety anti-counterfeiting, identity authentication, electronic commerce and the like. Therefore, the research of the two-dimensional bar code technology still has very important significance today in the rapid development of science and technology.
The existing two-dimensional code identification is basically completed under the conditions of relatively single background, ideal illumination condition, small geometric deformation of the obtained image and the like, so the identification accuracy is high. With the wide application of the QR two-dimensional bar code in our daily life, the two-dimensional code picture collected by the practical camera equipment such as the user mobile phone is greatly affected by the equipment itself, the external illumination, the shooting environment, the shooting angle, the background of the two-dimensional code, etc., the shot picture may have large geometric deformation, many noise points, a non-single background, and poor image uniformity, which results in overlong image processing time, exceeding the specified interpretation time of the system, and even difficult to accurately interpret the information of the two-dimensional code, so it is necessary to perform fast and efficient binarization, positioning image recognition and geometric shape correction on the QR two-dimensional code image, and support the accurate extraction of the two-dimensional code information.
Disclosure of Invention
An object of the present invention is to provide a QR two-dimensional code image correction method, which can quickly and efficiently correct a QR two-dimensional code image, and improve the accuracy of information extracted from a two-dimensional code image. Another object of the present invention is to provide a QR two-dimensional code image correction system.
In order to achieve the purpose, the invention adopts the following technical scheme:
the invention discloses a QR two-dimensional code image correction method, which comprises the following steps:
preprocessing the QR two-dimensional code image to obtain a gray image;
carrying out binarization processing on the gray level image to obtain a binarized image;
obtaining a transformation parameter matrix through a positioning image in the QR two-dimensional code image;
and converting the binary image through the transformation parameter matrix to obtain a corrected two-dimensional code image.
Preferably, the preprocessing the QR two-dimensional code image to obtain a gray image includes:
decolorizing the color QR two-dimensional code image;
denoising and filtering the two-dimensional code image after the color is removed;
performing image enhancement on the two-dimensional code image subjected to denoising and filtering;
and normalizing the two-dimensional code image after image enhancement to obtain the gray level image.
Preferably, the binarizing processing on the grayscale image specifically includes:
obtaining a self-adaptive gray threshold value through a histogram algorithm;
and comparing the gray value of each pixel point of the gray image with the gray threshold value to obtain a binary image corresponding to the gray image.
Preferably, the comparing the gray value of each pixel point of the gray image with the gray threshold to obtain the binary image corresponding to the gray image specifically includes:
comparing the gray value of each pixel point of the gray image with the gray threshold value;
if the gray value of the pixel point is greater than or equal to the gray threshold, taking 1 as the binarization value corresponding to the pixel point, and if the gray value of the pixel point is less than the gray threshold, taking 0 as the binarization value corresponding to the pixel point;
and forming the binary image according to the binary value of each pixel point of the gray level image.
Preferably, the obtaining of the transformation parameter matrix through the positioning image in the QR two-dimensional code image specifically includes:
determining the same positioning images of three corners of the QR two-dimensional code image;
and obtaining the transformation parameter matrix according to the positioning image of the QR two-dimensional code image and the positioning image of the standard two-dimensional code image.
The invention also discloses a QR two-dimensional code image correction system, which comprises:
the preprocessing module is used for preprocessing the QR two-dimensional code image to obtain a gray level image;
the binarization processing module is used for carrying out binarization processing on the gray level image to obtain a binarization image;
the parameter matrix determining module is used for obtaining a transformation parameter matrix through a positioning image in the QR two-dimensional code image;
and the image correction module is used for converting the binary image through the transformation parameter matrix to obtain a corrected two-dimensional code image.
Preferably, the preprocessing the QR two-dimensional code image to obtain a gray image includes:
decolorizing the color QR two-dimensional code image;
denoising and filtering the two-dimensional code image after the color is removed;
performing image enhancement on the two-dimensional code image subjected to denoising and filtering;
and normalizing the two-dimensional code image after image enhancement to obtain the gray level image.
Preferably, the binarizing processing on the grayscale image specifically includes:
obtaining a self-adaptive gray threshold value through a histogram algorithm;
and comparing the gray value of each pixel point of the gray image with the gray threshold value to obtain a binary image corresponding to the gray image.
Preferably, the comparing the gray value of each pixel point of the gray image with the gray threshold to obtain the binary image corresponding to the gray image specifically includes:
comparing the gray value of each pixel point of the gray image with the gray threshold value;
if the gray value of the pixel point is greater than or equal to the gray threshold, taking 1 as the binarization value corresponding to the pixel point, and if the gray value of the pixel point is less than the gray threshold, taking 0 as the binarization value corresponding to the pixel point;
and forming the binary image according to the binary value of each pixel point of the gray level image.
Preferably, the obtaining of the transformation parameter matrix through the positioning image in the QR two-dimensional code image specifically includes:
determining the same positioning images of three corners of the QR two-dimensional code image;
and obtaining the transformation parameter matrix according to the positioning image of the QR two-dimensional code image and the positioning image of the standard two-dimensional code image.
According to the method, the image is preprocessed and binarized, the transformation parameter matrix is obtained based on the positioning image in the two-dimensional code image, the binarized image obtained through the binarization processing is further subjected to image transformation according to the transformation parameter matrix, the distorted QR two-dimensional code image is corrected into the standard QR two-dimensional code image, and the corrected two-dimensional code image is obtained, so that the problem of quick correction of the geometric shape of the QR two-dimensional code image under the conditions of complex background, uneven illumination and geometric deformation is solved, basic conditions are provided for accurately extracting the two-dimensional code image information in real time, and the accuracy of extracting the two-dimensional code image information is improved.
Drawings
The following describes embodiments of the present invention in further detail with reference to the accompanying drawings.
FIG. 1 shows one of the flow charts of embodiments of a QR two-dimensional code image correction method according to the present invention;
FIG. 2 shows a second flowchart of an embodiment of a QR two-dimensional code image correction method according to the present invention;
FIG. 3 shows a third flowchart of an embodiment of a QR two-dimensional code image correction method according to the present invention;
FIG. 4 shows a fourth flowchart of an embodiment of a QR two-dimensional code image correction method according to the present invention;
FIG. 5 shows a fifth flowchart of an embodiment of a QR two-dimensional code image correction method according to the present invention;
FIG. 6 shows a schematic coordinate diagram of four corner points of a center point of a positioned image according to an embodiment of a QR two-dimensional code image correction method;
fig. 7 is a schematic diagram showing a QR two-dimensional code image photographed and a QR two-dimensional code image after correction in a specific example of a QR two-dimensional code image correction method according to the present invention;
fig. 8 is a schematic view showing a QR two-dimensional code image photographed and a QR two-dimensional code image after correction in another specific example of the QR two-dimensional code image correction method according to the present invention;
FIG. 9 is a block diagram illustrating an embodiment of a QR two-dimensional code image correction system according to the present invention;
FIG. 10 shows a schematic block diagram of a computer device suitable for use in implementing embodiments of the present invention.
Detailed Description
In order to more clearly illustrate the invention, the invention is further described below with reference to preferred embodiments and the accompanying drawings. Similar parts in the figures are denoted by the same reference numerals. It is to be understood by persons skilled in the art that the following detailed description is illustrative and not restrictive, and is not to be taken as limiting the scope of the invention.
According to one aspect of the invention, the embodiment discloses a QR two-dimensional code image correction method. As shown in fig. 1, in this embodiment, the method includes:
s100: and preprocessing the QR two-dimensional code image to obtain a gray image.
S200: and carrying out binarization processing on the gray level image to obtain a binarized image.
S300: and obtaining a transformation parameter matrix through a positioning image in the QR two-dimensional code image.
S400: and converting the binary image through the transformation parameter matrix to obtain a corrected two-dimensional code image.
According to the method, the image is preprocessed and binarized, the transformation parameter matrix is obtained based on the positioning image in the two-dimensional code image, the binarized image obtained through the binarization processing is further subjected to image transformation according to the transformation parameter matrix, the distorted QR two-dimensional code image is corrected into the standard QR two-dimensional code image, and the corrected two-dimensional code image is obtained, so that the problem of quick correction of the geometric shape of the QR two-dimensional code image under the conditions of complex background, uneven illumination and geometric deformation is solved, basic conditions are provided for accurately extracting the two-dimensional code image information in real time, and the accuracy of extracting the two-dimensional code image information is improved.
In a preferred embodiment, as shown in fig. 2, the S100 may specifically include:
s110: and (4) decoloring the colored QR two-dimensional code image. Specifically, the color of the QR two-dimensional code image can be removed by performing graying processing on the color QR two-dimensional code image.
S120: and denoising and filtering the two-dimensional code image after the color removal. Preferably, the median filtering method can be used to smooth out the noise.
S130: and performing image enhancement on the two-dimensional code image subjected to denoising and filtering. Preferably, the two-dimensional code image after denoising and filtering can be subjected to contrast enhancement in a gamma transformation mode to realize image enhancement processing.
S140: and normalizing the two-dimensional code image after image enhancement to obtain the gray level image. Specifically, in one specific example, normalization can be achieved by the following equation:
the enhanced two-dimensional code image is I, the height is H, the width is W, I (u, v) represents the gray value of the pixel of the u-th row and the v-th column of I, ImaxAnd IminRespectively the maximum value and the minimum value in the gray value of all pixels in the image, then I (r, c) is belonged to [ Imin,Imax]O (u, v) is the gray value of the pixel in the u row and the v column of the normalized image, and O (u, v) is within the range of 0,1]。
In a preferred embodiment, as shown in fig. 3, the S200 may specifically include:
s210: and obtaining the self-adaptive gray threshold value through a histogram algorithm. The present embodiment provides an improved histogram technique for finding an adaptive gray scale threshold. Specifically, a histogram H (i) is obtained for the normalized grayscale image O (u, v), i ∈ [0,1 ]]Simultaneously obtaining the maximum and minimum gray value histogram H of H (i)maxAnd Hmin. Initial segmentation thresholdRespectively calculating the ratio of H toth(0) And is greater than Hth(0) The mean values of the two regions are respectively set as Hmin_mean,Hmax_meanThen order againIterate sequentially until Hth(i)<Hth(i-1) or i < n, where i represents the number of iterations and n represents the maximum number of iterations. According to the threshold value H obtained after iterationth(i) And performing binarization on O (r, c). The histogram-based adaptive threshold extraction method of the embodiment mainly includes iteratively solving a gray average value of an image region after a histogram threshold is divided into two parts, comparing the gray average values of the two parts of the divided regions, and determining a corresponding threshold as a final divided threshold of a two-dimensional image when the gray average values are converged, so as to improve the accuracy of information extraction in subsequent decoding.
S220: and comparing the gray value of each pixel point of the gray image with the gray threshold value to obtain a binary image corresponding to the gray image.
In a preferred embodiment, as shown in fig. 4, the S220 may specifically include:
s221: and comparing the gray value of each pixel point of the gray image with the gray threshold value.
S222: if the gray value of the pixel point is greater than or equal to the gray threshold, the binarization value corresponding to the pixel point is 1, and if the gray value of the pixel point is less than the gray threshold, the binarization value corresponding to the pixel point is 0.
S223: and forming the binary image according to the binary value of each pixel point of the gray level image. By determining the binarization value of each pixel point, a two-dimensional matrix array consisting of 0 and 1 can be obtained, and the two-dimensional matrix array corresponds to each pixel point of the binarization image one by one. Because the two-dimensional code decoding is calculated according to the two-dimensional matrix array obtained after binarization, the quality of binarization directly influences whether the subsequent decoding is successful or not, and a histogram-based adaptive threshold algorithm is adopted to realize the binarization of the image to obtain a binarized image
In a preferred embodiment, as shown in fig. 5, the S300 may specifically include:
s310: and determining the same positioning images of three corners of the QR two-dimensional code image.
The QR two-dimensional code image comprises three same images at different positions, namely positioning images at the three positions of the upper left corner, the upper right corner and the lower left corner of the two-dimensional code image, and the positioning image at each position can be regarded as being composed of three overlapped concentric squares, wherein the three squares are respectively 7 multiplied by 7 black modules, 5 multiplied by 5 white modules and 3 multiplied by 3 black modules. Finally, the module sequence of each position positioning image formed by overlapping three squares consists of a black-white-black sequence, the width ratio of each module with the same color is 1:1:3:1:1, and the position positioning image can be determined according to the pixel characteristics of the positioning image
S320: and obtaining the transformation parameter matrix according to the positioning image of the QR two-dimensional code image and the positioning image of the standard two-dimensional code image.
The positions of the positioning images of the three corners in the QR two-dimensional code image can be determined through the pixel characteristics of the positioning images, the position and the direction of the QR two-dimensional code image in the view field can be determined according to the pixel range of the positioning images in the QR two-dimensional code image, and then the transformation parameter matrix can be obtained.
Specifically, a transformation parameter matrix may be obtained according to the equation AX ═ b, where A, b is a matrix parameter and X is a transformation parameter matrix. A represents an equation parameter formed by a parameter matrix formed by the center point and four corner point coordinates of each positioning image in a standard QR two-dimensional code image which needs to be obtained after correction, and b represents an equation parameter formed by a parameter matrix formed by the center point and four corner point coordinates of each positioning image in a QR two-dimensional code image which is actually shot by a camera.
In a specific example, the positioning image is detected in the binarized image according to the ratio of the widths of the black and white modules of 1:1:3:1: 1. The method for determining the positioning image based on the four-line scanning method is proposed, and the four scanning lines are respectively a horizontal scanning line, a vertical scanning line and two diagonal scanning lines. When the horizontal scanning lines and the vertical scanning lines preliminarily detect the positioning images, two diagonal scanning lines are used for scanning respectively, only four scanning lines simultaneously meet the color block proportion, the image can be determined as the positioning image, meanwhile, the central point of the image is preliminarily positioned according to the intersection points of the diagonal scanning lines, and the central coordinates of the positioning image are respectively (x (1), y (1)), (x (2), y (2)), (x (3) and y (3)) according to the pixel coordinate mean value of the area image. The rotation angle theta of the QR two-dimensional code image is determined according to the central points of the three positioning images, four corner points of each positioning image can be obtained according to the rotation angle, twelve corner points are obtained, and the corresponding sequence of the fifteen points is shown in FIG. 6. Wherein the rotation angle θ can be determined by the following formula:
wherein,
in a preferred embodiment, in S400, after the transformation parameter matrix X is acquired, a transformation is performed according to each pixel in the actually acquired QR two-dimensional code image to obtain a standard QR two-dimensional code image, that is, the image geometric correction is completed.
In a specific example, firstly, the version number of a standard QR two-dimensional code image is obtained according to the distance between the center points of a positioning image, the number of modules and the size of the modules of a coding image can be calculated according to the version number, so that the center point and four corner point coordinates of the standard QR two-dimensional code positioning image of the version are determined, 15 point coordinates (u (i), v (i)) are obtained, i is 1 and 2. Eight parameters of the perspective transformation X can be obtained from AX ═ b, and are denoted by a, b, c, d, e, f, and g. And (c) calculating the mapping relation between the pixel point coordinates on the standard QR two-dimensional code image and the pixel point coordinates of the actually shot QR code image, wherein (u, v) is the pixel point coordinates of the standard QR two-dimensional code image, and (x, y) is the pixel point coordinates of the actually shot QR two-dimensional code image. Then (x, y) can be determined by the following equation:
finishing image correction according to the gray pixel value (x, y) of the corresponding position obtained by calculation, and setting the corrected image as Iresult(u,v)∈[0,1]And (4) taking the average of the four neighborhood 5 points as the corrected pixel gray value, and then carrying out binarization on the gray image to obtain a corrected QR two-dimensional code image.
Fig. 7 and 8 respectively show schematic diagrams of QR two-dimensional code correction in two specific examples, and it can be seen from the diagrams that the present invention solves the problem of rapid geometric correction of QR two-dimensional code images under conditions of complex background, uneven illumination and geometric deformation by preprocessing the images, binarizing based on histogram adaptive pre-values, automatically identifying the positioning images based on scanning lines, and adopting the perspective transformation technique based on multi-feature points, and provides a basic condition for accurately extracting two-dimensional code image information in real time, thereby improving the accuracy of extracting two-dimensional code image information.
Compared with the traditional OSTU threshold extraction algorithm, the histogram-based adaptive threshold extraction method provided by the invention has the advantages that the calculation complexity is lower by one order of magnitude, and the image segmentation effect is equivalent to the OSTU segmentation effect. Compared with other linear detection algorithms based on edge detection and Hough transformation, the scanning line positioning image identification method based on the horizontal direction, the vertical direction and the diagonal direction is higher in accuracy, and the calculation complexity is at least lower than 2 orders of magnitude. The perspective transformation correction technology based on the multiple characteristic points fully utilizes the central characteristic points of the positioning images and the four corner points of each positioning image, has better geometric correction performance, and does not increase extra calculation expense.
Based on the same principle, the embodiment also discloses a QR two-dimensional code image correction system. As shown in fig. 9, in the present embodiment, the system includes a preprocessing module 11, a binarization processing module 12, a parameter matrix determination module 13, and an image correction module 14.
In a preferred embodiment, the preprocessing module 11 is specifically configured to decolor a color QR two-dimensional code image, perform denoising and filtering on the decolored two-dimensional code image, perform image enhancement on the denoised and filtered two-dimensional code image, and perform normalization processing on the image-enhanced two-dimensional code image to obtain the grayscale image.
Specifically, the color of the QR two-dimensional code image can be removed by performing graying processing on the color QR two-dimensional code image. The median filtering method can be used to smooth out the noise. And performing contrast enhancement on the denoised and filtered two-dimensional code image by adopting a gamma transformation mode to realize image enhancement processing.
Specifically, in one specific example, normalization can be achieved by the following equation:
the enhanced two-dimensional code image is I, the height is H, the width is W, I (u, v) represents the gray value of the pixel of the u-th row and the v-th column of I, ImaxAnd IminRespectively the maximum value and the minimum value in the gray value of all pixels in the image, then I (r, c) is belonged to [ Imin,Imax]O (u, v) is the gray value of the pixel in the u row and the v column of the normalized image, and O (u, v) is within the range of 0,1]。
In a preferred embodiment, the binarization processing module 12 is specifically configured to obtain an adaptive gray level threshold through a histogram algorithm, and compare a gray level of each pixel point of the gray level image with the gray level threshold to obtain a binarized image corresponding to the gray level image.
The present embodiment provides an improved histogram technique for finding an adaptive gray scale threshold. In particular, toThe normalized gray image O (u, v) finds the histogram H (i), i ∈ [0,1 ]]Simultaneously obtaining the maximum and minimum gray value histogram H of H (i)maxAnd Hmin. Initial segmentation thresholdRespectively calculating the ratio of H toth(0) And is greater than Hth(0) The mean values of the two regions are respectively set as Hmin_mean,Hmax_meanThen order againIterate sequentially until Hth(i)<Hth(i-1) or i < n, where i represents the number of iterations and n represents the maximum number of iterations. According to the threshold value H obtained after iterationth(i) And performing binarization on O (r, c). The histogram-based adaptive threshold extraction method of the embodiment mainly includes iteratively solving a gray average value of an image region after a histogram threshold is divided into two parts, comparing the gray average values of the two parts of the divided regions, and determining a corresponding threshold as a final divided threshold of a two-dimensional image when the gray average values are converged, so as to improve the accuracy of information extraction in subsequent decoding.
In a preferred embodiment, the binarization processing module 12 is further configured to compare the gray level value of each pixel point of the gray level image with the gray level threshold. If the gray value of the pixel point is greater than or equal to the gray threshold, the binarization value corresponding to the pixel point is 1, and if the gray value of the pixel point is less than the gray threshold, the binarization value corresponding to the pixel point is 0. And forming the binary image according to the binary value of each pixel point of the gray level image. By determining the binarization value of each pixel point, a two-dimensional matrix array consisting of 0 and 1 can be obtained, and the two-dimensional matrix array corresponds to each pixel point of the binarization image one by one. Because the two-dimensional code decoding is calculated according to the two-dimensional matrix array obtained after binarization, the quality of binarization directly influences whether the subsequent decoding is successful or not, and a histogram-based adaptive threshold algorithm is adopted to realize the binarization of the image to obtain a binarized image
In a preferred embodiment, the parameter matrix determining module 13 is specifically configured to determine the same positioning images of three corners of the QR two-dimensional code image, and obtain the transformation parameter matrix according to the positioning image of the QR two-dimensional code image and the positioning image of the standard two-dimensional code image.
The QR two-dimensional code image comprises three same images at different positions, namely positioning images at the three positions of the upper left corner, the upper right corner and the lower left corner of the two-dimensional code image, and the positioning image at each position can be regarded as being composed of three overlapped concentric squares, wherein the three squares are respectively 7 multiplied by 7 black modules, 5 multiplied by 5 white modules and 3 multiplied by 3 black modules. Finally, the module sequence of each position positioning image formed by overlapping three squares consists of a black-white-black sequence, the width ratio of each module with the same color is 1:1:3:1:1, and the position positioning image can be determined according to the pixel characteristics of the positioning image
The positions of the positioning images of the three corners in the QR two-dimensional code image can be determined through the pixel characteristics of the positioning images, the position and the direction of the QR two-dimensional code image in the view field can be determined according to the pixel range of the positioning images in the QR two-dimensional code image, and then the transformation parameter matrix can be obtained.
Specifically, a transformation parameter matrix may be obtained according to the equation AX ═ b, where A, b is a matrix parameter and X is a transformation parameter matrix. A represents an equation parameter formed by a parameter matrix formed by the center point and four corner point coordinates of each positioning image in a standard QR two-dimensional code image which needs to be obtained after correction, and b represents an equation parameter formed by a parameter matrix formed by the center point and four corner point coordinates of each positioning image in a QR two-dimensional code image which is actually shot by a camera.
In a specific example, the positioning image is detected in the binarized image according to the ratio of the widths of the black and white modules of 1:1:3:1: 1. The method for determining the positioning image based on the four-line scanning method is proposed, and the four scanning lines are respectively a horizontal scanning line, a vertical scanning line and two diagonal scanning lines. When the horizontal scanning lines and the vertical scanning lines preliminarily detect the positioning images, two diagonal scanning lines are used for scanning respectively, only four scanning lines simultaneously meet the color block proportion, the image can be determined as the positioning image, meanwhile, the central point of the image is preliminarily positioned according to the intersection points of the diagonal scanning lines, and the central coordinates of the positioning image are respectively (x (1), y (1)), (x (2), y (2)), (x (3) and y (3)) according to the pixel coordinate mean value of the area image. The rotation angle theta of the QR two-dimensional code image is determined according to the central points of the three positioning images, four corner points of each positioning image can be obtained according to the rotation angle, twelve corner points are obtained, and the corresponding sequence of the fifteen points is shown in FIG. 6. Wherein the rotation angle θ can be determined by the following formula:
wherein,
in a preferred embodiment, after the image correction module 14 acquires the transformation parameter matrix X, it transforms each pixel in the actually acquired QR two-dimensional code image to obtain a standard QR two-dimensional code image, that is, completes the image geometric correction.
In a specific example, firstly, the version number of a standard QR two-dimensional code image is obtained according to the distance between the center points of a positioning image, the number of modules and the size of the modules of a coding image can be calculated according to the version number, so that the center point and four corner point coordinates of the standard QR two-dimensional code positioning image of the version are determined, 15 point coordinates (u (i), v (i)) are obtained, i is 1 and 2. Eight parameters of the perspective transformation X can be obtained from AX ═ b, and are denoted by a, b, c, d, e, f, and g. And (c) calculating the mapping relation between the pixel point coordinates on the standard QR two-dimensional code image and the pixel point coordinates of the actually shot QR code image, wherein (u, v) is the pixel point coordinates of the standard QR two-dimensional code image, and (x, y) is the pixel point coordinates of the actually shot QR two-dimensional code image. Then (x, y) can be determined by the following equation:
finishing image correction according to the gray pixel value (x, y) of the corresponding position obtained by calculation, and setting the corrected image as Iresult(u,v)∈[0,1]And taking the average of the four neighborhood 5 points as the corrected pixel gray value, and then carrying out binarization on the gray image to obtain a corrected QR two-dimensional code image.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer device, which may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
In a typical example, the computer device specifically comprises a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method performed by the client as described above when executing the program, or the processor implementing the method performed by the server as described above when executing the program.
Referring now to FIG. 10, shown is a schematic diagram of a computer device 600 suitable for use in implementing embodiments of the present application.
As shown in fig. 10, the computer apparatus 600 includes a Central Processing Unit (CPU)601 which can perform various appropriate works and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM)) 603. In the RAM603, various programs and data necessary for the operation of the system 600 are also stored. The CPU601, ROM602, and RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output section 607 including a Cathode Ray Tube (CRT), a liquid crystal feedback (LCD), and the like, and a speaker and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 606 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted as necessary on the storage section 608.
In particular, according to an embodiment of the present invention, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the invention include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A QR two-dimensional code image correction method is characterized by comprising the following steps:
preprocessing the QR two-dimensional code image to obtain a gray image;
carrying out binarization processing on the gray level image to obtain a binarized image;
obtaining a transformation parameter matrix through a positioning image in the QR two-dimensional code image;
and converting the binary image through the transformation parameter matrix to obtain a corrected two-dimensional code image.
2. The method for correcting the QR two-dimensional code image according to claim 1, wherein the preprocessing the QR two-dimensional code image to obtain a gray scale image comprises:
decolorizing the color QR two-dimensional code image;
denoising and filtering the two-dimensional code image after the color is removed;
performing image enhancement on the two-dimensional code image subjected to denoising and filtering;
and normalizing the two-dimensional code image after image enhancement to obtain the gray level image.
3. The QR two-dimensional code image correction method according to claim 1, wherein the binarizing processing on the grayscale image specifically includes:
obtaining a self-adaptive gray threshold value through a histogram algorithm;
and comparing the gray value of each pixel point of the gray image with the gray threshold value to obtain a binary image corresponding to the gray image.
4. The QR two-dimensional code image correction method according to claim 3, wherein the comparing the gray value of each pixel point of the gray image with the gray threshold value to obtain the binarized image corresponding to the gray image specifically comprises:
comparing the gray value of each pixel point of the gray image with the gray threshold value;
if the gray value of the pixel point is greater than or equal to the gray threshold, taking 1 as the binarization value corresponding to the pixel point, and if the gray value of the pixel point is less than the gray threshold, taking 0 as the binarization value corresponding to the pixel point;
and forming the binary image according to the binary value of each pixel point of the gray level image.
5. The QR two-dimensional code image correction method according to claim 1, wherein obtaining the transformation parameter matrix from the positioning image in the QR two-dimensional code image specifically includes:
determining the same positioning images of three corners of the QR two-dimensional code image;
and obtaining the transformation parameter matrix according to the positioning image of the QR two-dimensional code image and the positioning image of the standard two-dimensional code image.
6. A QR two-dimensional code image correction system is characterized by comprising:
the preprocessing module is used for preprocessing the QR two-dimensional code image to obtain a gray level image;
the binarization processing module is used for carrying out binarization processing on the gray level image to obtain a binarization image;
the parameter matrix determining module is used for obtaining a transformation parameter matrix through a positioning image in the QR two-dimensional code image;
and the image correction module is used for converting the binary image through the transformation parameter matrix to obtain a corrected two-dimensional code image.
7. The QR two-dimensional code image correction system of claim 6, wherein the preprocessing module is specifically configured to decolor a color QR two-dimensional code image, perform denoising and filtering on the decolored two-dimensional code image, perform image enhancement on the denoised and filtered two-dimensional code image, and perform normalization processing on the image-enhanced two-dimensional code image to obtain the grayscale image.
8. The QR two-dimensional code image correction system of claim 6, wherein the binarization processing module is specifically configured to obtain an adaptive gray threshold through a histogram algorithm, and compare the gray value of each pixel of the gray image with the gray threshold to obtain the binarized image corresponding to the gray image.
9. The QR two-dimensional code image correction system according to claim 8, wherein the binarization processing module is further configured to compare the gray value of each pixel point of the gray image with the gray threshold, if the gray value of the pixel point is greater than or equal to the gray threshold, the binarization value corresponding to the pixel point is 1, if the gray value of the pixel point is less than the gray threshold, the binarization value corresponding to the pixel point is 0, and the binarization image is formed according to the binarization value of each pixel point of the gray image.
10. The QR two-dimensional code image correction system of claim 6, wherein the parameter matrix determination module is specifically configured to determine the same positioning images of three corners of the QR two-dimensional code image, and obtain the transformation parameter matrix according to the positioning images of the QR two-dimensional code image and the positioning images of the standard two-dimensional code image.
CN201910601467.4A 2019-07-04 2019-07-04 QR two-dimensional code image correction method and system Active CN110348264B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910601467.4A CN110348264B (en) 2019-07-04 2019-07-04 QR two-dimensional code image correction method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910601467.4A CN110348264B (en) 2019-07-04 2019-07-04 QR two-dimensional code image correction method and system

Publications (2)

Publication Number Publication Date
CN110348264A true CN110348264A (en) 2019-10-18
CN110348264B CN110348264B (en) 2023-12-26

Family

ID=68177568

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910601467.4A Active CN110348264B (en) 2019-07-04 2019-07-04 QR two-dimensional code image correction method and system

Country Status (1)

Country Link
CN (1) CN110348264B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111223065A (en) * 2020-01-13 2020-06-02 中国科学院重庆绿色智能技术研究院 Image correction method, irregular text recognition device, storage medium and equipment
CN111311497A (en) * 2020-02-12 2020-06-19 广东工业大学 Bar code image angle correction method and device
CN111339797A (en) * 2020-02-25 2020-06-26 福州符号信息科技有限公司 Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code
CN111343339A (en) * 2020-03-03 2020-06-26 青岛海信移动通信技术股份有限公司 Mobile terminal and image display method thereof
CN111598794A (en) * 2020-04-24 2020-08-28 山东易华录信息技术有限公司 Image imaging method and device for removing underwater overlapping condition
CN111798619A (en) * 2020-07-09 2020-10-20 常德市广汇气体有限公司 Inflation system for filling gas cylinder by scanning code
CN113095104A (en) * 2021-05-08 2021-07-09 山东新一代信息产业技术研究院有限公司 Defective two-dimensional code positioning method
CN114330400A (en) * 2020-10-12 2022-04-12 珠海格力电器股份有限公司 Two-dimensional code image processing method, system, device, electronic equipment and storage medium
CN114582301A (en) * 2022-03-08 2022-06-03 康键信息技术(深圳)有限公司 Information display method and device, electronic equipment and storage medium
CN117057377A (en) * 2023-10-11 2023-11-14 青岛冠成软件有限公司 Code identification matching method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103914675A (en) * 2014-03-17 2014-07-09 东华大学 Garment QD code recognition method
US20150090792A1 (en) * 2013-09-29 2015-04-02 Founder Mobile Media Technology (Beijing) Co., Ltd. System for decoding two dimensional code and method thereof
CN104636118A (en) * 2013-11-10 2015-05-20 航天信息股份有限公司 QR two-dimensional code self-adaptation binarization processing method and device based on light balance

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150090792A1 (en) * 2013-09-29 2015-04-02 Founder Mobile Media Technology (Beijing) Co., Ltd. System for decoding two dimensional code and method thereof
CN104636118A (en) * 2013-11-10 2015-05-20 航天信息股份有限公司 QR two-dimensional code self-adaptation binarization processing method and device based on light balance
CN103914675A (en) * 2014-03-17 2014-07-09 东华大学 Garment QD code recognition method

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111223065A (en) * 2020-01-13 2020-06-02 中国科学院重庆绿色智能技术研究院 Image correction method, irregular text recognition device, storage medium and equipment
CN111223065B (en) * 2020-01-13 2023-08-01 中国科学院重庆绿色智能技术研究院 Image correction method, irregular text recognition device, storage medium and apparatus
CN111311497A (en) * 2020-02-12 2020-06-19 广东工业大学 Bar code image angle correction method and device
CN111311497B (en) * 2020-02-12 2023-05-05 广东工业大学 Bar code image angle correction method and device
CN111339797B (en) * 2020-02-25 2023-05-02 福州符号信息科技有限公司 Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code
CN111339797A (en) * 2020-02-25 2020-06-26 福州符号信息科技有限公司 Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code
CN111343339A (en) * 2020-03-03 2020-06-26 青岛海信移动通信技术股份有限公司 Mobile terminal and image display method thereof
CN111343339B (en) * 2020-03-03 2021-07-23 青岛海信移动通信技术股份有限公司 Mobile terminal and image display method thereof
CN111598794A (en) * 2020-04-24 2020-08-28 山东易华录信息技术有限公司 Image imaging method and device for removing underwater overlapping condition
CN111798619A (en) * 2020-07-09 2020-10-20 常德市广汇气体有限公司 Inflation system for filling gas cylinder by scanning code
CN114330400A (en) * 2020-10-12 2022-04-12 珠海格力电器股份有限公司 Two-dimensional code image processing method, system, device, electronic equipment and storage medium
CN114330400B (en) * 2020-10-12 2023-12-08 珠海格力电器股份有限公司 Two-dimensional code image processing method, system, device, electronic equipment and storage medium
CN113095104A (en) * 2021-05-08 2021-07-09 山东新一代信息产业技术研究院有限公司 Defective two-dimensional code positioning method
CN114582301A (en) * 2022-03-08 2022-06-03 康键信息技术(深圳)有限公司 Information display method and device, electronic equipment and storage medium
CN117057377A (en) * 2023-10-11 2023-11-14 青岛冠成软件有限公司 Code identification matching method
CN117057377B (en) * 2023-10-11 2024-01-12 青岛冠成软件有限公司 Code identification matching method

Also Published As

Publication number Publication date
CN110348264B (en) 2023-12-26

Similar Documents

Publication Publication Date Title
CN110348264B (en) QR two-dimensional code image correction method and system
CN109086714B (en) Form recognition method, recognition system and computer device
CN105069394B (en) Quick Response Code weighted average gray level method coding/decoding method and system
CN105740876B (en) A kind of image pre-processing method and device
CN114529459B (en) Method, system and medium for enhancing image edge
CN112183038A (en) Form identification and typing method, computer equipment and computer readable storage medium
CN104463795A (en) Processing method and device for dot matrix type data matrix (DM) two-dimension code images
CN108021837B (en) Bar code detection method, bar code detection device and electronic equipment
CN113436080B (en) Seal image processing method, device, equipment and storage medium
CN111680690B (en) Character recognition method and device
CN110009615B (en) Image corner detection method and detection device
CN108932449B (en) Bar code binarization method and system based on clustering
CN111259908A (en) Machine vision-based steel coil number identification method, system, equipment and storage medium
CN112163443A (en) Code scanning method, code scanning device and mobile terminal
CN109522768A (en) The recognition methods of QR code and device
CN111582000A (en) Bar code positioning method and device and related equipment
CN111681160B (en) Curved image restoration method, device and equipment and readable storage medium
CN113111674A (en) Aztec code positioning and decoding method, system, equipment and storage medium
CN111311497B (en) Bar code image angle correction method and device
CN112419207A (en) Image correction method, device and system
CN109741273A (en) A kind of mobile phone photograph low-quality images automatically process and methods of marking
CN106778766B (en) Positioning point-based rotating number identification method and system
CN117557565B (en) Detection method and device for lithium battery pole piece
CN117993406A (en) Automatic two-dimensional bar code identification and reading method and system
CN104268550A (en) Feature extraction method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant