CN115936047A - Encoding and decoding method of colorful Chinese-sensible code, electronic equipment and storage medium - Google Patents

Encoding and decoding method of colorful Chinese-sensible code, electronic equipment and storage medium Download PDF

Info

Publication number
CN115936047A
CN115936047A CN202211444369.2A CN202211444369A CN115936047A CN 115936047 A CN115936047 A CN 115936047A CN 202211444369 A CN202211444369 A CN 202211444369A CN 115936047 A CN115936047 A CN 115936047A
Authority
CN
China
Prior art keywords
color
code
original
information
block
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.)
Pending
Application number
CN202211444369.2A
Other languages
Chinese (zh)
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.)
SHENZHEN AEROSPACE INNOTECH CO Ltd
Original Assignee
SHENZHEN AEROSPACE INNOTECH CO Ltd
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 SHENZHEN AEROSPACE INNOTECH CO Ltd filed Critical SHENZHEN AEROSPACE INNOTECH CO Ltd
Priority to CN202211444369.2A priority Critical patent/CN115936047A/en
Publication of CN115936047A publication Critical patent/CN115936047A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the application provides a coding and decoding method of a colorful Chinese-sensible code, electronic equipment and a storage medium, and relates to the technical field of information coding and decoding. The method comprises the following steps: acquiring a color data code stream; generating an original code graph structure according to the stipulation of a preset symbol version, wherein the original code graph structure comprises an original information coding region, an original image searching graph and an original correction graph; filling colors of color blocks of the original image searching graph according to three preset primary colors to obtain a color image searching graph; carrying out color filling on the color bars of the original correction graph according to the three primary colors to obtain a color correction graph; filling a color data code stream into an original information coding region according to the specification of the symbol version to obtain a color information coding region; and updating the original code image structure according to the color image finding pattern, the color correction pattern and the color information coding region to obtain the color Chinese-sensible code. The embodiment of the application can improve the information capacity borne by the two-dimensional code and reduce the error rate.

Description

