CN109785353B - Secondary traversal binarization method and device for two-dimensional code and storage medium - Google Patents

Secondary traversal binarization method and device for two-dimensional code and storage medium Download PDF

Info

Publication number
CN109785353B
CN109785353B CN201910033914.0A CN201910033914A CN109785353B CN 109785353 B CN109785353 B CN 109785353B CN 201910033914 A CN201910033914 A CN 201910033914A CN 109785353 B CN109785353 B CN 109785353B
Authority
CN
China
Prior art keywords
binarization
dimensional code
coarse positioning
local
image
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.)
Active
Application number
CN201910033914.0A
Other languages
Chinese (zh)
Other versions
CN109785353A (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.)
Joint Research Institute
Sun Yat Sen University
SYSU CMU Shunde International Joint Research Institute
Original Assignee
Joint Research Institute
Sun Yat Sen University
SYSU CMU Shunde International Joint Research Institute
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 Joint Research Institute, Sun Yat Sen University, SYSU CMU Shunde International Joint Research Institute filed Critical Joint Research Institute
Priority to CN201910033914.0A priority Critical patent/CN109785353B/en
Publication of CN109785353A publication Critical patent/CN109785353A/en
Application granted granted Critical
Publication of CN109785353B publication Critical patent/CN109785353B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses a two-dimensional code secondary traversal binarization method, a two-dimensional code secondary traversal binarization device and a storage medium. After an original image is obtained, preprocessing is carried out to obtain an input image and an integral image, the input image is transversely scanned and traversed by combining the integral image to obtain a coarse positioning subgraph and a coarse positioning parameter, and binarization is carried out on the coarse positioning subgraph during traversal according to the coarse positioning parameter to obtain a binarization result graph. The method only executes two times of traversal without performing the traversal on the binary image, thereby greatly reducing the calculation amount and accelerating the calculation efficiency, and further realizing the quick identification of the fuzzy two-dimensional code.

Description

