A recyclable electronic price-calculating scale with anti-counterfeiting and anti-cheating functions
Through blocked DCT transformation and clustering analysis technology, the appropriate steganography location and frequency range are selected for the frequency domain characteristics of different regions, which solves the problem of low robustness of steganography information in the existing technology and achieves higher resistance Attack ability.
Patent Information
- Application Number
- CN202411805431.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-12-10
AI Technical Summary
The existing QR code steganography technology ignores regional differences when processing frequency domain characteristics of different regions, resulting in low robustness in steganography when QR code deterioration.
The QR code image is blocked by using the block DCT transformation algorithm, and the cluster coefficient matrix of each cluster is determined through cluster analysis, and the appropriate steganography position and frequency range are selected for steganography to improve the resistance of steganography information. Attack ability.
By considering the frequency domain characteristics of different regions and selecting appropriate steganography locations and frequency ranges, the robustness and attack resistance of steganography information are significantly improved, and the damage to steganography information is avoided due to regional differences.
Smart Images

Figure CN119272793B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic scale anti-cheating, and in particular to a recyclable electronic pricing scale with anti-counterfeiting and anti-cheating functions. Background Art
[0002] The recyclable electronic price-calculating scale is equipped with easily replaceable parts, supporting users to exchange old items for new ones, which not only improves transaction efficiency, but also enhances the safety of the use process. During the transaction process, the electronic price-calculating scale can convert transaction data into a QR code and provide a printing function. Consumers or regulators can obtain a complete transaction record by scanning the QR code. Since the QR code is unique, it can effectively prevent merchants from tampering with local data, achieving the effect of anti-counterfeiting and anti-cheating.
[0003] When using QR codes to prevent cheating, it is crucial to ensure the authenticity of the QR code. In order to prevent merchants from counterfeiting QR codes, steganography embeds digital fingerprints into QR codes. The authenticity of the QR code can be verified through the hidden digital fingerprint, which can effectively curb data cheating. Considering that QR codes may be defaced during image compression, printing and storage, it is necessary to ensure that the adopted QR code steganography technology has high robustness to resist attacks caused by information damage. Traditional QR code steganography technology usually uses the DCT (discrete cosine transform) algorithm to process the QR code image, and then inserts a binary bit stream into the DCT coefficients to complete the steganography. Because the basic information contained in the DCT coefficients at the same frequency position in different regions and the ability to resist attacks are different, the traditional DCT method ignores the differences in frequency domain characteristics of different regions of the QR code image. When a DCT coefficient matrix obtained from a QR code image is steganographically obtained, when the QR code image is defaced, the steganographic information in certain frequency ranges will be greatly damaged, thereby reducing the robustness of the steganographic information. Therefore, when the two-dimensional code of the electronic price calculating scale is steganographically written, there is a problem of low robustness of the steganographic information due to inappropriate selection of the steganographic coefficient range. Summary of the invention
[0004] In order to solve the above technical problems, a recyclable electronic pricing scale with anti-counterfeiting and anti-cheating functions is provided to solve the existing problems.
[0005] The solution to the technical problem of the present application is to provide a recyclable electronic price-calculating scale with anti-counterfeiting and anti-cheating functions, the electronic price-calculating scale comprising:
[0006] An information acquisition module is used to obtain the QR code image corresponding to the transaction information of the electronic price computing scale, as well as the steganographic information;
[0007] The information embedding module is used to embed the steganographic information into the two-dimensional code image to obtain the steganographic two-dimensional code image, including:
[0008] (1) Using a block DCT transform algorithm to divide the two-dimensional code image into blocks, and calculating the DCT coefficient matrix of each DCT block; clustering all DCT blocks based on the DCT coefficient matrix to obtain multiple clusters; determining the clustering coefficient matrix of each cluster according to the DCT coefficient matrices of all DCT blocks in each cluster and the number of all DCT blocks;
[0009] (2) Determine the steganographic position of each cluster according to the distribution of elements in the clustering coefficient matrix; perform window sliding on all the steganographic positions to determine the steganographic window to be selected for each cluster;
[0010] (3) Analyze the complexity of texture distribution in the two-dimensional code image area corresponding to the DCT block in each cluster, and determine the texture complexity of each cluster; determine the position of the steganographic window of each cluster in combination with the number of the steganographic windows to be selected; determine the steganographic coefficient range of the DCT coefficient matrix of each DCT block based on the steganographic window position; obtain the two-dimensional code image after steganography based on the DCT coefficient matrix, the steganographic coefficient range and the steganographic information;
[0011] The anti-counterfeiting verification module is used to extract the steganographic information to be verified from the steganographic two-dimensional code image and perform anti-counterfeiting verification on the steganographic two-dimensional code image.
[0012] Preferably, the obtaining of multiple clusters comprises:
[0013] The difference between the DCT coefficient matrices corresponding to any two DCT blocks is recorded as a difference matrix; the sum of the absolute values of all elements in the difference matrix is recorded as a block distance;
[0014] Taking the block distance as the sample distance, a cluster analysis algorithm is used to cluster all DCT blocks in the two-dimensional code image to obtain a plurality of clusters.
[0015] Preferably, determining the clustering coefficient matrix of each cluster includes:
[0016] The sum of the DCT coefficient matrices corresponding to all DCT blocks in each cluster is taken as the sum matrix of each cluster;
[0017] The number of all DCT blocks in each cluster is counted, and the ratio of each element in the sum matrix to the number is used as the clustering coefficient matrix of each cluster.
[0018] Preferably, the step of determining the steganographic position of each cluster comprises:
[0019] Perform a zigzag scan on the clustering coefficient matrix of each cluster, and form a frequency sequence of each cluster according to the scanning order;
[0020] Using the threshold segmentation algorithm, the segmentation threshold of the frequency sequence of each cluster is obtained;
[0021] Recording the element with the smallest difference between the frequency sequence and the segmentation threshold as the low-frequency upper limit coefficient;
[0022] The low-frequency upper limit coefficient and all elements on the right side of the frequency sequence are recorded as steganographic positions.
[0023] Preferably, the step of determining a candidate steganographic window for each cluster comprises:
[0024] If the number of steganographic positions in each cluster is greater than or equal to the length of the stego information, a sliding window equal to the length of the stego information is constructed;
[0025] The frequency sequence is slid rightwards from the low-frequency upper limit coefficient in sequence, and each sliding window is recorded as a candidate steganalysis window for each cluster.
[0026] Preferably, determining the texture complexity of each cluster comprises:
[0027] The edge detection algorithm is used to perform edge detection on the two-dimensional code image to obtain the two-dimensional code edge image; the corresponding area of each DCT block in each cluster in the two-dimensional code edge image is recorded as an edge block;
[0028] Calculating the fractal dimension of the edge block corresponding to each DCT block in each cluster;
[0029] The normalized result of the mean value of the fractal dimension of the edge blocks corresponding to all DCT blocks in each cluster is taken as the texture complexity of each cluster.
[0030] Preferably, the steganographic window position of each cluster is a result of rounding up the product of the texture complexity and the number of the steganographic windows to be selected.
[0031] Preferably, the step of determining the steganographic coefficient range of the DCT coefficient matrix of each DCT block comprises:
[0032] The selected steganalysis window corresponding to the steganalysis window position of each cluster is recorded as the steganalysis window of each cluster;
[0033] The element position of the clustering coefficient matrix corresponding to the element in the stego window is recorded as the matrix stego position of each cluster;
[0034] The DCT coefficients at the same position as the steganographic position of the matrix in the DCT coefficient matrix of each DCT block in each cluster are used as the steganographic coefficient range of the DCT coefficient matrix of each DCT block.
[0035] Preferably, the step of obtaining the steganographic QR code image includes:
[0036] Taking the DCT coefficient matrix of each DCT block, the steganographic coefficient range and the steganographic information as input, using the STC coding steganographic algorithm to perform steganography, and obtaining the DCT coefficient matrix of each DCT block after steganography;
[0037] The block DCT inverse transform algorithm is used to inversely transform all the steganographic DCT coefficient matrices to obtain the steganographic QR code image.
[0038] Preferably, the step of extracting the steganographic information to be verified from the steganographic QR code image includes:
[0039] The block DCT transform algorithm is used to divide the steganographic two-dimensional code image into blocks to obtain the DCT coefficient matrix of each DCT block; the DCT coefficient matrix of each DCT block is used as input, and the STC coding steganographic inverse algorithm is used to extract the binary bit stream of each DCT block to form the vector to be verified for each DCT block;
[0040] Calculate the mean of all elements of the vector to be verified in each dimension of all DCT blocks, and form the mean vector of the steganographic two-dimensional code image with the mean values of all dimensions;
[0041] The elements in the mean vector whose values are greater than a preset threshold are assigned a value of 1, and vice versa, are assigned a value of 0; and all the elements after the assignment are used as the stego information to be verified.
[0042] This application has at least the following beneficial effects:
[0043] The present application generates a QR code through transaction information, and generates steganographic information through transaction information and a system terminal key; determines the clustering coefficient matrix of each cluster according to the DCT coefficient matrix of all DCT blocks in each cluster and the number of all DCT blocks; its beneficial effect is that it considers dividing DCT blocks with similar frequency domain features into one category, which helps to select a suitable range of steganographic coefficients according to the differences between different regions in the future, and improves the confidentiality and anti-attack ability of the steganographic information; determines the steganographic position of each cluster according to the distribution of elements in the clustering coefficient matrix; performs window sliding on all the steganographic positions to determine the steganographic window to be selected for each cluster, and its beneficial effect is that it considers dividing the low-frequency information of each DCT block into one category, and The invention discloses a method for distinguishing the low-frequency information part from the high-frequency information part to avoid damaging the basic information of the two-dimensional code in the low-frequency part; determining the texture complexity of each cluster; determining the position of the steganographic window of each cluster; determining the steganographic coefficient range of the DCT coefficient matrix of each DCT block; obtaining the two-dimensional code image after steganography, which has the beneficial effect of considering the use of a steganographic window with a higher frequency range for clusters with high texture complexity, while improving the confidentiality of the steganographic information, ensuring the anti-attack ability of the steganographic information, and secondly selecting coefficients of a suitable frequency range as the steganographic coefficient range for different DCT blocks according to the frequency domain characteristics, which can avoid the reduction of the robustness of the steganographic information caused by the regional frequency difference of the two-dimensional code image, and can improve the anti-attack ability of the steganographic information. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The following is a further detailed description of a recyclable electronic price calculating scale with anti-counterfeiting and anti-cheating functions of the present application in conjunction with the accompanying drawings.
[0045] Figure 1 A block diagram of a recyclable electronic price-calculating scale with anti-counterfeiting and anti-cheating functions provided in one embodiment of the present application;
[0046] Figure 2 A flowchart of the steps of an information embedding module provided by one embodiment of the present application;
[0047] Figure 3 A flowchart of a method for obtaining a steganographic window to be selected for each cluster provided in one embodiment of the present application;
[0048] Figure 4 A flowchart of the steps of a method for obtaining a steganographic coefficient range of a DCT coefficient matrix of each DCT block provided by an embodiment of the present application;
[0049] Figure 5 A two-dimensional code image steganography flow chart provided for one embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the following is a further detailed description of a recyclable electronic price-calculating scale with anti-counterfeiting and anti-cheating functions proposed in the present application in combination with the accompanying drawings and implementation examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0051] 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.
[0052] See also Figure 1 , which shows a block diagram of a recyclable electronic price computing scale with anti-counterfeiting and anti-cheating functions provided by an embodiment of the present application. The electronic price computing scale includes: an information acquisition module, an information embedding module, and an anti-counterfeiting verification module.
[0053] The information acquisition module is used to obtain the QR code image corresponding to the transaction information of the electronic pricing scale, as well as the steganographic information.
[0054] In this embodiment, after each weighing and pricing, the electronic price calculating scale will convert the transaction information into a QR code, wherein the transaction information includes the transaction merchant, transaction customer, transaction commodity, transaction quantity, transaction time and other information.
[0055] Therefore, after the electronic pricing scale completes the transaction, the transaction information is obtained, and the two-dimensional code image generation algorithm is used to convert the transaction information into a two-dimensional code image;
[0056] Preferably, in this embodiment, the QR code version is selected as Version 1, and the error correction level is selected as H, which means that about 30% of the QR code errors can be corrected. The size of the output QR code image is a 320×320 grayscale image, wherein the QR code image generation algorithm is a well-known technology and will not be repeated here.
[0057] At the same time, the electronic price calculating scale sends the transaction information to the electronic price calculating scale anti-cheating management system terminal. The system terminal generates a random key and stores the key securely locally. The system terminal takes the transaction information and the random key as input and uses a hash function to calculate the hash value. The hash value length in the hash function is set to 32 bits, and the 32-bit hash value is converted into a binary bit stream. Since the binary bit stream requires the key of the system terminal to generate, it cannot be forged by the merchant, and the transaction information can be verified through the binary bit stream.
[0058] Preferably, in this embodiment, the SHA256 hash function is used to calculate the hash value, and the necessary parameter is that the hash value length is 32 bits, wherein the SHA256 hash function is a well-known technology and will not be described in detail here. As other implementation methods, the implementer can adopt other methods of the prior art, such as the SHA1 hash function, etc., and this embodiment does not impose any special restrictions on this.
[0059] The binary bit stream is used as hidden information and embedded into the QR code image through steganography technology to ensure that the binary bit stream cannot be discovered and tampered with by attackers.
[0060] So far, the QR code image corresponding to the transaction information of the electronic price computing scale and the steganographic information are obtained;
[0061] The information embedding module is used to embed the steganographic information into the two-dimensional code image to obtain the steganographic two-dimensional code image.
[0062] In order to ensure the robustness of the steganographic information, the traditional steganographic technology method first uses the DCT (Discrete Cosine Transform) algorithm to obtain the DCT coefficient matrix of the two-dimensional code image, and then selects the DCT coefficient matrix in a specific frequency range, and uses STC (syndrome-trellis code) to embed the binary bit stream into the two-dimensional code image to complete the digital steganography of the two-dimensional code image. The DCT coefficients in a specific frequency range are selected for steganography, which can avoid damage to the basic information of the two-dimensional code and the discovery of steganographic traces while ensuring the anti-attack resistance of the steganographic information.
[0063] However, in different areas of the two-dimensional code image, the frequency range of effective information is different. If the same frequency range is used for steganography in all areas, when some areas of the two-dimensional code image are seriously defaced, the stego information will be greatly damaged, which may cause the stego information to fail. Therefore, this embodiment uses a block DCT algorithm to divide the two-dimensional code image into different DCT blocks, and selects a suitable frequency range for different DCT blocks for steganography, which can avoid the problem of low robustness of the stego information caused by regional differences in the two-dimensional code image, thereby further improving the ability of the stego information to resist attacks.
[0064] Further, the step flow chart of the information embedding module provided in this application is as follows Figure 2 shown.
[0065] Step 1: Determine the clustering coefficient matrix of each cluster according to the DCT coefficient matrices of all DCT blocks in each cluster and the number of all DCT blocks.
[0066] The block DCT transform algorithm is an improved algorithm of the DCT transform algorithm. It divides the image into different blocks and performs DCT transform on each block. While speeding up the extraction of frequency domain features, it can extract frequency domain features separately for different image areas.
[0067] Since different areas of the two-dimensional code image have different frequency ranges of valid information, the frequency ranges that can effectively resist attacks are also different. Therefore, the block DCT transform algorithm is used to extract frequency domain features of the two-dimensional code image, and the DCT sub-blocks with similar frequency information are divided into one category. The same steganographic coefficient range is used for sub-blocks of the same category to adapt to the frequency domain feature differences in different areas of the two-dimensional code image, which can effectively improve the anti-attack ability of the steganographic information.
[0068] First, the two-dimensional code image is divided into blocks and DCT transformed, specifically:
[0069] Using the block DCT transform algorithm, the two-dimensional code image is divided into multiple DCT blocks, and the DCT coefficient matrix of each DCT block is calculated;
[0070] Preferably, in this embodiment, the block DCT transform algorithm is a well-known technology and will not be described in detail here; secondly, the block size is set to 16×16 in the block DCT transform algorithm, and the two-dimensional code image is divided into 400 DCT blocks, thereby obtaining 400 16×16 DCT coefficient matrices.
[0071] It should be noted that the pixel points closer to the upper left corner of the DCT coefficient matrix reflect lower-frequency information in the two-dimensional code image, and the pixel points closer to the lower right corner reflect higher-frequency information.
[0072] Furthermore, in the DCT coefficient matrix, the effective information of the two-dimensional code image is usually concentrated in the low-frequency part. If the DCT coefficients of the low-frequency part are selected for steganography, it is easy to cause damage to the two-dimensional code image and the steganographic traces will be discovered; if the DCT coefficients of the high-frequency part are used for steganography, the stegographed information is easily damaged during the transmission, compression, storage and wear of the paper two-dimensional code, resulting in low robustness of the stegographed information.
[0073] Based on the above analysis, according to the frequency domain distribution of the two-dimensional code image, a suitable frequency range is selected for steganography, which helps the robustness of the steganographic information while avoiding damage to the two-dimensional code image. Therefore, for image blocks with similar distribution of DCT coefficient matrices, their steganographic coefficient ranges should also be similar. Therefore, the similarity between DCT blocks in the two-dimensional code image is analyzed, specifically:
[0074] The difference between the DCT coefficient matrices corresponding to any two DCT blocks is recorded as a difference matrix; the sum of the absolute values of all elements in the difference matrix is recorded as a block distance;
[0075] It should be noted that, assuming that in two 3×3 dimensional DCT coefficient matrices, the DCT coefficient matrices corresponding to the two DCT blocks are , , then the difference matrix is , the block distance is ,in, Indicates the calculation of absolute value. The smaller the block distance is, the more similar the distribution of DCT coefficient matrices of the two DCT blocks is.
[0076] Furthermore, if the steganographic coefficient range is selected for each DCT block separately, the more prominent noise at a certain frequency in a single DCT block may be used as the frequency domain feature of the corresponding block, which will cause noise interference when selecting the frequency of the block, resulting in unreasonable selection of the steganographic coefficient range of the block, resulting in reduced robustness of the steganographic information. Therefore, DCT blocks with similar DCT coefficient matrix distribution are combined to jointly select a suitable steganographic coefficient range to reduce the impact of noise on the steganographic coefficient range. Cluster analysis is performed on all DCT blocks, specifically:
[0077] Taking the block distance as the sample distance, clustering all DCT blocks in the two-dimensional code image using a clustering analysis algorithm to obtain multiple clusters;
[0078] Preferably, in this embodiment, a bottom-up hierarchical clustering algorithm is adopted, wherein the clustering stopping condition is that the number of DCT blocks in a cluster is greater than or equal to 20, wherein the hierarchical clustering algorithm is a well-known technology and will not be described in detail here. As other implementation methods, the implementer can adopt other methods of the prior art, such as the K-means clustering algorithm, etc., and this embodiment does not impose any special restrictions on this.
[0079] The sum of the DCT coefficient matrices corresponding to all DCT blocks in each cluster is taken as the sum matrix of each cluster;
[0080] Counting the number of all DCT blocks in each cluster, and taking the ratio of each element in the sum matrix to the number as the clustering coefficient matrix of each cluster;
[0081] It should be noted that, assuming There are DCT blocks, The sum matrix of clusters is: , then The clustering coefficient matrix of clusters is , where the clustering coefficient matrix of each cluster reflects the overall distribution of DCT coefficients corresponding to the DCT blocks in the cluster. Therefore, the DCT coefficient matrix in the two-dimensional code image is classified according to the frequency characteristics, which is conducive to selecting the appropriate range of steganographic coefficients according to the characteristics of the two-dimensional code region.
[0082] At this point, the clustering coefficient matrix of each cluster is obtained.
[0083] Step 2: Determine the steganographic position of each cluster according to the distribution of elements in the clustering coefficient matrix; perform window sliding on all the steganographic positions to determine the steganographic window to be selected for each cluster.
[0084] The effective information of the two-dimensional code image is usually concentrated in the low-frequency part. In order to avoid damaging the basic information of the two-dimensional code and discovering the steganographic traces, this part of the frequency needs to be avoided during steganography. Since the DCT coefficients of the low-frequency part where the effective information is concentrated and the other frequency parts usually have a large gap, therefore, by calculating the low-frequency upper limit coefficient in the two-dimensional code image, the DCT coefficients lower than the low-frequency upper limit coefficient are determined to be the DCT coefficient part where the effective information of the two-dimensional code image is concentrated. Then, the position corresponding to the DCT coefficient lower than the low-frequency upper limit coefficient should be avoided from being steganographic. The greater the gap between the lowest frequency DCT coefficient and the low-frequency upper limit within the range of the steganographic coefficients selected by the steganography, the less damage the steganography causes to the two-dimensional code image, and the less likely the steganographic traces are to be discovered. Based on the above analysis, the low-frequency upper limit coefficient of each cluster is obtained, specifically:
[0085] Perform a zigzag scan on the clustering coefficient matrix of each cluster, and form a frequency sequence of each cluster according to the scanning order;
[0086] It should be noted that the zigzag scanning is a well-known technology and will not be described in detail here. The clustering coefficient matrix is scanned from the upper left corner to the lower right corner in a zigzag scanning manner. Assume that in a 3×3 dimensional clustering coefficient matrix, The clustering coefficient matrix of clusters is , the frequency sequence obtained after zigzag scanning is: , the elements closer to the left in the frequency sequence are the low-frequency part of the clustering coefficient matrix, and the more they contain the basic information of the QR code.
[0087] Using the threshold segmentation algorithm, the segmentation threshold of the frequency sequence of each cluster is obtained;
[0088] Recording the element with the smallest difference between the frequency sequence and the segmentation threshold as the low-frequency upper limit coefficient;
[0089] The low-frequency upper limit coefficient and all elements on the right side of the frequency sequence are recorded as steganographic positions;
[0090] It should be noted that all the elements on the left side of the low-frequency upper limit coefficient in the frequency sequence contain the basic information of the QR code image. In the DCT coefficient matrix, the positions corresponding to these elements should not be written with steganographic information to avoid damage to the basic information of the QR code and the discovery of steganographic traces. Assuming that the frequency sequence middle, The difference between the element value of and the segmentation threshold is the smallest, then is the low frequency upper limit coefficient, The element on the left Contains the basic information of the QR code image. and the elements to its right A steganographic location.
[0091] Furthermore, the difference between the number of steganographic positions of each cluster and the length of the steganographic information is analyzed to determine the selectable steganographic window, which is:
[0092] If the number of steganographic positions in each cluster is greater than or equal to the length of the stego information, a sliding window equal to the length of the stego information is constructed;
[0093] Slide rightwards in sequence from the low frequency upper limit coefficient in the frequency sequence, and record each sliding window as a steganalysis window to be selected;
[0094] Preferably, in this embodiment, the step size of the sliding window is 1. Since the stego information is a 32-bit binary bit stream, assuming that the number of steganographic positions of the nth cluster is M, it will slide H=M-32+1 times to obtain H stego windows to be selected.
[0095] It should be noted that if the number of steganographic positions of each cluster is less than the length of the stego information, the DCT block of the cluster will not be steganographic. In this embodiment, the stego information is a 32-bit binary bit stream, so at least 32 steganographic positions are required for steganography. Therefore, if the first If the number of steganographic locations of a cluster is less than 32, then the The DCT blocks of clusters are used for steganography. If the number of steganographic positions of a cluster is greater than or equal to 32, a sliding window with a length of 32 is constructed and slid within the frequency sequence, starting from the low-frequency upper limit coefficient and sliding to the right until it slides to the rightmost side of the frequency sequence.
[0096] It should be noted that when performing steganography, you can select a selected steganography window for steganography, which can avoid damage to the basic information of the QR code and the discovery of steganography traces. When selecting a selected steganography window, the closer to the left side of the selected steganography window is selected for steganography, the greater the damage to the QR code image information caused by the steganographic information; the closer to the right side of the selected steganography window is selected for steganography, the lower the resistance of the steganographic information to attacks.
[0097] Furthermore, the step flow chart of the method for obtaining the selected steganalysis window of each cluster provided by the present application is as follows: Figure 3 shown.
[0098] At this point, the candidate steganalysis window for each cluster is obtained.
[0099] Step 3, analyzing the complexity of texture distribution in the two-dimensional code image area corresponding to the DCT block in each cluster, and determining the texture complexity of each cluster; determining the steganographic window position of each cluster in combination with the number of the steganographic windows to be selected; determining the steganographic coefficient range of the DCT coefficient matrix of each DCT block based on the steganographic window position; obtaining the two-dimensional code image after steganography based on the DCT coefficient matrix, the steganographic coefficient range and the steganographic information.
[0100] Furthermore, for different regions in the two-dimensional code image, the robustness of its high-frequency DCT coefficients to data damage is different. Generally, the more complex and detailed the image of an image region is, the easier it is to retain its high-frequency information during image transmission and compression, and the better its robustness to data damage is.
[0101] Therefore, for different areas in the two-dimensional code image corresponding to different DCT coefficient matrices, the degree of detail and complexity of different areas in the two-dimensional code image is analyzed. The more detailed and complex the area is, the better the robustness of its high-frequency information part. When performing image steganography, you can choose to select a steganographic window that is further to the right in the frequency sequence. While ensuring the robustness of the steganographic information, reduce the damage to the basic information of the QR code and avoid the discovery of steganographic traces.
[0102] Based on the above analysis, we first perform edge detection on the QR code image to better analyze the texture features later, specifically:
[0103] Using edge detection algorithm, perform edge detection on the two-dimensional code image to obtain the edge image of the two-dimensional code;
[0104] Preferably, in this embodiment, the Canny edge detection algorithm is used for edge detection, wherein the Canny edge detection algorithm is a well-known technology and will not be described in detail here. As other implementation methods, the implementer may adopt other methods of the prior art, such as Sobel edge detection, etc. This embodiment does not impose any special restrictions on this.
[0105] It should be noted that the QR code edge image includes the texture information of the QR code image.
[0106] Furthermore, the texture complexity of the QR code edge image is analyzed to determine the texture complexity, specifically:
[0107] The corresponding area of each DCT block in each cluster in the edge image of the two-dimensional code is recorded as the edge block;
[0108] Calculating the fractal dimension of the edge block corresponding to each DCT block in each cluster;
[0109] The normalized result of the mean value of the fractal dimension of the edge blocks corresponding to all DCT blocks in each cluster is used as the texture complexity of each cluster;
[0110] Preferably, in this embodiment, the box counting method is used to calculate the fractal dimension, wherein the box counting method is a well-known technology and will not be described in detail here. As other implementation methods, the implementer can adopt other methods of the prior art, such as the frequency domain method, the random walk method, etc. This embodiment does not impose any special restrictions on this.
[0111] It should be noted that the effective information of the QR code is represented by the image texture. Therefore, the more complex the edge blocks are, the more complex the effective information of the QR code is, and the less likely the high-frequency information of the image is to be damaged. The larger the fractal dimension, the more complex the texture of the corresponding edge blocks, the less likely the high-frequency information of the corresponding DCT blocks is to be damaged, and the more likely high-frequency DCT coefficients can be selected for steganography, while ensuring the robustness of the steganographic data, avoiding damage to the basic information of the QR code and the detection of steganographic traces. Therefore, The greater the texture complexity of the cluster, the The more complex the stripes in the image area corresponding to the DCT blocks in the cluster, the better the The more clusters there are, the more likely it is that the steganographic window on the right will be selected for steganography.
[0112] Further, based on the texture complexity and the selected steganalysis window, a range of steganalysis coefficients is determined, specifically:
[0113] Rounding up the product of the texture complexity of each cluster and the number of the to-be-selected steganographic windows as the steganographic window position of each cluster;
[0114] It should be noted that, assuming The steganalysis window position of the clusters is , then for the clusters, select The position of the stego window is obtained by the texture complexity. The greater the texture complexity, the more right-facing windows in the frequency sequence should be selected, and the position of the stego window is obtained by the texture complexity. The larger it is, the closer to the right the selected steganographic window is, which can avoid the damage of the basic information of the QR code and the discovery of steganographic traces, while also ensuring that the steganographic information has a high ability to resist attacks.
[0115] The selected steganalysis window corresponding to the steganalysis window position of each cluster is recorded as the steganalysis window of each cluster;
[0116] The element position of the clustering coefficient matrix corresponding to the element in the stego window is recorded as the matrix stego position of each cluster;
[0117] Taking the DCT coefficients at the same position as the steganographic position of the matrix in the DCT coefficient matrix of each DCT block in each cluster as the steganographic coefficient range of the DCT coefficient matrix of each DCT block;
[0118] It should be noted that, assuming that the 16×16 matrix is scaled to a three-dimensional matrix, and the sliding window length is scaled from 32 to 3, in the frequency sequence middle, is the low frequency upper limit coefficient, from Start sliding, the steganographic window to be selected is: , , , , assuming that the fourth candidate steganalysis window is selected as the The steganalysis window of clusters is The corresponding clustering coefficient matrix The element position of The matrix steganalysis position of clusters, that is, the matrix steganalysis position is , assuming that The DCT coefficient matrix of the mth DCT block in the cluster is , the DCT coefficient matrix of the nth DCT block is , then the DCT coefficient matrix and Corresponding to the matrix stegoscopy position, therefore, As the range of the hidden coefficients of the mth DCT block, As the range of steganographic coefficients of the nth DCT block.
[0119] Furthermore, the step flow chart of the method for obtaining the steganographic coefficient range of the DCT coefficient matrix of each DCT block provided by the present application is as follows: Figure 4 shown.
[0120] Furthermore, based on the range of the steganographic coefficient and the steganographic information, the QR code image is steganographically processed as follows:
[0121] The DCT coefficient matrix of each DCT block and its steganographic coefficient range, as well as the steganographic information, are used as input, and the STC (syndrome-trellis code) coding steganographic algorithm is used for steganography to obtain the DCT coefficient matrix of each DCT block after steganography;
[0122] It should be noted that the STC coding steganography algorithm is a well-known technology and will not be described in detail here.
[0123] Using the block DCT inverse transform algorithm, all the DCT coefficient matrices after steganography are inversely transformed to obtain the steganographic QR code image;
[0124] It should be noted that the block DCT inverse transform algorithm is a well-known technology and will not be described in detail here; wherein, the steganographic two-dimensional code image contains the steganographic information, which can prevent the two-dimensional code from being counterfeited.
[0125] Further, the two-dimensional code image steganography flow chart provided in this application is as follows Figure 5 shown.
[0126] At this point, the steganographic QR code image is obtained.
[0127] The anti-counterfeiting verification module is used to extract the steganographic information to be verified from the steganographic two-dimensional code image and perform anti-counterfeiting verification on the steganographic two-dimensional code image.
[0128] Furthermore, based on the steganographic QR code image, anti-counterfeiting verification can be performed on it, specifically:
[0129] The block DCT transform algorithm is used to divide the steganographic two-dimensional code image into blocks to obtain the DCT coefficient matrix of each DCT block;
[0130] It should be noted that the block size of 16×16 needs to be consistent with the block size when steganography is performed on the QR code image.
[0131] The DCT coefficient matrix of each DCT block is taken as input, and the STC coding steganographic inverse algorithm is adopted to obtain the binary bit stream of each DCT block;
[0132] It should be noted that, in this embodiment, the stego information is a 32-bit binary bit stream, so the binary bit stream obtained by the STC coding stegoscopy inverse algorithm is also 32 bits. Assuming that there are G DCT blocks, G 32-bit binary bit streams are obtained. The STC coding stegoscopy inverse algorithm is a well-known technology and will not be described in detail here.
[0133] Since part of the binary bit stream may be attacked, which will lead to information loss, the 32-bit binary bit stream data corresponding to a certain DCT block is incomplete. Therefore, the steganographic information of the QR code image is extracted, specifically:
[0134] G binary bit streams are combined into G vectors of length 32 to be verified;
[0135] It should be noted that, assuming that the k-th digit of the binary bit stream is 0, the k-th element in the vector is 0; if the k-th digit of the binary bit stream is 1, the k-th element in the vector is 1.
[0136] Calculate the mean of all elements of the G vectors to be verified in each dimension, and compose the mean of all dimensions into a mean vector of the steganographic two-dimensional code image;
[0137] It should be noted that the dimension of the mean vector is 32. Assuming three 3-dimensional vectors , , , then the mean vector is: .
[0138] The elements in the mean vector that are greater than a preset threshold are assigned a value of 1, and the elements that are less than or equal to the preset threshold are assigned a value of 0;
[0139] Preferably, in this embodiment, the preset threshold value is 0.5.
[0140] All the elements after the assignment are used as the stego information to be verified;
[0141] It should be noted that all the elements after assignment are also binary bit streams, that is, the steganographic information of the two-dimensional code image after steganography is extracted.
[0142] The steganographic QR code is scanned to obtain transaction information, and the transaction information is sent to the electronic price scale anti-cheating management system terminal. The system terminal calculates the hash value by using the SHA256 hash function for the transaction information and each DCT block in each local cluster, and compares the first 32 bits of the hash value with the steganographic information to be verified. If the comparison results are consistent, the steganographic QR code image is true and the transaction information is also true. Otherwise, the steganographic QR code image is forged and the transaction information is false.
[0143] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0144] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0145] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the present application. It should be pointed out that, for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application without departing from the content of the technical solution of the present application, shall fall within the protection scope of the technical solution of the present application.
Claims
1. A recyclable electronic price-calculating scale with anti-counterfeiting and anti-cheating functions, characterized in that: The electronic price computing scale comprises: The information acquisition module is used to obtain the QR code image corresponding to the transaction information of the electronic price computing scale and the stego information, wherein a 32-bit hash value is calculated based on the transaction information and the random key of the electronic price computing scale anti-cheating management system terminal as input, the 32-bit hash value is converted into a binary bit stream, and the binary bit stream is used as the stego information; The information embedding module is used to embed the steganographic information into the two-dimensional code image to obtain the steganographic two-dimensional code image, including: (1) Using a block DCT transform algorithm to divide the two-dimensional code image into blocks, and calculating the DCT coefficient matrix of each DCT block; clustering all DCT blocks based on the DCT coefficient matrix to obtain multiple clusters; determining the clustering coefficient matrix of each cluster according to the DCT coefficient matrices of all DCT blocks in each cluster and the number of all DCT blocks; (2) Determine the steganographic position of each cluster according to the distribution of elements in the clustering coefficient matrix; perform window sliding on all the steganographic positions to determine the steganographic window to be selected for each cluster; (3) Analyze the complexity of texture distribution in the two-dimensional code image area corresponding to the DCT block in each cluster, and determine the texture complexity of each cluster; determine the position of the steganographic window of each cluster in combination with the number of the steganographic windows to be selected; determine the steganographic coefficient range of the DCT coefficient matrix of each DCT block based on the steganographic window position; obtain the two-dimensional code image after steganography based on the DCT coefficient matrix, the steganographic coefficient range and the steganographic information; The anti-counterfeiting verification module is used to extract the steganographic information to be verified from the steganographic QR code image and perform anti-counterfeiting verification on the steganographic QR code image. According to the transaction information obtained by scanning the code and the DCT blocks in each local cluster, a 32-bit hash value is calculated, and the 32-bit hash value is compared with the steganographic information to be verified.
2. The electronic price-computing scale as claimed in claim 1, which is recyclable and has anti-counterfeiting and anti-cheating functions, characterized in that: The obtaining of multiple clusters comprises: The difference between the DCT coefficient matrices corresponding to any two DCT blocks is recorded as a difference matrix; the sum of the absolute values of all elements in the difference matrix is recorded as a block distance; Taking the block distance as the sample distance, a cluster analysis algorithm is used to cluster all DCT blocks in the two-dimensional code image to obtain a plurality of clusters.
3. The electronic price-computing scale as claimed in claim 1, which is recyclable and has anti-counterfeiting and anti-cheating functions, is characterized in that: Determining the clustering coefficient matrix of each cluster includes: The sum of the DCT coefficient matrices corresponding to all DCT blocks in each cluster is used as the sum matrix of each cluster; The number of all DCT blocks in each cluster is counted, and the ratio of each element in the sum matrix to the number is used as the clustering coefficient matrix of each cluster.
4. The electronic price-computing scale that is recyclable and has anti-counterfeiting and anti-cheating functions as claimed in claim 1, characterized in that: The step of determining the steganographic position of each cluster comprises: Perform a zigzag scan on the clustering coefficient matrix of each cluster, and form a frequency sequence of each cluster according to the scanning order; Using the threshold segmentation algorithm, the segmentation threshold of the frequency sequence of each cluster is obtained; Recording the element with the smallest difference between the frequency sequence and the segmentation threshold as the low-frequency upper limit coefficient; The low-frequency upper limit coefficient and all elements on the right side of the frequency sequence are recorded as steganographic positions.
5. The electronic price-computing scale as claimed in claim 4, which is recyclable and has anti-counterfeiting and anti-cheating functions, is characterized in that: The step of determining the candidate steganalysis window for each cluster comprises: If the number of steganographic positions in each cluster is greater than or equal to the length of the stego information, a sliding window equal to the length of the stego information is constructed; The frequency sequence is slid rightwards from the low-frequency upper limit coefficient in sequence, and each sliding window is recorded as a candidate steganalysis window for each cluster.
6. The electronic price-computing scale that is recyclable and has anti-counterfeiting and anti-cheating functions as claimed in claim 1, characterized in that: The determining of the texture complexity of each cluster comprises: Perform edge detection on the two-dimensional code image to obtain a two-dimensional code edge image; record the corresponding area of each DCT block in each cluster in the two-dimensional code edge image as an edge block; Calculating the fractal dimension of the edge block corresponding to each DCT block in each cluster; The normalized result of the mean value of the fractal dimension of the edge blocks corresponding to all DCT blocks in each cluster is taken as the texture complexity of each cluster.
7. The electronic price-computing scale that is recyclable and has anti-counterfeiting and anti-cheating functions as claimed in claim 1, characterized in that: The steganographic window position of each cluster is a result of rounding up the product of the texture complexity and the number of the steganographic windows to be selected.
8. The recyclable electronic price-calculating scale with anti-counterfeiting and anti-cheating functions as claimed in claim 1, characterized in that: The step of determining the steganographic coefficient range of the DCT coefficient matrix of each DCT block comprises: The selected steganalysis window corresponding to the steganalysis window position of each cluster is recorded as the steganalysis window of each cluster; The element position of the clustering coefficient matrix corresponding to the element in the stego window is recorded as the matrix stego position of each cluster; The DCT coefficients at the same position as the steganographic position of the matrix in the DCT coefficient matrix of each DCT block in each cluster are used as the steganographic coefficient range of the DCT coefficient matrix of each DCT block.
9. The electronic price-computing scale that is recyclable and has anti-counterfeiting and anti-cheating functions as claimed in claim 1, characterized in that: The step of obtaining the steganographic two-dimensional code image comprises: Taking the DCT coefficient matrix of each DCT block, the steganographic coefficient range and the steganographic information as input, using the STC coding steganographic algorithm to perform steganography, and obtaining the DCT coefficient matrix of each DCT block after steganography; The block DCT inverse transform algorithm is used to inversely transform all the steganographic DCT coefficient matrices to obtain the steganographic QR code image.
10. The electronic price-computing scale that is recyclable and has anti-counterfeiting and anti-cheating functions as claimed in claim 1, characterized in that: The step of extracting the steganographic information to be verified from the steganographic two-dimensional code image comprises: The block DCT transform algorithm is used to divide the steganographic two-dimensional code image into blocks to obtain the DCT coefficient matrix of each DCT block; the DCT coefficient matrix of each DCT block is used as input, and the STC coding steganographic inverse algorithm is used to extract the binary bit stream of each DCT block to form the vector to be verified for each DCT block; Calculate the mean of all elements of the vector to be verified in each dimension of all DCT blocks, and form the mean vector of the steganographic two-dimensional code image with the mean values of all dimensions; The elements in the mean vector whose values are greater than a preset threshold are assigned a value of 1, and vice versa, are assigned a value of 0; and all the elements after the assignment are used as the stego information to be verified.
Citation Information
Patent Citations
Robust hidden data extraction method for scaling attacks
US20060176299A1
Encryption method
US20110311042A1