Encoding and decoding method of colorful Chinese-sensible code, electronic equipment and storage medium
Technical Field
The present application relates to the field of information encoding and decoding technologies, and in particular, to an encoding and decoding method for color hanxin codes, an electronic device, and a storage medium.
Background
With the increase of information, the traditional black-and-white bi-color two-dimensional code is difficult to bear more capacity of information, and therefore, in order to improve the information capacity of the two-dimensional code, related technologies have proposed encoding and decoding methods of color two-dimensional codes. However, in practical application, it is found that in the process of identifying the color two-dimensional code, because the color needs to be identified and judged, error codes are easy to occur, i.e. the error rate is high. Therefore, how to provide a method for encoding and decoding a two-dimensional code, which can improve the information capacity carried by the two-dimensional code and reduce the error rate, is a technical problem to be solved urgently.
Disclosure of Invention
The embodiment of the application mainly aims to provide a coding and decoding method of a color Chinese-sensible code, electronic equipment and a storage medium, which can improve the information capacity carried by a two-dimensional code and reduce the error rate.
In order to achieve the above object, a first aspect of an embodiment of the present application provides a method for encoding and decoding a color han-key code, where the method includes:
acquiring a color data code stream; the color data code stream is used for expressing: coded data obtained after the coded data is subjected to color coding;
generating an original code graph structure according to the stipulation of a preset symbol version, wherein the original code graph structure comprises an original information coding region and an original functional graph region, and the original functional graph region comprises an original image searching graph and an original correction graph;
filling colors of color blocks of the original image searching graph according to three preset primary colors to obtain a color image searching graph;
carrying out color filling on the color bars of the original correction graph according to the three primary colors to obtain a color correction graph;
filling the color data code stream into the original information coding region according to the provision of the symbol version to obtain a color information coding region;
and replacing the original image searching graph according to the color image searching graph, replacing the original correction graph by the color correction graph, and replacing the original information coding area by the color information coding area to obtain the color Hanxin code.
In some embodiments, the obtaining the color data code stream includes:
acquiring the data to be encoded, and determining a data encoding mode of the data to be encoded;
coding the data to be coded according to the data coding mode to obtain an information bit stream;
carrying out code word construction on the information bit stream according to the preset information code word number to obtain an information code word sequence;
carrying out color mapping on each information bit of the information code word sequence to obtain an information code color pixel point sequence;
the information code color pixel point sequence is blocked to obtain at least one information code color pixel point sequence block, and the information code word sequence is blocked to obtain at least one information code word sequence block; the information code color pixel point sequence block and the information code word sequence block have a corresponding relation;
carrying out error correction coding on the information code word sequence block according to the rule of a preset error correction level to obtain an original error correction code word sequence block;
carrying out color mapping on each information bit of the original error correction code word sequence block to obtain a color error correction code word sequence block;
splicing the information code color pixel point sequence block and the color error correction code word sequence block to obtain a color data code stream block;
and sequentially combining the color data code stream blocks to obtain the color data code stream.
In some embodiments, the three basic colors include red, green, and blue, the original finding pattern includes a first original color block, a second original color block, and a third original color block, and the color blocks of the original finding pattern are color-filled according to the preset three basic colors to obtain a color finding pattern, including:
filling the red color to the first original color block to obtain a first color block;
filling the green color to the second original color block to obtain a second color block;
filling the blue color to the third original color block to obtain a third color block;
and replacing the first original color block by the first color block, replacing the second original color block by the second color block, and replacing the third original color block by the third color block to obtain the color image finding graph.
In some embodiments, the three primary colors include red, green, and blue, the original correction pattern includes original color bars, and color filling is performed on the color bars of the original correction pattern according to the three primary colors to obtain a color correction pattern, including:
taking the red, the green and the blue as a group of filling colors, and sequentially filling the filling colors into the original color bars to obtain color bars;
and replacing the original color bar according to the color bar to obtain the color correction graph.
In some embodiments, after the obtaining the color hanseng code, the method further comprises:
preprocessing the color Chinese-sensible code to obtain a binary image;
finding a finding image in the binary image, and determining the position and the direction of a symbol;
extracting a color image finding graph of the color Chinese-sensible code according to the position and the direction of the symbol;
carrying out global color difference deviation correction processing on the color Chinese-sensible code according to the color image finding graph to obtain a primary color decoding image;
extracting a color correction graph of the color Chinese-sensible code according to the symbol position and the direction;
extracting a symbol version from the function information area of the binary image;
establishing a sampling grid according to the specification of the symbol version;
sampling the preliminary color decoding image according to a sampling network, and performing local color difference correction processing on pixel point sequences in each sampling grid according to the color correction graph to obtain a target color decoding image;
performing data extraction on the target color decoding image according to a data arrangement rule to obtain the color data code stream;
carrying out color matching on the color data code stream so as to adjust the color of each pixel point in the color data code stream to one of colors in a preset color range;
carrying out color restoration on the color data code stream to obtain an information code word sequence to be decoded of the color Chinese-sensible code;
and carrying out information decoding on the information code word sequence to be decoded to obtain the information carried by the color Chinese-sensible code.
In some embodiments, the performing color restoration on the color data code stream to obtain a to-be-decoded information code word sequence of the color hanzi code includes:
partitioning the color data code stream to obtain a plurality of information blocks, wherein each information block comprises an information code color pixel point sequence block and a color error correction code word sequence block;
carrying out color restoration on the information code color pixel point sequence block to obtain an information code word sequence block, and carrying out color restoration on the color error correction code word sequence block to obtain an original error correction code word sequence block;
carrying out error detection on the information code word sequence block according to the original error correction code word sequence block, if an error is found, carrying out error correction decoding processing on the information code word sequence block according to the regulation of a preset error correction level to obtain a new information code word sequence block;
and combining the information code word sequence blocks in sequence to obtain the information code word sequence to be decoded.
In some embodiments, the color finding pattern includes a first color block, a second color block and a third color block, and the performing global color deviation rectifying processing on the color hanxin code according to the color finding pattern to obtain a preliminary color decoded image includes:
calculating the average color difference value of all pixel points in the first color block to obtain the average red color difference;
calculating the average color difference value of all pixel points in the second color block to obtain the average green color difference;
calculating the average color difference value of all pixel points in the third color block to obtain the average blue color difference;
acquiring the color value of each pixel point of the color Chinese-sensible code in the color correction graph and the color information coding area, and recording the color value as an original pixel value;
performing color difference correction on the original pixel value according to the average red color difference, the average green color difference and the average blue color difference to obtain a preliminary pixel value;
and replacing the original pixel value of the color Hanxin code according to the preliminary pixel value to obtain the preliminary color decoding image.
In some embodiments, the pixel point sequence includes a plurality of pixel points, and the performing local color difference correction processing on the pixel point sequence in each sampling grid to obtain the target color decoded image includes:
acquiring the position and the preliminary pixel value of each pixel point;
determining a reference point from the color correction pattern according to the distance length between the position and the color correction pattern;
taking the reference point as a benchmark, extracting a reference pixel value from the color correction graph; the reference pixel values include a corrected red, a corrected green, and a corrected blue;
and performing color difference correction on the preliminary pixel value according to the corrected red color, the corrected green color and the corrected blue color to obtain the target color decoding image.
In order to achieve the above object, a second aspect of the embodiments of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory, and the processor implements the method of the first aspect when executing the computer program.
To achieve the above object, a third aspect of the embodiments of the present application proposes a storage medium storing a computer program, which when executed by a processor implements the method of the first aspect.
According to the encoding and decoding method of the color Chinese-sensible code, the electronic equipment and the storage medium, the color information coding region is obtained by filling the color data code stream into the original information coding region, and the bearing information capacity of the color Chinese-sensible code is improved. By replacing the original image searching graph with the color image searching graph and replacing the original correction graph with the color correction graph, on the basis of providing the functions of the position and the direction of the symbol, the chromatic aberration correction can be carried out during the decoding of the color Hanxin code, the identification accuracy of the color is improved, and the error rate of the color Hanxin code is reduced.
Drawings
Fig. 1 is a schematic diagram of an original code diagram of a han-xin code according to an embodiment of the present application;
fig. 2 is a flowchart of a method for encoding and decoding a color hanzi code according to an embodiment of the present application;
fig. 3 is a flowchart of step S101 in fig. 2;
fig. 4 is a flowchart of step S103 in fig. 2;
FIG. 5 is a schematic diagram of a color viewfinder graphic provided by an embodiment of the present application;
FIG. 6 is a schematic diagram of a color correction pattern according to an embodiment of the present application
Fig. 7 is a flowchart of a method for encoding and decoding a color hanzi code according to another embodiment of the present application;
fig. 8 is a flowchart of step S402 in fig. 7;
fig. 9 is a flowchart of step S405 in fig. 7;
FIG. 10 is a schematic diagram of local color rectification using color correction patterns according to an embodiment of the present application;
fig. 11 is a flowchart of step S408 in fig. 7;
fig. 12 is a schematic hardware structure diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application 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 present application and are not intended to limit the present application.
It should be noted that although functional blocks are partitioned in a schematic diagram of an apparatus and a logical order is shown in a flowchart, in some cases, the steps shown or described may be performed in a different order than the partitioning of blocks in the apparatus or the order in the flowchart. The terms first, second and the like in the description and in the claims, and the drawings described above, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the application.
At present, the mainstream two-dimensional code technology adopts a black and white graphic coding format, the carried effective information capacity is low, and even if the size and the density of the two-dimensional code are enlarged, the information capacity is difficult to greatly improve. Because each data bit of the color two-dimensional code adopts 8-bit information represented by 256 colors to replace 1-bit information represented by black and white colors of the Chinese-sensible code, the data capacity of symbols of different versions of the color two-dimensional code is increased exponentially compared with the data capacity of symbols of different versions of the Chinese-sensible code. For example: selecting a black-white two-dimensional code version 1 and an error correction level L4, wherein the data bit number is 200 and the information bit number is 72; selecting the color two-dimensional code version 1 and the error correction level L4, the data bit number is 200, and the information bit number is 8 72 . Because 256 colors are adopted to replace black and white two colors to express information, the information capacity of the color two-dimensional code is exponentially increased.
In the process of identifying the color two-dimensional code, because the color needs to be identified and judged, error codes are easy to appear, namely the error rate is high. Therefore, how to provide a method for encoding and decoding a two-dimensional code, which can improve the information capacity carried by the two-dimensional code and reduce the error rate, is a technical problem to be solved urgently.
The application provides color coding on the basis of Chinese-sensible code, and aims to provide a method for coding and decoding the color Chinese-sensible code, which can improve the carried information capacity and reduce the error rate.
The color Hanxin code is developed on the basis of the Hanxin code, in order to avoid the defect of color aberration correction capability of a scanning terminal such as a mobile phone and the like, the color Hanxin code is described by using the condition that an RGB color mode is 8 bits (bit) and 256 reference colors are used, but the principle used by the color Hanxin code is also suitable for the use of wider color types.
Referring to fig. 1, fig. 1 is a schematic diagram of an original code diagram of a han-xin code according to an embodiment of the present application. As shown in fig. 1, the structure of the white-black chinese-sensible code symbol includes: an information encoding region, a functional information region, and a functional graphic region. The information encoding area is an area for encoding the information content and the error correction code word thereof. The function information area is used for recording a data bit stream of a symbol version, an error correction level, and a mask type. The functional graphic area is used for positioning and identifying the characteristics of the bar code symbols. The functional graphic area comprises a finding graphic, a correcting graphic, a functional information graphic, an auxiliary correcting graphic and the like. The image finding pattern is used for determining the symbol position and direction of the Chinese-sensible code. The correction graph is used for determining the position of the bar code matrix module and assisting the correction graph to be positioned at the edge of the bar code symbol, and plays a role of synchronizing the modules in the symbol.
The coding and decoding method of the color Chinese-sensible code mainly improves the image searching graph, the correction graph and the information coding area, and other areas such as the functional information area, the auxiliary correction graph and the like are similar to the processing process of the Chinese-sensible code and are not described more.
The encoding and decoding method of the color Chinese-character encoding and decoding method provided by the embodiment of the application is applied to a server side, and can also be software running in a terminal or the server side. The server side can be configured into an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, and cloud servers for providing basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud functions, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN (content delivery network) and big data and artificial intelligence platforms; the software may be an application of a coding and decoding method for realizing color Chinese-character encoding, and the like, but is not limited to the above form.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: server computers, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, distributed computing environments that include any of the above systems or devices, and the like. 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 of the present application provide a method for encoding and decoding a color hanxin code, an electronic device, and a storage medium, which are described in detail with reference to the following embodiments, first, the method for encoding and decoding a color hanxin code in the embodiments of the present application is described.
Fig. 2 is an alternative flowchart of a method for encoding and decoding a color hanzi code according to an embodiment of the present application, which may include, but is not limited to, steps S101 to S106.
Step S101, acquiring a color data code stream; the color data stream is used to represent: coded data obtained after the coded data is subjected to color coding;
step S102, generating an original code graph structure according to the stipulation of a preset symbol version, wherein the original code graph structure comprises an original information coding region and an original function graph region, and the original function graph region comprises an original image searching graph and an original correction graph;
step S103, filling colors of color blocks of the original image searching graph according to three preset primary colors to obtain a color image searching graph;
step S104, filling colors of the color bars of the original correction graph according to the three primary colors to obtain a color correction graph;
step S105, filling a color data code stream into the original information coding region according to the provision of the symbol version to obtain a color information coding region;
and S106, replacing the original image searching graph with the color image searching graph, replacing the original correction graph with the color correction graph, and replacing the original information coding area with the color information coding area to obtain the color Chinese-sensible code.
In steps S101 to S106 shown in the embodiment of the present application, the color information coding region is obtained by filling the color data code stream into the original information coding region, so that the information carrying capacity of the color hanxin code is improved. By replacing the original image searching graph with the color image searching graph and replacing the original correction graph with the color correction graph, on the basis of providing the functions of the position and the direction of the symbol, the chromatic aberration correction can be carried out during the decoding of the color Hanxin code, the identification accuracy of the color is improved, and the error rate of the color Hanxin code is reduced.
In step S101 of some embodiments, the color data stream is used to represent: and the coded data is obtained after the coded data is subjected to color coding. Specifically, the color coding of the embodiment of the present application includes: forming the data to be coded into an information bit stream, reconstructing an information code word sequence, and finally carrying out color coding to obtain a color data code stream. The color coding process is to convert the binary data code stream into 256 color data code streams.
It should be noted that the data to be encoded in the information encoding region is data carrying valid information, and according to actual needs, the data to be encoded may be valid information contained in an article, a picture, or a sound recording. And according to the mode indication, the effective information is coded according to the specified data coding mode (such as a digital mode, a Text mode, a common Chinese character 1 region and the like), and the coding process of each mode is consistent with the Chinese character-letter code. Each mode encoding forms a bitstream consisting of: a mode indicator; a character count indicator; an encoded information bit stream; a mode end symbol. And connecting the bit streams formed by coding the modes end to obtain the information bit stream. The content composition of the information bit stream coded by each mode of the embodiment of the application is consistent with the Chinese-sensible code.
Specifically, referring to fig. 3, in an embodiment, step S101 specifically includes, but is not limited to, the following steps:
step S201, acquiring data to be encoded, and determining a data encoding mode of the data to be encoded;
step S202, encoding data to be encoded according to a data encoding mode to obtain an information bit stream;
step S203, carrying out code word construction on the information bit stream according to the preset information code word number to obtain an information code word sequence;
step S204, performing color mapping on each information bit of the information code word sequence to obtain an information code color pixel point sequence;
step S205, the information code color pixel point sequence is blocked to obtain at least one information code color pixel point sequence block, and the information code word sequence is blocked to obtain at least one information code word sequence block; an information code color pixel point sequence block and an information code word sequence block have a corresponding relation;
step S206, carrying out error correction coding on the information code word sequence block according to the preset error correction level to obtain an original error correction code word sequence block;
step S207, performing color mapping on each information bit of the original error correction codeword sequence block to obtain a color error correction codeword sequence block;
step S208, splicing the information code color pixel point sequence block and the color error correction code word sequence block to obtain a color data code stream block;
step S209, sequentially merge the color data code stream blocks to obtain a color data code stream.
It should be noted that the data encoding modes include: a digit mode, a Text mode, a binary byte mode, a common Chinese character 1 region mode, a common Chinese character 2 region mode and an ECI mode.
Digital mode: the input digit character sequence is grouped in a mode of grouping every three digit characters, decimal numeric values corresponding to 3 digit characters in each group (the last group can be less than 3 digits) are converted into 10-digit binary system (namely (0000000000) bin ~(1111100111) bin ) As an encoded representation thereof. The last group of the grouped number charactersThe correspondence between the number and the end symbol is shown in table 1.
Number of last group of digits Ending symbol
1 (1111111101) bin
2 (1111111110) bin
3 (1111111111) bin
TABLE 1
Text mode: the common symbols with byte values ranging from OOHEX to 1BHEX and 20HEX to 7FHEX are encoded by a 6-bit binary sequence. The Text mode includes two sub-modes: a Text l mode and a Text2 mode. The Text mode encoding ranges are capital English letters (A-Z), lowercase English letters (a-Z) and numbers (0-9), and the encoding and mapping rules are shown in Table 2. The Text2 sub-mode encoding range is other characters except upper and lower case English letters and numbers, and the encoding mapping rule is shown in Table 3. Code value (111110) bin To indicate the transition between the two sub-modes. Code value (111111) bin Is the mode terminator for Text mode. After entering the Text mode, the default coding sub-mode is the Text1 sub-mode. Reading in the characters to be coded in sequence, and if the characters are in the Text1 sub-mode, coding the characters according to the coding method shown in the table 2; if the character is in the Text2 sub-mode, it should be applied first (111110) bin Convert the Text1 sub-mode to the Text2 sub-mode, and then press it as in Table 3The coding method shown performs the coding. By analogy, the following steps are all applied firstly as long as the condition that the sub-mode needs to be converted is met (111110) bin And converting the sub-modes, and then coding according to the coding method in the corresponding sub-mode until the character sequence is ended. Adding a Text mode end-of-sequence (111111) to the resulting coded binary bit stream bin The encoding of the mode is ended.
It should be noted that, table 2 and table 3 only show the encoding process of a part of characters, but not limited thereto, and the encoding processes of other symbols are similar and not described much.
Character(s) Byte value (10 system) Encoding Character(s) Byte value (10 system) Encoding
0 48 (000000) bin V 86 (011111) bin
1 49 (000001) bin W 87 (100000) bin
2 50 (000010) bin X 88 (100001) bin
3 51 (000011) bin Y 89 (100010) bin
4 52 (000100) bin Z 90 (100011) bin
TABLE 2
Character(s) Byte value (10 system) Coding Character(s) Byte value (10 system) Encoding
NUL 0 (000000) bin # 35 (011111) bin
SOH 1 (000001) bin $ 36 (100000) bin
STX 2 (000010) bin 37 (100001) bin
ETX 3 (000011) bin & 38 (100010) bin
EOT 4 (000100) bin 39 (100011) bin
TABLE 3
Binary byte pattern is used to represent binary data in any form. The binary byte pattern indicator, the counter symbol and the binary data sequence are concatenated to form an information bit stream of a binary byte encoding pattern. The counter is a 13-bit binary sequence and represents the number of bytes of input binary data.
It should be noted that other types of data encoding modes may specifically refer to the encoding standard of the han-xin code, and are not additionally described in the embodiments of the present application.
Embodiments of the present application may support representation of any hybrid data sequence of the above data coding modes. The mixed mode encoding rules are as follows: for the original data, it can be converted from one mode to another mode for information coding representation, and its structure is shown in table 4.
Figure BDA0003949455880000081
TABLE 4
In addition, the numbers and the common Chinese characters can be coded by adopting a plurality of data coding modes. In order to achieve the effect of optimal coding, the specific method for selecting the data coding mode is as follows:
(1) For digital information, if the previous coding mode is a coding mode other than the Text mode, the digital coding mode is adopted for coding. If the previous encoding mode was a Text mode:
(1) if the former coding mode is a Text1 sub-mode, when the length of the digital information to be coded is greater than 11 digital characters, the Text coding mode is ended, and the digital coding mode is adopted for coding; otherwise, the coding is still carried out according to the Text coding mode. (2) If the former coding mode is a Text2 sub-mode, when the length of the digital information to be coded is greater than 8 digital characters, the Text coding mode is ended, and the digital coding mode is adopted for coding; otherwise, the coding is still carried out according to the Text coding mode.
(2) For common Chinese characters, the mixed coding rule is as follows:
(1) and if the former coding mode is a non-double-byte zone coding mode, the common Chinese characters in the common Chinese character 1 zone are coded by adopting the common Chinese character 1 zone coding mode. If the former coding mode is a double-byte area coding mode, when the length of the Chinese character in the common Chinese character area 1 to be coded is larger than 11 characters, the Chinese character is coded by adopting the common Chinese character area 1 coding mode; otherwise, encoding is still performed according to the double-byte encoding mode. (2) And if the former coding mode is a non-double-byte zone coding mode, the Chinese characters and the characters in the common Chinese character zone 2 are coded by adopting the common Chinese character zone 2 coding mode. If the former coding mode is a double-byte area coding mode, when the information length of the common Chinese character 2 area to be coded is more than 11 characters, the common Chinese character 2 area coding mode is adopted for coding; otherwise, encoding is still performed according to the double-byte encoding mode.
In step S203 of some embodiments, the information bit stream is subjected to codeword construction according to a preset number of information codewords, so as to obtain an information codeword sequence. Specifically, the method comprises the following steps: the number of information codewords is determined according to the corresponding error correction level and the determined symbol version in the data analysis. Then according to the number of information code words, the information bit stream is converted into an information code word sequence in a mode that every 8 bits of the information bit stream correspond to one code word, and when the information is insufficient, filling bits are used for complementing.
In step S204 of some embodiments, color mapping is performed on each information bit of the information code word sequence to obtain an information code color pixel point sequence. Specifically, the method comprises the following steps: the color mapping process is a unique encoding process in the embodiment of the application, and aims to translate binary information code streams into 256-color information code color pixel point sequences. This step is performed as the last step of information encoding after the two processes of forming the information bit stream and constructing the information codeword sequence are performed. The embodiment of the application defaults to use 256 colors, the color coding of each information bit is 8 bits of data, and the coding of each color is shown in table 5.
RGB value Original color numbering Color coding of color Chinese-sensible code
rgb(0,0,0) 0 #00
rgb(128,0,0) 1 #01
rgb(0,128,0) 2 #02
rgb(128,128,0) 3 #03
rgb(0,0,128) 4 #04
rgb(128,0,128) 5 #05
rgb(0,128,128) 6 #06
rgb(188,188,188) 250 #FA
rgb(198,198,198) 251 #FB
rgb(208,208,208) 252 #FC
rgb(218,218,218) 253 #FD
rgb(228,228,228) 254 #FE
rgb(238,238,238) 255 #FF
TABLE 5
Referring to table 5, in one example, the different colors are numbered, resulting in original color numbers of 0 to 255; and coding the original color number to obtain the color code of the color Chinese-sensible code. It should be noted that different colors refer to different RGB values, for example, a color with RGB value RGB (0,0,0) and corresponding original color number 0, so that the corresponding color code is #00. And the RGB value is RGB (128,0,0) color, the corresponding original color number is 1, and the corresponding color code is #01. Additionally, RGB values may also be represented in hexadecimal, e.g., RGB (0,0,0) for #000000, RGB (128,0,0) for #800000.
It should be noted that the color numbers of the embodiment of the present application include 0 to 255, and table 5 only shows the color mapping processes of the color numbers 0 to 6 and 250 to 255, but not limited thereto, and the color mapping processes of other color numbers are similar to the color codes 0 to 6 and 250 to 255, and are not described much.
In steps S205 to S207 of some embodiments, error correction coding is mainly implemented. Specifically, the information code color pixel point sequence is blocked to obtain at least one information code color pixel point sequence block, and the information code word sequence is blocked to obtain at least one information code word sequence block; the information code color pixel point sequence block and the information code word sequence block have a corresponding relation; carrying out error correction coding on the information code word sequence block according to the rule of a preset error correction level to obtain an error correction code word sequence block; and carrying out color mapping on each information bit of the error correction code word sequence block to obtain a color error correction code word sequence block.
It should be noted that, to generate the error correction coding of the color han-xin code, firstly, according to the error correction coding method of the han-xin code, according to the symbol version and the error correction level of the han-xin code, the information codeword sequence is divided into blocks, and a corresponding error correction codeword sequence is generated according to the blocks, thereby completing the error correction coding. Finally, the error correction coding is converted into color coding. Since the information capacity of the color hanxin code is far greater than the specification of the hanxin code, because more effective information is carried by the color, how to segment the color hanxin code during error correction coding is complicated. Specifically, first, two processes of forming an information bit stream and constructing an information codeword sequence are performed according to the Chinese-sensible code rule during information encoding, so that the information codeword sequence is obtained. And then, continuously executing a color coding process on the information code word sequence to obtain an information code color pixel point sequence. When in error correction coding, firstly, the information code color pixel point sequence is divided into blocks according to the Chinese-sensible code symbol version and the error correction grade, then, according to the information code word sequence block corresponding to each information code color pixel point sequence block, a corresponding error correction code word sequence block is generated according to the Chinese-sensible code rule, and then, all the blocks are spliced into a complete error correction code word sequence. And after color coding is carried out on the complete error correction code word sequence, the complete error correction code word sequence is converted into a color error correction code pixel point sequence.
The error correction code word generation of the embodiment of the application is consistent with the Chinese-sensible code, the information code word sequence is divided into a corresponding number of blocks, and each block respectively calculates the error correction code word and adds the error correction code word to the information code word. The calculation formula of the error correction code word is consistent with the Chinese sensible code. The generated black and white error correction code word is reversely converted into a color error correction code word according to the color coding process of the table 5, namely the error correction code of each byte (8 bit) is reduced into the color of one data bit (1 bit) according to the 256 color coding value of the color Hanxin code, and finally the capacity is reduced to 1/8 m (m is the original capacity bits number). The symbol padding bits (e.g., black, corresponding to code # 00) are used to complement the symbol when not filled to one codeword width.
In steps S208 to S209 of some embodiments, the information code color pixel point sequence block and the color error correction codeword sequence block are spliced to obtain a color data code stream block; and combining the color data code stream blocks in sequence to obtain the color data code stream. Specifically, the information code color pixel point sequence and the color error correction code word sequence are combined into a color data code word sequence block, and each color data code word sequence block is combined in sequence to form a final color data code stream.
In one example, the final color data stream is constructed as follows: partitioning the information codeword sequence according to version and error correction level; calculating an error correction codeword sequence for each block; converting the sequence of error correction codewords into a sequence of color error correction codewords according to a color coding process; sequentially connecting each information code color pixel point sequence block and each color error correction code word sequence block into a color data code stream: the color data code stream of the information code color pixel dot sequence block of the information block 1, the color error correction codeword sequence block of the error correction block 1, the information code color pixel dot sequence block of the information block 2, the color error correction codeword sequence block of the error correction block 2, the information code color pixel dot sequence block of the information block 3, the color error correction codeword sequence block … … of the information block 3, the information code color pixel dot sequence block of the information block n, and the color error correction codeword sequence block of the error correction block n.
The number, the position and the shape of the image searching graphs of the color Hanxin code are consistent with those of the Hanxin code, but color blocks in each image searching graph are filled with base colors. The color image-finding pattern adopts color blocks of three primary colors to replace a black and white pattern of the Chinese-sensible code, and aims to solve the problems of global chromatic aberration generated by printing equipment in the process of generating the color Chinese-sensible code and global chromatic aberration generated by environmental light and the like in the process of recognizing and reading the color Chinese-sensible code. In the decoding process, the global chromatic aberration correction calculation is carried out on the color correction graph and the color information coding region according to the chromatic aberration average value of the three primary colors read by the four-corner image searching graphs. The three primary colors of the embodiment of the present application include red (RGB value FF 0000), green (RGB value 00FF 00), and blue (RGB value 0000 FF).
Referring to fig. 4, in an embodiment, the three primary colors include red, green, and blue, the original viewfinder pattern includes a first original color block, a second original color block, and a third original color block, and step S103 includes, but is not limited to, the following steps:
step S301, filling red color to a first original color block to obtain a first color block;
step S302, filling the green color to a second original color block to obtain a second color block;
step S303, filling the blue color to a third original color block to obtain a third color block;
and step S304, replacing the first original color block by the first color block, replacing the second original color block by the second color block, and replacing the third original color block by the third color block to obtain the color image finding graph.
Specifically, as shown in fig. 5, fig. 5 is a schematic diagram of a color finding pattern provided in the embodiment of the present application. The first original color block is an outermost color block and is represented by red, the second original color block is a middle color block and is represented by green, and the third original color block is an innermost color block and is represented by blue.
The shape of the color correction graph of the color Hanxin code of the embodiment of the application is consistent with the definition of the Hanxin code, and the color correction graph is a group of stepped correction folding lines. The correction fold line is 1 module wide color bar on the left boundary and the lower boundary of the color Hanxin code symbol, and consists of adjacent 1 module wide color and white color bars on other corresponding positions of the color Hanxin code symbol, and the principle that the color bar is on the upper part and the color bar is on the lower part and the color bar is on the right part and the white bar is on the left part is followed.
In an embodiment, the three primary colors include red, green and blue, the original correction pattern includes original color bars, and the step S104 includes, but is not limited to, the following steps:
taking red, green and blue as a group of filling colors, and sequentially filling the filling colors into the original color bars to obtain color bars;
and replacing the original color bars according to the color bars to obtain a color correction graph.
In one example, as shown in fig. 6, fig. 6 is a schematic diagram of a color correction pattern provided in an embodiment of the present application. The color bars are respectively represented by the alternate combination of points of three primary colors of red, green and blue. Each broken line starts with a red point, is sequentially a green point and a blue point, and repeats the red point, the green point and the blue point; the color alternating sequence continues when the polyline turns are encountered until the polyline ends.
Referring to fig. 7, in an embodiment, after step S106, the method for encoding and decoding color hanxin codes further includes, but is not limited to, the following steps:
step S401, preprocessing the color Chinese-sensible code to obtain a binary image; searching an image searching graph in the binary image, and determining the position and the direction of a symbol;
step S402, extracting a color image searching graph of the color Chinese-sensible code according to the position and the direction of the symbol; carrying out global chromatic aberration correction processing on the color Chinese-sensible code according to the color image finding graph to obtain a primary color decoding image;
step S403, extracting a color correction graph of the color Chinese-sensible code according to the symbol position and the direction;
step S404, extracting a symbol version from the function information area of the binary image; establishing a sampling grid according to the specification of the symbol version;
step S405, sampling the preliminary color decoded image according to a sampling network, and performing local color difference correction processing on a pixel point sequence in each sampling grid according to a color correction graph to obtain a target color decoded image;
step S406, extracting data of the target color decoding image according to a data arrangement rule to obtain a color data code stream;
step S407, color matching is carried out on the color data code stream, so that the color of each pixel point in the color data code stream is adjusted to be one of colors in a preset color range;
step S408, color reduction is carried out on the color data code stream to obtain a code word sequence of information to be decoded of the color Chinese-sensible code;
step S409, information decoding is carried out on the information code word sequence to be decoded, and information carried by the color Chinese-sensible code is obtained.
In the steps S401 to S409 illustrated in the embodiment of the present application, since the color hanxin code is a color two-dimensional code, it is difficult to directly identify the color hanxin code. Therefore, the color Chinese-sensible code is converted into a binary image, and the symbol position and the direction of the color Chinese-sensible code are convenient to determine. Then extracting color image finding pattern and color correcting pattern from the color Chinese-sensible code according to the symbol position and direction. It should be noted that, since the color of each symbol needs to be identified in the process of decoding the color hanzi code, and different devices have different color identification standards, it is easy to cause identification errors. Therefore, the embodiment of the application provides that the color image finding graph is used for carrying out global chromatic aberration correction on the color Chinese-sensible code, and the color correction graph is used for carrying out local chromatic aberration correction on the color Chinese-sensible code, so that the identification accuracy of colors can be improved, and the decoding success rate is improved. In addition, considering the case that the color RGB values of the color data stream may not match the 256-color range after the global color deviation correction and the local color deviation correction, it is necessary to match the color RGB values to one of the closest 256 colors for this purpose. Color restoration is performed on the color data code stream to obtain an information code word sequence, and it should be noted that color restoration is the reverse process of color mapping. And finally, carrying out information decoding on the information code word sequence to obtain the information carried by the color Chinese-sensible code.
Referring to fig. 8, in an embodiment, the color finding pattern includes a first color block, a second color block, and a third color block, and the step S402 includes, but is not limited to, the following steps:
step S501, calculating the average color difference value of all pixel points in the first color block to obtain the average red color difference;
step S502, calculating the average value of the chromatic aberration of all pixel points in the second color block to obtain the average green chromatic aberration;
step S503, calculating the average color difference value of all pixel points in the third color block to obtain the average blue color difference;
step S504, obtaining the color value of each pixel point of the color Chinese-sensible code in the color correction graph and the color information coding area, and recording the color value as an original pixel value;
step S505, performing color difference correction on the original pixel value according to the average red color difference, the average green color difference and the average blue color difference to obtain a preliminary pixel value;
step S506, replacing the original pixel value of the color Hanxin code according to the preliminary pixel value to obtain a preliminary color decoding image.
In steps S501 to S506 illustrated in the embodiment of the present application, first, a color difference average value of all pixel points in three color patches, namely red, green, and blue, of each color finding pattern in four corners of the color han-xin code is calculated. For example, after calculation, if the average RGB color value of the red color block (first color block) in the upper left corner finding pattern is FD020A, the average RGB color value of the green color block (second color block) is 07F809, and the average RGB color value of the blue color block (third color block) is 1201FA, the average color difference of the three primary colors is calculated as:
Δ ER upper left = (FD-FF) + (07-00) + (12-00) =17H;
Δ EG Upper left = (02-00) + (F8-FF) + (01-00) = -04H;
Δ EB upper left = (0A-00) + (09-00) + (FA-FF) =0EH.
And sequentially calculating three primary color differences of the image-finding patterns of the other three angles: right upper delta ER, right upper delta EG, right upper delta EB, left lower delta ER, left lower delta EG, left lower delta EB, right lower delta ER, right lower delta EG, and right lower delta EB.
Then, the color difference average of the three primary colors of the four corners is calculated:
Δ ER = ([ Delta ER ] upper left + [ Delta ER ] upper right + [ Delta ER ] lower left + [ Delta ER ] lower right)/4;
Δ EG = ([ Delta EG upper left + [ Delta ] EG upper right + [ Delta ] EG lower left + [ Delta ] EG lower right)/4;
Δ EB = ([ delta ] ER upper left + [ delta ] EB upper right + [ delta ] EB lower left + [ delta ] EB lower right)/4.
And finally, performing color difference deviation correction processing of three primary colors on RGB color values of all pixel points of the two regions of the color correction graph and the color information coding region: r new = rred- # ER; gchin = gcold- Δ EG; bnew = bnold- # EB. Through the steps, the global chromatic aberration correction processing of the colorful Chinese-sensible codes is completed.
Referring to fig. 9, in an embodiment, the pixel point sequence includes a plurality of pixel points, and the step S405 specifically includes, but is not limited to, the following steps:
step S601, acquiring the position and the preliminary pixel value of each pixel point;
step S602, determining a reference point from the color correction pattern according to the distance length between the position and the color correction pattern;
step S603, taking the reference point as a reference, extracting a reference pixel value from the color correction graph; the reference pixel values include a corrected red, a corrected green, and a corrected blue;
and step S604, performing color difference correction on the preliminary pixel value according to the corrected red, the corrected green and the corrected blue to obtain a target color decoding image.
In the steps S601 to S604 illustrated in the embodiment of the present application, the color correction graph of the color hanxin code uses a line graph formed by alternating color bars of three primary colors to replace a black-and-white line graph of the hanxin code, so as to solve the problem that the color reading of the information coding region is affected by local shadows, such as finger shadows, leaf shadows, and the like, generated on the color hanxin code due to ambient light shielding and the like in the process of reading the color hanxin code. And according to the color difference of the three primary colors read by the color correction graph with the closest linear distance of the data bit to be decoded of the information coding region to be read, performing local color difference deviation correction calculation on the color of the information coding region.
In one example, for example, a local color deviation correction calculation is required at a certain point X (shown in FIG. 10) of the information encoding region. First, the spatial range of the color Hanxin code and the reference of the X, Y coordinate system have been confirmed from the color finding patterns of the four corners. And the position of each segment of the polyline of the color correction graph is already recognized and read. At this time, the X point extends forward and backward along the X axis and the Y axis until intersecting with a certain broken line of the calibration graph or reaching the two-dimensional code boundary, which is point a, point B, point C and point D in fig. 10. The lengths of the line segments XA, XB, XC, XD are calculated, and the intersection point where the length of the line segment is the shortest is taken, which is point B in fig. 10, and this indicates that the point X is closest to the point B. Extending left and right along the X-axis at point B, the nearest set of R, G, B alternating sets of three primaries are found, which in fig. 10 are the locations of the noted RGB. Calculating the color difference of the set of three primary colors of RGB, and assuming that the RGB values of the three points are F20A03HEX, 13ED02HEX and 0A10F8HEX respectively, then:
△ER=(F2-FF)+(13-00)+(0A-00)=0AHEX;
△EG=(0A-00)+(ED-FF)+(10-00)=09HEX;
△EB=(03-00)+(02-00)+(F8-FF)=-02HEX。
and finally, carrying out local chromatic aberration adjustment on the color of the X point, and assuming that the RGB value of the X point is 2EB683HEX, carrying out the adjustment as follows: RX new = RX old- Δ ER =2E-0a =24hex; GX new = GX old- Δ EG = B6-09= adhex; BX new = BX old- Δ EB =83+02=85hex; through the steps, after adjustment, the RGB value of the X point is 24AD85HEX.
In an embodiment, step S407 specifically includes: assuming that the RGB value of the color to be decoded is AABBCCHEX, one of the RGB values of 256 colors is xxyyyzhex, and the calculation formula of the difference (D value) is as follows: d = (AA-XX) 2 +(BB-YY) 2 +(CC-ZZ) 2 . And circularly calculating the matching degree of the color to be decoded and all 256 colors, selecting the color with the lowest difference degree (D value), and restoring the color to be decoded into the color code of the corresponding color Hanxin code according to the table 5.
Referring to fig. 11, in an embodiment, step S408 specifically includes, but is not limited to, the following steps:
step S701, partitioning a color data code stream to obtain a plurality of information blocks, wherein each information block comprises an information code color pixel point sequence block and a color error correction code word sequence block;
step S702, the color of the information code color pixel point sequence block is restored to obtain an information code word sequence block, and the color of the color error correction code word sequence block is restored to obtain an original error correction code word sequence block;
step S703, carrying out error detection on the information code word sequence block according to the original error correction code word sequence block, if an error is found, carrying out error correction decoding processing on the information code word sequence block according to the rule of a preset error correction level to obtain a new information code word sequence block;
step S704, sequentially combining the information codeword sequence blocks to obtain an information codeword sequence to be decoded.
In steps S701 to S704 shown in the embodiment of the present application, the information code color pixel point sequence blocks of the information blocks 1 to N and the color error correction code word sequence blocks of the error correction blocks 1 to N are first decomposed from the color data code stream. And restoring the information code color pixel point sequence blocks of the information blocks 1 to N into hexadecimal information code word sequence blocks of the information blocks 1 to N, and restoring the color error correction code word sequence blocks of the error correction blocks 1 to N into hexadecimal original error correction code word sequence blocks of the error correction blocks 1 to N. And finally, carrying out error detection on the information code word sequence according to the specification of the Chinese-sensible code, and carrying out error correction decoding processing if errors are found so as to finally obtain the information code word sequence to be decoded.
It should be noted that the code pattern placement of the color hanxin code in the embodiment of the present application includes the placement of the functional patterns and the arrangement of data, which are completely consistent with the black and white hanxin code. In addition, since the hanxin code is a black-and-white two-dimensional code, masking is required in order to avoid continuous large areas of light or dark regions. The color Hanxin code of the application adopts 256 colors, and the probability of the same color in a continuous large area is extremely low, so that the color Hanxin code only keeps one mask scheme: without a mask. The placement of the functional information of the color Chinese-sensible code is completely consistent with the Chinese-sensible code, and the functional information is still stored by adopting black, white and two colors. The color Chinese-sensible code has the advantages that the symbol size, the character recognition and reading of people and the provision of the symbol making guide rule are completely consistent with the Chinese-sensible code.
It should be noted that the decoding is the inverse process of encoding, and the decoding process of the black-white chinese-sensible code includes image preprocessing, symbol image searching and symbol positioning, functional information decoding, establishing a sampling grid, removing a mask, recovering a data codeword sequence, error correction decoding, information decoding and the like. Compared with the prior art, the decoding process of the color Hanxin code adds three processes of global color difference correction, local color difference correction and color matching, cancels the mask removing process, and has the following specific comparison results:
1) Image preprocessing: the Chinese-sensible code converts an image into a binary image consisting of a series of dark and light pixels. The color Chinese character-Xin code reserves the process as a basis for analyzing the image searching graph, the image searching graph separator, the functional information graph, the correction graph and the auxiliary correction graph, and also reserves the color Chinese character-Xin code image so as to extract the color information of the color image searching graph, the color correction graph and the color information coding region;
2) Symbol seeking and symbol positioning: the Chinese-sensible code looks for the image-searching pattern in the binary image to determine the position and direction of the symbol. The color hanxin code preserves this process.
3) And (3) correcting global chromatic aberration: the process is newly added to the colorful Chinese-sensible code. Extracting red, green and blue three primary colors from color image finding graphs at four corners of the color image, and performing correction processing on the global color difference of the two-dimensional code by calculating the color difference of the four corners;
4) Decoding the function information: the Chinese-sensible code extracts function information in a function information area of the binary image and determines the version, the error correction level and the mask scheme of the symbol. The colorful Chinese-sensible code is consistent with the Chinese-sensible code in the process;
5) Establishing a sampling grid: the Chinese-sensible code establishes a sampling grid according to the symbol version of the binary image and other information, and samples the symbol. The color Chinese-sensible code establishes a sampling grid according to the symbol version of the binary image and other information, and samples the symbols of the color image. In the process, the color Chinese-sensible code simultaneously applies a binary image and a color image, and the Chinese-sensible code only applies the binary image;
6) Removing the mask: carrying out XOR processing on the modules of the coding region by using a mask pattern (the mask scheme is obtained from the functional information) of the Chinese-sensible code, and removing the mask; the color hanxin code uses no mask (mask scheme =0 in the functional information, meaning no mask), and there is no such process;
7) Local chromatic aberration correction: the process is newly added to the colorful Chinese-sensible code. After the sampling grids of the color symbols are determined, local color difference correction processing is executed on the pixel point sequences in each grid;
8) Recovering the data codeword sequence: the Chinese-sensible code recovers the data code word sequence according to the data arrangement rule. And recovering the color data code stream according to the data arrangement rule by the color Hanxin code.
9) Color matching: the process is newly added to the colorful Chinese-sensible code. Restoring the color of each pixel point in the color data code stream into one of the 256 colors which are most matched;
10 Error correction decoding: the Chinese-sensible code carries out error detection on the data code word sequence, and if errors are found, error correction decoding processing is carried out. The color Chinese-sensible code is added with two preposed steps, firstly, the color pixel point sequence of the information codes of the information blocks 1-N and the color error correction code word sequence of the error correction blocks 1-N are decomposed from the color data code stream, then the color pixel point sequence of the information codes of the information blocks 1-N is restored to the hexadecimal information code word sequence of the information blocks 1-N, and the color error correction code word sequence of the error correction blocks 1-N is restored to the hexadecimal error correction code word sequence of the error correction blocks 1-N. And finally, carrying out error detection on the information code word sequence according to the specification of the Chinese-sensible code, and carrying out error correction decoding processing if an error is found.
11 Information decoding: the Chinese-sensible code carries out information decoding on the information code word sequence to recover the original information. The process of the color Hanxin code is completely consistent with the Hanxin code.
In summary, the color coding is added on the basis of the black-white two-dimensional code, and exponential amplification of effectively carried information is realized. Meanwhile, the basic 256-color scheme is adopted, so that the two-dimensional code generated by printing and the code scanning reading color are easier, and the error rate is reduced.
An embodiment of the present application further provides an electronic device, where the electronic device includes: the device comprises a memory, a processor, a program stored on the memory and capable of running on the processor, and a data bus for realizing connection communication between the processor and the memory, wherein the program realizes the encoding and decoding method of the color Chinese character codes when being executed by the processor. The electronic equipment can be any intelligent terminal including a tablet computer, a vehicle-mounted computer and the like.
Referring to fig. 12, fig. 12 illustrates a hardware structure of an electronic device according to another embodiment, where the electronic device includes: the processor 801 may be implemented by a general-purpose CPU (central processing Unit), a microprocessor, an application Specific integrated circuit (ASI C), or one or more integrated circuits, and is configured to execute a relevant program to implement the technical solution provided in the embodiment of the present application; the Memory 802 may be implemented in a Read On y Memory (ROM), a static Memory device, a dynamic Memory device, or a Random Access Memory (RAM). The memory 802 may store an operating system and other application programs, and when the technical solution provided in the embodiments of the present specification is implemented by software or firmware, the relevant program codes are stored in the memory 802, and the processor 801 calls the encoding and decoding method for performing the color hanzi codes according to the embodiments of the present application; an input/output interface 803 for realizing information input and output; the communication interface 804 is used for realizing communication interaction between the device and other devices, and can realize communication in a wired manner (for example, USB, network cable, etc.) or in a wireless manner (for example, mobile network, WI-FI, bluetooth, etc.); a bus 805 that transfers information between the various components of the device (e.g., the processor 801, memory 802, input/output interfaces 803, and communication interface 804); wherein the processor 801, the memory 802, the input/output interface 803 and the communication interface 804 are communicatively connected to each other within the device via a bus 805.
The embodiment of the present application further provides a storage medium, which is a computer-readable storage medium for computer-readable storage, where the storage medium stores one or more programs, and the one or more programs are executable by one or more processors to implement the above-mentioned encoding and decoding method for the color hanzi codes.
The memory, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs as well as non-transitory computer executable programs. Further, the memory may include high speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory located remotely from the processor, and these remote memories may be connected to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
According to the encoding and decoding method of the color Chinese-sensible code, the electronic device and the storage medium, the color information coding region is obtained by filling the color data code stream into the original information coding region, and the bearing information capacity of the color Chinese-sensible code is improved. By replacing the original image searching graph with the color image searching graph and replacing the original correction graph with the color correction graph, on the basis of providing the functions of the position and the direction of the symbol, the chromatic aberration correction can be carried out during the decoding of the color Hanxin code, the identification accuracy of the color is improved, and the error rate of the color Hanxin code is reduced.
The embodiments described in the embodiments of the present application are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation to the technical solutions provided in the embodiments of the present application, and it is obvious to those skilled in the art that the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems with the evolution of technology and the emergence of new application scenarios.
It will be appreciated by those skilled in the art that the embodiments shown in fig. 2-4, 7-9 and 11 are not limiting to the embodiments of the present application and may include more or fewer steps than those shown, or some of the steps may be combined, or different steps.
The above-described embodiments of the apparatus are merely illustrative, wherein the units illustrated as separate components may or may not be physically separate, i.e. may be located in one place, or may also be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
One of ordinary skill in the art will appreciate that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one type of logical functional division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes multiple instructions for enabling an electronic device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing programs, such as a usb disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The preferred embodiments of the present application have been described above with reference to the accompanying drawings, and the scope of the claims of the embodiments of the present application is not limited thereto. Any modifications, equivalents and improvements that may occur to those skilled in the art without departing from the scope and spirit of the embodiments of the present application are intended to be within the scope of the claims of the embodiments of the present application.