Secondary traversal binarization method and device for two-dimensional code and storage medium
Technical Field
The invention relates to the field of image processing, in particular to a two-dimensional code secondary traversal binarization method, a two-dimensional code secondary traversal binarization device and a storage medium.
Background
At present, with the continuous popularization of the application of the two-dimensional code, the two-dimensional code is needed to be used in more and more scenes in life. In an actual practical scene, the situations that light is insufficient, the focal length of code scanning equipment is fuzzy and the like are often encountered, clear two-dimensional codes cannot be acquired, and in order to solve the problem, binaryzation needs to be carried out on the two-dimensional codes at the equipment end so as to enhance identification. The existing binarization method usually adopts the calculation of the gray mean value and the standard deviation of each small block of the two-dimensional code image, and continuously traverses the image until a threshold value obtained by weighting meets a preset standard, and then the binarization is determined to be finished. Although the method can be used for binarizing the two-dimensional code, the number of times of traversal is large, the consumed calculation time and calculation resources are large, the code scanning identification time is too long, and the actual use is not facilitated.
Disclosure of Invention
In order to overcome the defects of the prior art, the invention aims to provide a two-dimensional code twice traversal binarization method and a device thereof, which can complete binarization operation under the condition of traversing images only twice in practical application, realize fast and accurate binarization and improve the fast identification of fuzzy two-dimensional codes.
The technical scheme adopted by the invention for solving the problems is as follows:
in a first aspect, the invention provides a two-dimensional code two-time traversal binarization method, which comprises the following steps:
acquiring an original image, and preprocessing the original image to obtain an input image and a corresponding integral image;
acquiring a preset scanning width, and performing transverse scanning traversal on the input image according to the integral image and the scanning width to obtain a coarse positioning subgraph and a coarse positioning parameter;
and traversing and binarizing the coarse positioning subgraph according to the coarse positioning parameters to obtain a binarization result graph.
Further, the original image is a color RGB image; the preprocessing includes a grayscale transform and a 3 x 3 median filtering operation.
Further, the step of obtaining the coarse positioning subgraph and the coarse positioning parameters specifically comprises the following steps:
performing self-adaptive threshold segmentation on the input image according to the scanning width to obtain a two-dimensional code positioning pattern;
and acquiring preset proportional characteristics, and performing characteristic processing on the two-dimensional code positioning pattern according to the proportional characteristics to obtain a coarse positioning subgraph and a coarse positioning parameter.
Further, the lateral scan pass duration further comprises: the input image and the integral image are alternately accessed, and the value stored at the position of the integral image by the currently scanned pixel is updated.
Further, the coarse positioning parameters include pixel bit width and local binarization window size.
Further, traversing and binarizing the coarse positioning subgraph according to the coarse positioning parameters specifically comprises the following steps:
acquiring the local binarization window size of the current pixel of the traversed coarse positioning sub-image;
calculating a local mean value and a local deviation value of the current pixel, and calculating a local binarization threshold according to the local mean value and the local deviation value;
when the local binarization threshold value of the current pixel is detected to be smaller than or equal to the corresponding gray value in the input image, the binarization result is set to be 1.
In a second aspect, the present invention provides a two-dimensional code twice traversal binarization device, including the following devices:
the preprocessing unit is used for acquiring an original image, preprocessing the original image and obtaining an input image and a corresponding integral image;
the transverse scanning traversal unit is used for acquiring a preset scanning width and carrying out transverse scanning traversal on the input image according to the integral image and the scanning width to obtain a coarse positioning subgraph and a coarse positioning parameter;
and the binarization result graph obtaining unit is used for traversing and binarizing the coarse positioning subgraph according to the coarse positioning parameters to obtain a binarization result graph.
Further, the device also comprises the following devices:
the two-dimensional code positioning pattern acquisition unit is used for performing self-adaptive threshold segmentation on the input image according to the scanning width to obtain a two-dimensional code positioning pattern;
the characteristic processing unit is used for acquiring preset proportional characteristics and performing characteristic processing on the two-dimensional code positioning pattern according to the proportional characteristics to obtain a coarse positioning subgraph and coarse positioning parameters;
the integral image updating unit is used for alternately accessing the input image and the integral image and updating the numerical value stored in the integral image position of the currently scanned pixel;
the window size acquisition unit is used for acquiring the local binarization window size of the current pixel of the traversed coarse positioning subgraph;
the local binarization threshold calculation unit is used for calculating a local mean value and a local deviation value of the current pixel and calculating a local binarization threshold according to the local mean value and the local deviation value;
and the binarization result setting unit is used for setting the binarization result to be 1 when detecting that the local binarization threshold value of the current pixel is less than or equal to the corresponding gray value in the input image.
In a third aspect, the invention provides a two-dimensional code twice-traversal binarization device, which comprises at least one control processor and a memory, wherein the memory is used for being in communication connection with the at least one control processor; the memory stores instructions executable by the at least one control processor to enable the at least one control processor to perform the two-pass binarization method of the two-dimensional code as described above.
In a fourth aspect, the present invention provides a computer-readable storage medium storing computer-executable instructions for causing a computer to execute the two-pass binarization method for two-dimensional codes as described above.
In a fifth aspect, the present invention also provides a computer program product comprising a computer program stored on a computer-readable storage medium, the computer program comprising program instructions that, when executed by a computer, cause the computer to perform the two-pass binarization method of a two-dimensional code as described above.
One or more technical schemes provided in the embodiment of the invention have at least the following beneficial effects: the invention adopts a two-dimensional code secondary traversal binarization method, a device and a storage medium. After an original image is obtained, preprocessing is carried out to obtain an input image and an integral image, the input image is transversely scanned and traversed by combining the integral image to obtain a coarse positioning subgraph and a coarse positioning parameter, and binarization is carried out on the coarse positioning subgraph during traversal according to the coarse positioning parameter to obtain a binarization result graph. Compared with the prior art, the method only executes two traversals without performing the traversals on the binary image, so that the calculation amount is greatly reduced, the calculation efficiency is accelerated, and the quick identification of the fuzzy two-dimensional code is realized.
Drawings
The invention is further illustrated with reference to the following figures and examples.
Fig. 1 is a flowchart of a two-dimensional code quadratic traversal binarization method according to an embodiment of the present invention;
fig. 2 is a flowchart of obtaining a coarse positioning subgraph and a coarse positioning parameter by using a two-dimensional code twice traversal binarization method according to an embodiment of the present invention;
fig. 3 is a flowchart of traversing and binarizing the coarse positioning subgraph according to the coarse positioning parameter in the two-dimensional code twice-traversal binarization method according to the embodiment of the present invention;
fig. 4 is a diagram of a complete step of a two-dimensional code quadratic traversal binarization method according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a device of a two-dimensional code twice-traversal binarization device according to a second embodiment of the present invention;
fig. 6 is a schematic structural diagram of a two-dimensional code twice-traversal binarization device according to a third embodiment of the present invention.
Detailed Description
At present, with the continuous popularization of the application of the two-dimensional code, the two-dimensional code is needed to be used in more and more scenes in life. In an actual practical scene, the situations that light is insufficient, the focal length of code scanning equipment is fuzzy and the like are often encountered, clear two-dimensional codes cannot be acquired, and in order to solve the problem, binaryzation needs to be carried out on the two-dimensional codes at the equipment end so as to enhance identification. The existing binarization method usually adopts the calculation of the gray mean value and the standard deviation of each small block of the two-dimensional code image, and continuously traverses the image until a threshold value obtained by weighting meets a preset standard, and then the binarization is determined to be finished. Although the method can be used for binarizing the two-dimensional code, the number of times of traversal is large, the consumed calculation time and calculation resources are large, the code scanning identification time is too long, and the actual use is not facilitated.
Based on the method, the device and the storage medium, the two-dimensional code is subjected to secondary traversal binarization. After an original image is obtained, preprocessing is carried out to obtain an input image and an integral image, the input image is transversely scanned and traversed by combining the integral image to obtain a coarse positioning subgraph and a coarse positioning parameter, and binarization is carried out on the coarse positioning subgraph during traversal according to the coarse positioning parameter to obtain a binarization result graph. Compared with the prior art, the method only executes two traversals without performing the traversals on the binary image, so that the calculation amount is greatly reduced, the calculation efficiency is accelerated, and the quick identification of the fuzzy two-dimensional code is realized.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
It should be noted that, if not conflicted, the various features of the embodiments of the invention may be combined with each other within the scope of protection of the invention. Additionally, while functional block divisions are performed in apparatus schematics, with logical sequences shown in flowcharts, in some cases, steps shown or described may be performed in sequences other than block divisions in apparatus or flowcharts.
Referring to fig. 1, an embodiment of the present invention provides a two-dimensional code binary method by two-pass traversal, including the following steps:
step S1, acquiring an original image, preprocessing the original image to obtain an input image and a corresponding integral image;
step S2, acquiring a preset scanning width, and performing transverse scanning traversal on the input image according to the integral image and the scanning width to obtain a coarse positioning subgraph and coarse positioning parameters;
and step S3, traversing and binarizing the coarse positioning subgraph according to the coarse positioning parameters to obtain a binarization result graph.
In this embodiment, preferably, the original image is obtained by scanning a two-dimensional code with a smart device, and when the two-dimensional code is identified by the code scanning device, the two-dimensional code region is obtained as the original image.
In this embodiment, after the input image is obtained, a space having the same size as the input image is created in the memory, and an integral image is synchronously stored, that is, the integral image stores the sum of all pixels above and to the left of the corresponding pixel position in the input image. The integral image is adopted, so that the number of times of traversing the input image can be greatly reduced, the calculation amount of local binarization at the later stage is reduced, and a foundation is provided for obtaining the binarized image through secondary traversal.
In the embodiment, the preferably obtained binarization result graph comprises a coarse positioning subgraph and a binarization image of the two-dimensional code, and the application range of the method can be further widened by simultaneously outputting the two images, thereby being beneficial to further analysis and processing after identification through the coarse positioning subgraph and the binarization image.
Further, the original image is a color RGB image; the preprocessing includes a grayscale transform and a 3 x 3 median filtering operation.
In this embodiment, any form of preprocessing operation may be performed on the original image, and the original image may be used to identify the two-dimensional code.
In this embodiment, the gray scale conversion may adopt any calculation method, and in this embodiment, after the color RGB image including the two-dimensional code is acquired, the gray scale value is preferably calculated according to the following formula: gray ═ 0.3R +0.59G + 0.11B; wherein Gray is a Gray value, and R, G, B are RGB values of the two-dimensional code image respectively.
Referring to fig. 2, further, in another embodiment of the present invention, the deriving the coarse localization sub-graph and the coarse localization parameters specifically includes the following steps:
step S21, carrying out self-adaptive threshold segmentation on the input image according to the scanning width to obtain a two-dimensional code positioning pattern;
and step S22, acquiring preset proportional characteristics, and performing characteristic processing on the two-dimensional code positioning pattern according to the proportional characteristics to obtain a coarse positioning subgraph and coarse positioning parameters.
In this embodiment, since the size of the two-dimensional code is usually not too large, the range of the scan width N is preferably 5 to 7 pixel bits. In the adaptive threshold segmentation process, the first N pixels of a row are skipped and not processed while traversing the image. With pxAnd expressing the gray value of the current scanning point, and calculating the average gray value of the previous N pixel points. Considering the influence relationship of the first N pixels on the 'big-end-up-end-down' of the current pixel in the gradient image, the closer the current pixel is, the larger the influence on the gray scale of the current pixel is, and the smaller the influence is, otherwise, the smaller the influence is, so that the conversion and superposition formula introducing exponential attenuation is used for solving the predicted value g of the first N pixels on the current pixelxThe specific calculation formula is as follows:
Figure GDA0002715014740000091
k and lambda are exponential decay coefficients and are obtained by presetting; the predicted value g of the current pixel to be calculatedxAnd the gray value p of the current scanning pointxA comparison is made. If p isx<gxTemporarily, the current pixel point is regarded as black; otherwise, the color is regarded as white.
In this embodiment, it is preferable that the preset ratio characteristic is 1:1:3:1:1, and the image is processed by the horizontal scanning once based on the result of the calculation. And acquiring coordinate records according with the characteristics of black and white pixels 1:1:3:1:1 in the two-dimensional code direction-finding area. Determining the approximate region of the two-dimensional code image and the pixel bit width of a single two-dimensional code, and widening and cutting out a sub-image containing the complete two-dimensional code, namely a coarse positioning sub-image according to the width b of the approximate region of the two-dimensional code image and the pixel bit width omega of the single two-dimensional code. And determining a square window with the local binarization window size k omega by k omega, wherein k is obtained by presetting.
Further, in another embodiment of the present invention, the transverse scan traversal further comprises: the input image and the integral image are alternately accessed, and the value stored at the position of the integral image by the currently scanned pixel is updated.
In this embodiment, it is preferable to alternately access the input image G (x, y) and the integral image I (x, y) while scanning the input image transversely, and update the value stored in the integral image position of the currently scanned pixel in real time, which is beneficial to reducing the number of traversals.
Further, in another embodiment of the present invention, the coarse positioning parameters include pixel bit width and window size for local binarization.
In this embodiment, the coarse positioning parameters may further include any available parameters, and in this embodiment, the pixel bit width and the window size of the local binarization are preferably obtained for subsequent calculation.
Referring to fig. 3, further, in another embodiment of the present invention, the traversing and binarizing the coarse localization subgraph according to the coarse localization parameters specifically includes the following steps:
step S31, obtaining the local binarization window size of the current pixel of the traversed coarse positioning sub-image;
step S32, calculating a local mean value and a local deviation value of the current pixel, and calculating a local binarization threshold according to the local mean value and the local deviation value;
in step S33, when it is detected that the local binarization threshold of the current pixel is less than or equal to the corresponding grayscale value in the input image, the binarization result is set to 1.
In this embodiment, it is preferable to perform a second traversal on the coarse localization graph calculated in step S22, and calculate a local mean m (x, y) in a square window of k ω × k ω where each pixel is locatedAnd local deviations
Figure GDA0002715014740000104
The specific calculation method is as follows:
Figure GDA0002715014740000101
Figure GDA0002715014740000102
according to the calculation result, the local binarization threshold value T (x, y) is further calculated, and the specific calculation mode is as follows:
Figure GDA0002715014740000103
wherein k is1、k2And C is a preset offset coefficient.
In the present embodiment, the local binarization threshold T (x, y) obtained as described above is compared with G (x, y) of the original input image. If G (x, y) ≧ T (x, y), the binarization result is "1". Otherwise, it is "0".
In this embodiment, the above-mentioned calculation method is to calculate the binarization value of the current pixel, and the calculation is repeatedly performed until the entire image is traversed. Therefore, the binarization result graph is obtained through secondary traversal.
Referring to fig. 4, in addition, another embodiment of the present invention further provides a two-dimensional code twice-traversal binarization method, including the following steps:
step S100, acquiring an original image, and preprocessing the original image to obtain an input image and a corresponding integral image;
step S200, acquiring a preset scanning width;
step S210, carrying out self-adaptive threshold segmentation on the input image according to the scanning width to obtain a two-dimensional code positioning pattern;
step S220, acquiring preset proportional characteristics, and performing characteristic processing on the two-dimensional code positioning pattern according to the proportional characteristics to obtain a coarse positioning subgraph, a pixel bit width and a local binarization window size;
step S310, obtaining the local binarization window size of the current pixel of the traversed coarse positioning subgraph;
step S320, calculating a local mean value and a local deviation value of the current pixel, and calculating a local binarization threshold according to the local mean value and the local deviation value;
step S330, when detecting that the local binarization threshold value of the current pixel is less than or equal to the corresponding gray value in the input image, setting the binarization result to be 1;
and step S340, repeatedly executing the steps S310-S330 until the traversal is completed, and outputting a binarization result graph.
In the present embodiment, an image including a two-dimensional code captured by a camera in an actual scene is subjected to gray scale conversion, and a color image is converted into a gray scale image. And then denoising by adopting median filtering. And then, transversely scanning an image once by adopting a self-adaptive ladder threshold segmentation method and utilizing the characteristics of the two-dimensional code positioning pattern 1:1:3:1:1, and determining the approximate area of the two-dimensional code image and the pixel bit width of a single two-dimensional code. And then, calculating the size of a local binarization window according to the pixel bit width of the single two-dimensional code and the width of the approximate area of the two-dimensional code. And finally, an improved rapid local binarization method is adopted to finish the self-adaptive binarization operation of the fuzzy two-dimensional code.
In the embodiment, after an original image is acquired, preprocessing is performed to obtain an input image and an integral image, the input image is subjected to transverse scanning traversal by combining the integral image to obtain a coarse positioning subgraph and a coarse positioning parameter, and binarization is performed on the coarse positioning subgraph during traversal according to the coarse positioning parameter to obtain a binarization result graph. Compared with the prior art, the method only executes two traversals without performing the traversals on the binary image, so that the calculation amount is greatly reduced, the calculation efficiency is accelerated, and the quick identification of the fuzzy two-dimensional code is realized.
Referring to fig. 5, a second embodiment of the present invention further provides a two-dimensional code twice-traversal binarization device, where in the two-dimensional code twice-traversal binarization device 1000, the two-dimensional code includes, but is not limited to: a preprocessing unit 1100, a transverse scanning traversal unit 1200 and a binarization result image acquisition unit 1300.
The preprocessing unit 1100 is configured to acquire an original image, preprocess the original image, and obtain an input image and a corresponding integral image;
the transverse scanning traversal unit 1200 is configured to acquire a preset scanning width, and perform transverse scanning traversal on the input image according to the integral image and the scanning width to obtain a coarse positioning subgraph and a coarse positioning parameter;
the binarization result map obtaining unit 1300 is configured to traverse and binarize the coarse positioning subgraph according to the coarse positioning parameters to obtain a binarization result map.
Further, in another embodiment of the present invention, but not limited to, further comprising: a two-dimensional code positioning pattern acquisition unit 1210, a feature processing unit 1220, an integral image updating unit 1230, a window size acquisition unit 1310, a local binarization threshold calculation unit 1320, and a binarization result setting unit 1330.
The two-dimensional code positioning pattern obtaining unit 1210 is configured to perform adaptive threshold segmentation on an input image according to a scan width to obtain a two-dimensional code positioning pattern;
the feature processing unit 1220 is configured to obtain a preset proportional feature, and perform feature processing on the two-dimensional code positioning pattern according to the proportional feature to obtain a coarse positioning subgraph and a coarse positioning parameter;
the integral image updating unit 1230 is used for alternately accessing the input image and the integral image and updating the numerical value stored in the position of the integral image by the currently scanned pixel;
the window size obtaining unit 1310 is configured to obtain a locally binarized window size of a current pixel of the traversed coarse positioning sub-image;
the local binarization threshold calculation unit 1320 is configured to calculate a local mean value and a local deviation value for the current pixel, and calculate a local binarization threshold according to the local mean value and the local deviation value;
the binarization result setting unit 1330 is configured to set the binarization result to 1 when detecting that the local binarization threshold of the current pixel is less than or equal to the corresponding grayscale value in the input image.
It should be noted that, since the two-dimensional code twice-traversal binarization device in this embodiment is based on the same inventive concept as the two-dimensional code twice-traversal binarization method described above, corresponding contents in the method embodiment are also applicable to this device embodiment, and detailed descriptions thereof are omitted here.
Referring to fig. 6, a third embodiment of the present invention further provides a two-dimensional code two-pass binarization device, where the two-dimensional code two-pass binarization device 6000 may be any type of intelligent terminal, such as a mobile phone, a tablet computer, a personal computer, and the like.
Specifically, the two-dimensional code twice-traversal binarization device 6000 includes: one or more control processors 6001 and a memory 6002, for example control processor 6001 in fig. 5.
The control processor 6001 and memory 6002 may be coupled via a bus or otherwise, as shown by way of example in FIG. 6.
The memory 6002 is a non-transitory computer-readable storage medium and can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as program instructions/modules corresponding to the two-dimensional code two-pass binarization device in the embodiment of the present invention, for example, the preprocessing unit 1100 and the transverse scan traversal unit 1200 shown in fig. 5. The control processor 6001 executes various functional applications and data processing of the two-dimensional code twice-traversal binarization device 1000 by running non-transitory software programs, instructions and modules stored in the memory 6002, that is, implements the two-dimensional code twice-traversal binarization method according to the above-described method embodiment.
The memory 6002 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created from the use of the two-dimensional code twice-traversal binarization device 1000, and the like. Further, the memory 6002 can include high-speed random access memory, and can also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 6002 may optionally include a memory remotely located from the control processor 6001, and these remote memories may be connected to the second traversal binarization device 6000 of the two-dimensional code via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 6002 and when executed by the one or more control processors 6001, execute the binary traversal method for the two-dimensional code in the above-described method embodiment, for example, execute the above-described method steps S1-S3 in fig. 1, method steps S21-S22 in fig. 2, and method steps S31-S33 in fig. 3, and implement the functions of the cell 1100-1300 in fig. 5.
Embodiments of the present invention further provide a computer-readable storage medium storing computer-executable instructions, which are executed by one or more control processors, for example, by one control processor 6001 in fig. 6, and can cause the one or more control processors 6001 to execute the binary traversal method for two-dimensional code in the above method embodiments, for example, execute the above-described method steps S1 to S3 in fig. 1, the method steps S21 to S22 in fig. 2, and the method steps S31 to S33 in fig. 3, so as to implement the functions of the unit 1100 and 1300 in fig. 5.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, may be located in one place, or may be distributed over a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be implemented by software plus a general hardware platform. Those skilled in the art will appreciate that all or part of the processes of the methods of the above embodiments may be implemented by hardware related to instructions of a computer program, which may be stored in a computer readable storage medium, and when executed, may include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read Only Memory (ROM), a Random Access Memory (RAM), or the like.
While the preferred embodiments of the present invention have been described in detail, it will be understood by those skilled in the art that the foregoing and various other changes, omissions and deviations in the form and detail thereof may be made without departing from the scope of this invention.

