CN110610218A - Portrait image two-dimensional code generation method - Google Patents
Portrait image two-dimensional code generation method Download PDFInfo
- Publication number
- CN110610218A CN110610218A CN201910732417.XA CN201910732417A CN110610218A CN 110610218 A CN110610218 A CN 110610218A CN 201910732417 A CN201910732417 A CN 201910732417A CN 110610218 A CN110610218 A CN 110610218A
- Authority
- CN
- China
- Prior art keywords
- portrait image
- image
- value
- pixel
- portrait
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06037—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06046—Constructional details
- G06K19/06103—Constructional details the marking being embedded in a human recognizable image, e.g. a company logo with an embedded two-dimensional code
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
Abstract
The invention discloses a method for generating a portrait image two-dimensional code, which is characterized by comprising the following steps: step 1: taking a portrait image A, and compressing the portrait image A to obtain a compressed image with the pixel data size meeting the storage capacity size of the QR code; step 2: extracting the pixel data of the compressed image obtained in the step to obtain a pixel data group; and step 3: and coding the pixel data group obtained in the step to generate the QR code. The method has the advantages that the portrait image is compressed, so that the compressed image obtained after compression can be directly converted into the QR code in a coding mode, the off-line storage of the portrait image is realized, the portability is good, the support of a database is not required, and the cost is greatly reduced.
Description
Technical Field
The invention relates to a method for generating an image two-dimensional code, in particular to a method for generating a portrait image two-dimensional code.
Background
Internationally, with more than a decade of effort, QR codes (a kind of two-dimensional codes) have now been widely used in various industries, including finance, industry and commerce, defense, customs, transportation, medical treatment, and government. Compared with developed countries, although the two-dimensional code industry in China starts late, along with the popularization of mobile internet and intelligent terminals, the two-dimensional code industry in China shows a explosive growth situation, particularly, the QR code technology is widely applied to various aspects such as article identity identification, leaflets, advertisement boards, products, outdoor, digital media storage logistics, product tracing, mobile payment and the like, and the common points of the fields are that the identification rate is high, an information carrier is not easy to damage, and the factors such as convenient identification of a mobile phone camera and built-in software are added, so that the QR code becomes the two-dimensional code which is currently and mainstream applied.
The data storage capacity of the QR code is nearly 3KB, and a part of the capacity of the data stored in the QR code is also used for storing error correction coded data and version format data carried by the QR code, so that the capacity of the data really stored in the QR code is far less than 3 KB. However, the data size of the conventional portrait image absolutely exceeds the storage capacity of the QR code, and if the portrait image is to be stored in the form of the QR code, the portrait image must be supported by a database according to the above method, which is poor in portability, and the database needs to be periodically maintained, resulting in high cost.
Disclosure of Invention
The invention aims to solve the technical problem of providing a method for generating a portrait image two-dimensional code, which can realize off-line storage of a portrait image, has good portability, does not need to rely on the support of a database, and greatly reduces the cost.
The technical scheme adopted by the invention for solving the technical problems is as follows:
a method for generating a portrait image two-dimensional code comprises the following steps:
step 1: taking a portrait image A, and compressing the portrait image A to obtain a compressed image with the pixel data size meeting the storage capacity size of the QR code;
step 2: extracting the pixel data of the compressed image obtained in the step to obtain a pixel data group of the compressed image;
and step 3: and encoding the pixel data group of the compressed image obtained in the step to generate the QR code.
The step 1 comprises the following specific steps:
step 1-1: preprocessing the portrait image A, wherein the specific preprocessing process is as follows:
step 1-1-1: setting the size of the portrait image A as m × n, defining the filtering value corresponding to each pixel point on the portrait image A as f (i, j), filtering the portrait image A to obtain the filtering value f (i, j) corresponding to each pixel point on the portrait image A, wherein,
m represents the width of the portrait image A, n represents the length of the portrait image A, i represents the horizontal direction of the portrait image A, j represents the vertical direction of the portrait image A, PijThe pixel value of the (i, j) intersection on the portrait image A is represented, f (i, j) represents the filtered value of the (i, j) intersection on the portrait image A, and the parameter Sigma is the width of f (i, j);
step 1-1-2: carrying out normalization processing on the portrait image A after filtering processing:
adding the filter values f (i, j) corresponding to each pixel point on the portrait image A obtained in the above step to obtain a filter sum value sum (f (i, j)) of the portrait image A, dividing the filter value f (i, j) corresponding to each pixel point by the filter sum value sum (f (i, j)), and obtaining a normalized convolution value g (i, j) as:
step 1-1-3: performing convolution processing on each pixel point in a Sigma area formed by taking an arbitrary point Q as the center in the portrait image A by using the convolution value g (i, j) obtained in the step, replacing the pixel value of the arbitrary point Q by the weighted average gray value in the Sigma area determined by the convolution processing, and forming a preprocessed portrait image after all the pixel points are replaced, wherein the pixel value g (i, j) is obtained in the step
Ap(i, j) represents the pixel value at the intersection of (i, j) in the portrait image A, AQ(i, j) represents each pixel point in a Sigma region centered on an arbitrary point Q;
step 1-2: and carrying out reduction processing on the preprocessed portrait image by utilizing the Gaussian pyramid principle to obtain a compressed image.
By adopting the specific steps, the data size of the portrait image can be remarkably reduced, so that the compressed image obtained after compression can better meet the QR storage requirement.
And (3) performing median filtering processing on the compressed image obtained in the step 1-2. The method is used for removing salt and pepper noise of the compressed image, adjusting the color brightness of the compressed image, and ensuring that the portrait image restored by decoding can be normally compared with a real person without influencing the comparison effect.
The median filtered neighborhood window was chosen to be 5 x 5. And ensuring that the pixel values around the neighborhood are close to the true values, thereby eliminating isolated noise points.
And (3) carrying out Huffman compression on the pixel data group of the compressed image extracted in the step (2). The compression ratio is further improved by 20% on average; meanwhile, the data is encrypted, and the safe use is ensured.
Compared with the prior art, the invention has the advantages that: by compressing the portrait image, the compressed image obtained after compression can be directly converted into a QR code in a coding mode, so that the off-line storage of the portrait image is realized, the portability is good, the support of a database is not required, and the cost is greatly reduced.
Drawings
FIG. 1 is a functional block diagram of the present invention;
FIG. 2 is a flow chart of step 1 of the present invention.
Detailed Description
The invention is described in further detail below with reference to the accompanying examples.
As shown in the figure, a method for generating a portrait image two-dimensional code includes the following steps:
step 1: taking a portrait image A, and compressing the portrait image A to obtain a compressed image with the pixel data size meeting the storage capacity size of the QR code;
step 1-1: preprocessing the portrait image A, wherein the specific preprocessing process is as follows:
step 1-1-1: setting the size of the portrait image A as m × n, defining the filtering value corresponding to each pixel point on the portrait image A as f (i, j), filtering the portrait image A to obtain the filtering value f (i, j) corresponding to each pixel point on the portrait image A, wherein,
m represents the width of the portrait image A, n represents the length of the portrait image A, i represents the horizontal direction of the portrait image A, j represents the vertical direction of the portrait image A, PijThe pixel value of the (i, j) intersection on the portrait image A is represented, f (i, j) represents the filtered value of the (i, j) intersection on the portrait image A, and the parameter Sigma is the width of f (i, j);
step 1-1-2: carrying out normalization processing on the portrait image A after filtering processing:
adding the filter values f (i, j) corresponding to each pixel point on the portrait image A obtained in the above step to obtain a filter sum value sum (f (i, j)) of the portrait image A, dividing the filter value f (i, j) corresponding to each pixel point by the filter sum value sum (f (i, j)), and obtaining a normalized convolution value g (i, j) as:
step 1-1-3: performing convolution processing on each pixel point in a Sigma area formed by taking an arbitrary point Q as the center in the portrait image A by using the convolution value g (i, j) obtained in the step, replacing the pixel value of the arbitrary point Q by the weighted average gray value in the Sigma area determined by the convolution processing, and forming a preprocessed portrait image after all the pixel points are replaced, wherein the pixel value g (i, j) is obtained in the step
Ap(i, j) represents the pixel value at the intersection of (i, j) in the portrait image A, AQ(i, j) represents each pixel point in a Sigma region centered on an arbitrary point Q;
step 1-2: carrying out reduction processing on the preprocessed portrait image by utilizing the Gaussian pyramid principle to obtain a compressed image;
by the gaussian pyramid principle, in short, half of odd or even rows and columns are removed, and the resolution is reduced to achieve the effect of reducing the picture, that is, a point (i, j +2) in the row direction of the original image is translated to a position at a point (i, j +1) in the row direction, and a corresponding point (i +2, j) in the column direction of the image is translated to a position at a point (i +1, j) in the column direction, wherein 0< i < ═ m, and 0< j < > n; by utilizing the method, not only the influence of the gray values of four directly adjacent pixel points around is considered, but also the influence of the change rate of the gray values of the four directly adjacent pixel points is considered, so that the occurrence of ripples can be avoided, smoother edges can be generated, the calculation precision is very high, and the image quality loss of the processed image is minimum;
and (3) performing median filtering on the compressed image obtained in the step 1-2 by adopting a method mentioned in chapter 6 of the book "OpenCV 3 Programming entry", selecting a neighborhood window of 5 × 5 for median filtering, and removing salt and pepper noise of the compressed image to adjust the color brightness of the compressed image.
Step 2: extracting the pixel data of the compressed image obtained in the step to obtain a pixel data group of the compressed image;
and (3) carrying out Huffman compression on the pixel data group of the compressed image extracted in the step (2).
And step 3: and (3) carrying out coding processing on the pixel data group of the compressed image obtained in the step in a coding mode mentioned in the third chapter of thesis of QR two-dimensional code generation and decoding based on an Android platform to generate a QR code.
The sum of the image sizes processed in the above step 1 is shown in the following table 1:
TABLE 1
The compression ratio after compression in step 2 is shown in table 2 below:
table 2.
Claims (5)
1. A method for generating a portrait image two-dimensional code is characterized by comprising the following steps:
step 1: taking a portrait image A, and compressing the portrait image A to obtain a compressed image with the pixel data size meeting the storage capacity size of the QR code;
step 2: extracting the pixel data of the compressed image obtained in the step to obtain a pixel data group of the compressed image;
and step 3: and encoding the pixel data group of the compressed image obtained in the step to generate the QR code.
2. The method for generating the portrait image two-dimensional code as claimed in claim 1, wherein the step 1 comprises the following specific steps:
step 1-1: preprocessing the portrait image A, wherein the specific preprocessing process is as follows:
step 1-1-1: setting the size of the portrait image A as m × n, defining the filtering value corresponding to each pixel point on the portrait image A as f (i, j), filtering the portrait image A to obtain the filtering value f (i, j) corresponding to each pixel point on the portrait image A, wherein,
m represents the width value of the portrait image A, n isShowing the length value of the portrait image A, i denotes the horizontal direction of the portrait image A, j denotes the vertical direction of the portrait image A, PijThe pixel value of the (i, j) intersection on the portrait image A is represented, f (i, j) represents the filtered value of the (i, j) intersection on the portrait image A, and the parameter Sigma is the width of f (i, j);
step 1-1-2: carrying out normalization processing on the portrait image A after filtering processing:
adding the filter values f (i, j) corresponding to each pixel point on the portrait image A obtained in the above step to obtain a filter sum value sum (f (i, j)) of the portrait image A, dividing the filter value f (i, j) corresponding to each pixel point by the filter sum value sum (f (i, j)), and obtaining a normalized convolution value g (i, j) as:
step 1-1-3: performing convolution processing on each pixel point in a Sigma area formed by taking an arbitrary point Q as the center in the portrait image A by using the convolution value g (i, j) obtained in the step, replacing the pixel value of the arbitrary point Q by the weighted average gray value in the Sigma area determined by the convolution processing, and forming a preprocessed portrait image after all the pixel points are replaced, wherein the pixel value g (i, j) is obtained in the step
Ap(i, j) represents the pixel value at the intersection of (i, j) in the portrait image A, AQ(i, j) represents each pixel point in a Sigma region centered on an arbitrary point Q;
step 1-2: and carrying out reduction processing on the preprocessed portrait image by utilizing the Gaussian pyramid principle to obtain a compressed image.
3. The method for generating a portrait image two-dimensional code according to claim 2, wherein the compressed image obtained in the step 1-2 is subjected to median filtering.
4. The method as claimed in claim 3, wherein the neighborhood window of the median filtering is selected to be 5 x 5.
5. The method for generating the portrait image two-dimensional code as claimed in claim 2, wherein the pixel data set of the compressed image extracted in step 2 is subjected to Huffman compression.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910732417.XA CN110610218B (en) | 2019-08-09 | 2019-08-09 | Portrait image two-dimensional code generation method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910732417.XA CN110610218B (en) | 2019-08-09 | 2019-08-09 | Portrait image two-dimensional code generation method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110610218A true CN110610218A (en) | 2019-12-24 |
CN110610218B CN110610218B (en) | 2022-09-13 |
Family
ID=68889844
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910732417.XA Active CN110610218B (en) | 2019-08-09 | 2019-08-09 | Portrait image two-dimensional code generation method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110610218B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6728317B1 (en) * | 1996-01-30 | 2004-04-27 | Dolby Laboratories Licensing Corporation | Moving image compression quality enhancement using displacement filters with negative lobes |
WO2015198983A1 (en) * | 2014-06-26 | 2015-12-30 | 京セラドキュメントソリューションズ株式会社 | Image processing apparatus |
CN107092821A (en) * | 2017-04-10 | 2017-08-25 | 成都元息科技有限公司 | A kind of distributed face authentication information generating method, authentication method and device |
CN109902242A (en) * | 2019-02-28 | 2019-06-18 | 尤尼泰克(嘉兴)信息技术有限公司 | A kind of picture storage method in two dimensional code |
-
2019
- 2019-08-09 CN CN201910732417.XA patent/CN110610218B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6728317B1 (en) * | 1996-01-30 | 2004-04-27 | Dolby Laboratories Licensing Corporation | Moving image compression quality enhancement using displacement filters with negative lobes |
WO2015198983A1 (en) * | 2014-06-26 | 2015-12-30 | 京セラドキュメントソリューションズ株式会社 | Image processing apparatus |
CN107092821A (en) * | 2017-04-10 | 2017-08-25 | 成都元息科技有限公司 | A kind of distributed face authentication information generating method, authentication method and device |
CN109902242A (en) * | 2019-02-28 | 2019-06-18 | 尤尼泰克(嘉兴)信息技术有限公司 | A kind of picture storage method in two dimensional code |
Non-Patent Citations (1)
Title |
---|
沈燕飞等: "基于非局部相似模型的压缩感知图像恢复算法", 《自动化学报》 * |
Also Published As
Publication number | Publication date |
---|---|
CN110610218B (en) | 2022-09-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Hui et al. | Fast and accurate single image super-resolution via information distillation network | |
EP3882822A1 (en) | Encoded pattern processing method and device , storage medium and electronic device | |
CN104573674B (en) | Towards the bar code recognition methods of real time embedded system | |
US10863206B2 (en) | Content-weighted deep residual learning for video in-loop filtering | |
CN108629744B (en) | Image enhancement method | |
CN110348264A (en) | A kind of QR image in 2 D code bearing calibration and system | |
CN112686812A (en) | Bank card inclination correction detection method and device, readable storage medium and terminal | |
CN107871145B (en) | Information transmission system based on packing carton image recognition | |
CN109598270B (en) | Method and device for identifying distorted characters, storage medium and processor | |
CN108647550A (en) | A kind of Quick Response Code fuzzy clustering recognition method and system based on machine learning | |
CN110830808A (en) | Video frame reconstruction method and device and terminal equipment | |
CN114881888A (en) | Video Moire removing method based on linear sparse attention transducer | |
CN110610218B (en) | Portrait image two-dimensional code generation method | |
Li et al. | Research and application of the EAN-13 barcode recognition on iphone | |
CN104346596A (en) | Identification method and identification device for QR (Quick Response) code | |
CN111898638B (en) | Image processing method, electronic device and medium fusing different visual tasks | |
CN110766117B (en) | Two-dimensional code generation method and system | |
CN110415175B (en) | Method for rapidly removing flat region coding mosaic | |
CN114519788A (en) | Image processing method, image processing device, electronic equipment and computer readable storage medium | |
CN104299223B (en) | Different-source image matching method based on Gabor coding | |
CN110866500A (en) | Face detection alignment system, method, device, platform, mobile terminal and storage medium | |
CN114511487A (en) | Image fusion method and device, computer readable storage medium and terminal | |
WO2020107376A1 (en) | Image processing method, device, and storage medium | |
CN116310105B (en) | Object three-dimensional reconstruction method, device, equipment and storage medium based on multiple views | |
CN114638849B (en) | DM two-dimensional code identification method, AGV positioning system and AGV |
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 |