Claims (10)

1. A method for encoding and decoding a color han-xin code, the method comprising:
acquiring a color data code stream; the color data code stream is used for expressing: coded data obtained after the coded data is subjected to color coding;
generating an original code graph structure according to the stipulation of a preset symbol version, wherein the original code graph structure comprises an original information coding region and an original functional graph region, and the original functional graph region comprises an original image searching graph and an original correction graph;
filling colors of the color blocks of the original image searching graph according to three preset primary colors to obtain a color image searching graph;
filling the color bars of the original correction graph with colors according to the three primary colors to obtain a color correction graph;
filling the color data code stream into the original information coding region according to the provision of the symbol version to obtain a color information coding region;
and replacing the original image searching graph according to the color image searching graph, replacing the original correction graph by the color correction graph, and replacing the original information coding region by the color information coding region to obtain the color Chinese-sensible code.
2. The method of claim 1, wherein obtaining the stream of color data bits comprises:
acquiring the data to be encoded, and determining a data encoding mode of the data to be encoded;
coding the data to be coded according to the data coding mode to obtain an information bit stream;
carrying out code word construction on the information bit stream according to the preset information code word number to obtain an information code word sequence;
carrying out color mapping on each information bit of the information code word sequence to obtain an information code color pixel point sequence;
the information code color pixel point sequence is blocked to obtain at least one information code color pixel point sequence block, and the information code word sequence is blocked to obtain at least one information code word sequence block; the information code color pixel point sequence block and the information code word sequence block have a corresponding relation;
carrying out error correction coding on the information code word sequence block according to the rule of a preset error correction level to obtain an original error correction code word sequence block;
carrying out color mapping on each information bit of the original error correction code word sequence block to obtain a color error correction code word sequence block;
splicing the information code color pixel point sequence block and the color error correction code word sequence block to obtain a color data code stream block;
and sequentially combining the color data code stream blocks to obtain the color data code stream.
3. The method according to claim 1 or 2, wherein the three primary colors include red, green and blue, the original finding pattern includes a first original color block, a second original color block and a third original color block, and the color blocks of the original finding pattern are color-filled according to the preset three primary colors to obtain a color finding pattern, including:
filling the red color to the first original color block to obtain a first color block;
filling the green color to the second original color block to obtain a second color block;
filling the blue color to the third original color block to obtain a third color block;
and replacing the first original color block by the first color block, replacing the second original color block by the second color block, and replacing the third original color block by the third color block to obtain the color image finding graph.
4. The method according to claim 1 or 2, wherein the three primary colors comprise red, green and blue, the original correction pattern comprises original color bars, and the color bars of the original correction pattern are color-filled according to the three primary colors to obtain a color correction pattern, comprising:
taking the red, the green and the blue as a group of filling colors, and sequentially filling the filling colors into the original color bars to obtain color bars;
and replacing the original color bar according to the color bar to obtain the color correction graph.
5. The method according to claim 1 or 2, wherein after said obtaining the color hanseng code, the method further comprises:
preprocessing the color Chinese-sensible code to obtain a binary image;
finding a finding image in the binary image, and determining the position and the direction of a symbol;
extracting a color image searching graph of the color Chinese-sensible code according to the symbol position and the direction;
carrying out global color difference deviation correction processing on the color Chinese-sensible code according to the color image finding graph to obtain a primary color decoding image;
extracting a color correction graph of the color Chinese-sensible code according to the symbol position and the direction;
extracting a symbol version from the function information area of the binary image;
establishing a sampling grid according to the specification of the symbol version;
sampling the preliminary color decoded image according to a sampling network, and performing local color difference correction processing on a pixel point sequence in each sampling grid according to the color correction graph to obtain a target color decoded image;
extracting data of the target color decoding image according to a data arrangement rule to obtain a color data code stream;
carrying out color matching on the color data code stream so as to adjust the color of each pixel point in the color data code stream to one of colors in a preset color range;
carrying out color restoration on the color data code stream to obtain an information code word sequence to be decoded of the color Chinese-sensible code;
and carrying out information decoding on the information code word sequence to be decoded to obtain the information carried by the color Chinese-sensible code.
6. The method according to claim 5, wherein said performing color restoration on the color data code stream to obtain a to-be-decoded information codeword sequence of the color Hansen code comprises:
partitioning the color data code stream to obtain a plurality of information blocks, wherein each information block comprises an information code color pixel point sequence block and a color error correction code word sequence block;
carrying out color restoration on the information code color pixel point sequence block to obtain an information code word sequence block, and carrying out color restoration on the color error correction code word sequence block to obtain an original error correction code word sequence block;
carrying out error detection on the information code word sequence block according to the original error correction code word sequence block, if an error is found, carrying out error correction decoding processing on the information code word sequence block according to the regulation of a preset error correction level to obtain a new information code word sequence block;
and combining the information code word sequence blocks in sequence to obtain the information code word sequence to be decoded.
7. The method according to claim 5, wherein the color finding pattern comprises a first color block, a second color block and a third color block, and the performing global color deviation rectification processing on the color Hanxin code according to the color finding pattern to obtain a preliminary color decoded image comprises:
calculating the average color difference value of all pixel points in the first color block to obtain the average red color difference;
calculating the average color difference value of all pixel points in the second color block to obtain the average green color difference;
calculating the average color difference value of all pixel points in the third color block to obtain the average blue color difference;
acquiring the color value of each pixel point of the color Chinese-sensible code in the color correction graph and the color information coding area, and recording the color value as an original pixel value;
performing color difference correction on the original pixel value according to the average red color difference, the average green color difference and the average blue color difference to obtain a preliminary pixel value;
and replacing the original pixel value of the color Hanxin code according to the preliminary pixel value to obtain the preliminary color decoding image.
8. The method of claim 5, wherein the pixel point sequence comprises a plurality of pixel points, and wherein performing local color deviation correction on the pixel point sequence in each of the sampling grids to obtain a target color-decoded image comprises:
acquiring the position and the preliminary pixel value of each pixel point;
determining a reference point from the color correction pattern according to the distance length between the position and the color correction pattern;
taking the reference point as a benchmark, extracting a reference pixel value from the color correction graph; the reference pixel values include a corrected red, a corrected green, and a corrected blue;
and performing color difference correction on the preliminary pixel value according to the corrected red color, the corrected green color and the corrected blue color to obtain the target color decoding image.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor implements the method of any of claims 1-8 when executing the computer program.
10. A storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the method of any one of claims 1 to 8.
CN202211444369.2A 2022-11-18 2022-11-18 Encoding and decoding method of colorful Chinese-sensible code, electronic equipment and storage medium Pending CN115936047A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211444369.2A CN115936047A (en) 2022-11-18 2022-11-18 Encoding and decoding method of colorful Chinese-sensible code, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211444369.2A CN115936047A (en) 2022-11-18 2022-11-18 Encoding and decoding method of colorful Chinese-sensible code, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115936047A true CN115936047A (en) 2023-04-07