Claims (8)

1. A two-dimensional code secondary traversal binarization method is characterized by comprising the following steps: acquiring an original image, and preprocessing the original image to obtain an input image and a corresponding integral image;
acquiring a preset scanning width, and performing transverse scanning traversal on the input image according to the integral image and the scanning width to obtain a coarse positioning subgraph and a coarse positioning parameter;
traversing and binarizing the coarse positioning subgraph according to coarse positioning parameters to obtain a binarization result graph, wherein the coarse positioning parameters comprise pixel bit width and local binarization window size;
the traversing and binarization of the coarse positioning subgraph according to the coarse positioning parameters specifically comprises the following steps:
acquiring the local binarization window size of the current pixel of the traversed coarse positioning sub-image;
calculating a local mean value and a local deviation value of the current pixel, and calculating a local binarization threshold according to the local mean value and the local deviation value;
when detecting that the local binarization threshold value of the current pixel is less than or equal to the corresponding gray value in the input image, setting the binarization result to be 1;
wherein, the calculation of the local mean value and the local deviation value of the current pixel is completed by the following formula:
Figure FDA0002715014730000011
Figure FDA0002715014730000012
wherein m (x, y) is a local mean of a square window of k ω x k ω where each pixel is located,
Figure FDA0002715014730000013
i (x, y) is the integral image for the local deviation of the square window of k ω × k ω where each pixel is located;
the local binarization threshold value calculated according to the local mean value and the local deviation value is obtained by the following formula:
Figure FDA0002715014730000021
where T (x, y) is the local binarization threshold, k1、k2And C is a preset offset coefficient.
2. The two-dimensional code twice traversal binarization method according to claim 1, characterized in that: the original image is a color RGB image; the preprocessing includes a grayscale transform and a 3 x 3 median filtering operation.
3. The two-dimensional code twice traversal binarization method according to claim 1, wherein the obtaining of the coarse positioning subgraph and the coarse positioning parameters specifically comprises the following steps:
performing self-adaptive threshold segmentation on the input image according to the scanning width to obtain a two-dimensional code positioning pattern; and acquiring preset proportional characteristics, and performing characteristic processing on the two-dimensional code positioning pattern according to the proportional characteristics to obtain a coarse positioning subgraph and a coarse positioning parameter.
4. The method according to claim 1, wherein the transverse scanning traversal further comprises: the input image and the integral image are alternately accessed, and the value stored at the position of the integral image by the currently scanned pixel is updated.
5. The two-dimensional code secondary traversal binarization device is characterized by comprising the following devices: the preprocessing unit is used for acquiring an original image, preprocessing the original image and obtaining an input image and a corresponding integral image;
the transverse scanning traversal unit is used for acquiring a preset scanning width and carrying out transverse scanning traversal on the input image according to the integral image and the scanning width to obtain a coarse positioning subgraph and a coarse positioning parameter;
a binarization result graph obtaining unit, configured to traverse and binarize the coarse positioning subgraph according to the coarse positioning parameters to obtain a binarization result graph;
the window size acquisition unit is used for acquiring the local binarization window size of the current pixel of the traversed coarse positioning subgraph;
the local binarization threshold calculation unit is used for calculating a local mean value and a local deviation value of the current pixel and calculating a local binarization threshold according to the local mean value and the local deviation value;
and the binarization result setting unit is used for setting the binarization result to be 1 when detecting that the local binarization threshold value of the current pixel is less than or equal to the corresponding gray value in the input image.
6. The apparatus according to claim 5, further comprising the following means:
the two-dimensional code positioning pattern acquisition unit is used for performing self-adaptive threshold segmentation on the input image according to the scanning width to obtain a two-dimensional code positioning pattern;
the characteristic processing unit is used for acquiring preset proportional characteristics and performing characteristic processing on the two-dimensional code positioning pattern according to the proportional characteristics to obtain a coarse positioning subgraph and coarse positioning parameters;
and the integral image updating unit is used for alternately accessing the input image and the integral image and updating the numerical value stored in the position of the integral image by the currently scanned pixel.
7. The utility model provides a binary equipment is traversed to secondary of two-dimensional code which characterized in that: comprises at least one control processor and a memory for communicative connection with the at least one control processor; the memory stores instructions executable by the at least one control processor to enable the at least one control processor to perform a two-pass binarization method of a two-dimensional code as claimed in any one of claims 1-4.
8. A computer-readable storage medium characterized by: the computer-readable storage medium stores computer-executable instructions for causing a computer to perform a two-dimensional code two-pass binarization method according to any one of claims 1 to 4.
CN201910033914.0A 2019-01-15 2019-01-15 Secondary traversal binarization method and device for two-dimensional code and storage medium Active CN109785353B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910033914.0A CN109785353B (en) 2019-01-15 2019-01-15 Secondary traversal binarization method and device for two-dimensional code and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910033914.0A CN109785353B (en) 2019-01-15 2019-01-15 Secondary traversal binarization method and device for two-dimensional code and storage medium