Family

ID=86554855

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211444369.2A Pending CN115936047A (en) 2022-11-18 2022-11-18 Encoding and decoding method of colorful Chinese-sensible code, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115936047A (en)

Similar Documents

Publication Publication Date Title
JP2940496B2 (en) Pattern matching encoding apparatus and method
US7950589B2 (en) Program, information storage medium, two-dimensional code generation system, image generation system and printed material
CN109754046B (en) Two-dimensional code, encoding method, decoding method, device and equipment of two-dimensional code
US8615138B2 (en) Image compression using sub-resolution images
Zhang et al. Optimal transition probability of reversible data hiding for general distortion metrics and its applications
US20180165836A1 (en) Triangle mesh compression
CN111699696A (en) Method and apparatus for encoding and decoding a byte stream
CN101816177A (en) Textual image coding
KR102152346B1 (en) Method and system for improving compression ratio by difference between blocks of image file
CN103632179B (en) Code And Decode method and the device of Three-Dimensional Bar Code
CN111046996B (en) Color QR code generation and identification method
CN111275152A (en) Two-dimensional code, encoding method and decoding method of two-dimensional code, decoding device of two-dimensional code and electronic system
CN111353321A (en) Data generating and analyzing method and device, computer storage medium and electronic device
CN114973282A (en) Table identification method and device, electronic equipment and storage medium
CN111726615B (en) Point cloud coding and decoding method and coder-decoder
CN111275049A (en) Method and device for acquiring character image skeleton feature descriptors
JP2006351001A (en) Content characteristic quantity extraction method and device, and content identity determination method and device
CN103927572B (en) By coding segment to form the method and apparatus of dot pattern
CN115936047A (en) Encoding and decoding method of colorful Chinese-sensible code, electronic equipment and storage medium
CN116126957A (en) Data format conversion method, device, equipment and storage medium
CN107122067B (en) Method and device for encoding and decoding surface position of physical medium and readable storage medium
CN110781185B (en) Text file content pixelation conversion and restoration method
Hu et al. Lossless index coding for indexed colour images
CN113810478B (en) Event stream data processing method and device, electronic equipment and storage medium
CN112232025A (en) Character string storage method and device and electronic equipment

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