Publications (2)

Publication Number Publication Date
CN109785353A CN109785353A (en) 2019-05-21
CN109785353B true CN109785353B (en) 2020-12-08

Family

ID=66500547

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910033914.0A Active CN109785353B (en) 2019-01-15 2019-01-15 Secondary traversal binarization method and device for two-dimensional code and storage medium

Country Status (1)

Country Link
CN (1) CN109785353B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113283262A (en) * 2020-12-29 2021-08-20 深圳怡化电脑股份有限公司 Two-dimensional code positioning method and device, electronic equipment and machine readable medium
CN114548140B (en) * 2022-04-26 2022-08-12 成都普什信息自动化有限公司 Two-dimensional code decoding method, data association method, association device and use method

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103235948A (en) * 2013-04-22 2013-08-07 中山大学 Adaptive threshold binarization method for two-dimensional barcode
CN104517090A (en) * 2013-09-29 2015-04-15 北大方正集团有限公司 Method and system for detecting QR code detection figures
CN104715221A (en) * 2015-03-25 2015-06-17 广州宽度信息技术有限公司 Decoding method and system for ultra-low-contrast two-dimension code
CN104933387A (en) * 2015-06-24 2015-09-23 上海快仓智能科技有限公司 Rapid positioning and identifying method based on two-dimensional code decoding
CN106845313A (en) * 2016-12-28 2017-06-13 广州智慧城市发展研究院 A kind of binary processing method of Quick Response Code
CN107545259A (en) * 2017-08-31 2018-01-05 华南理工大学 A kind of Quick Response Code reconstructing method based on Da-Jin algorithm
CN108154510A (en) * 2018-01-17 2018-06-12 深圳市亿图视觉自动化技术有限公司 Method for detecting surface defects of products, device and computer readable storage medium
CN108345816A (en) * 2018-01-29 2018-07-31 广州中大微电子有限公司 A kind of Quick Response Code extracting method and system in the case where uneven illumination is even

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103020618B (en) * 2011-12-19 2016-03-16 北京捷成世纪数码科技有限公司 The detection method of video image character and system
CN103544491A (en) * 2013-11-08 2014-01-29 广州广电运通金融电子股份有限公司 Optical character recognition method and device facing complex background

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103235948A (en) * 2013-04-22 2013-08-07 中山大学 Adaptive threshold binarization method for two-dimensional barcode
CN104517090A (en) * 2013-09-29 2015-04-15 北大方正集团有限公司 Method and system for detecting QR code detection figures
CN104715221A (en) * 2015-03-25 2015-06-17 广州宽度信息技术有限公司 Decoding method and system for ultra-low-contrast two-dimension code
CN104933387A (en) * 2015-06-24 2015-09-23 上海快仓智能科技有限公司 Rapid positioning and identifying method based on two-dimensional code decoding
CN106845313A (en) * 2016-12-28 2017-06-13 广州智慧城市发展研究院 A kind of binary processing method of Quick Response Code
CN107545259A (en) * 2017-08-31 2018-01-05 华南理工大学 A kind of Quick Response Code reconstructing method based on Da-Jin algorithm
CN108154510A (en) * 2018-01-17 2018-06-12 深圳市亿图视觉自动化技术有限公司 Method for detecting surface defects of products, device and computer readable storage medium
CN108345816A (en) * 2018-01-29 2018-07-31 广州中大微电子有限公司 A kind of Quick Response Code extracting method and system in the case where uneven illumination is even

Also Published As

Publication number Publication date
CN109785353A (en) 2019-05-21

Similar Documents

Publication Publication Date Title
CN108921823A (en) Image processing method, device, computer readable storage medium and electronic equipment
WO2019221013A4 (en) Video stabilization method and apparatus and non-transitory computer-readable medium
CN104517110A (en) Binarization method and system of two-dimensional code image
CN109858309B (en) Method and device for identifying road route
CN109785353B (en) Secondary traversal binarization method and device for two-dimensional code and storage medium
CN111105452B (en) Binocular vision-based high-low resolution fusion stereo matching method
CN109815762B (en) Method and storage medium for remotely identifying two-dimensional code
CN110415280B (en) Remote sensing image and building vector registration method and system under multitask CNN model
CN111582000B (en) Bar code positioning method, bar code positioning device and related equipment
CN103577828B (en) A kind of Approach for road detection based on edge feature
CN108710837A (en) Cigarette smoking recognition methods, device, computer equipment and storage medium
CN115457063A (en) Method, device and equipment for extracting edge of circular hole of PCB (printed Circuit Board) and storage medium
CN115239734A (en) Model training method, device, storage medium, equipment and computer program product
CN116612280A (en) Vehicle segmentation method, device, computer equipment and computer readable storage medium
CN108182700B (en) Image registration method based on two-time feature detection
CN111445411B (en) Image denoising method, image denoising device, computer equipment and storage medium
CN111767752A (en) Two-dimensional code identification method and device
CN112669346B (en) Pavement emergency determination method and device
CN109766889B (en) Rail image recognition post-processing method based on curve fitting
CN111104870A (en) Motion detection method, device and equipment based on satellite video and storage medium
CN111784636A (en) Skin image texture quantitative evaluation method based on texture growth
CN113793292A (en) Data processing method and device, electronic equipment and storage medium
CN115578500B (en) Mixed illumination method based on three-dimensional photogrammetry modeling
CN114120056B (en) Small target identification method, device, electronic equipment, medium and product
CN111127489B (en) Image frequency division method and device, storage medium and terminal

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