Image encryption method and device
By dividing the digital image into sub-regions and generating digital signatures and watermarks based on QR codes, the problem of insufficient security of image propagation is solved, and efficient encryption and copyright protection of images are achieved.
Patent Information
- Application Number
- CN202011356598.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-26
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2040-11-26
AI Technical Summary
The security of existing digital images spreading in the network is insufficient, especially in the face of copy attacks and malicious tampering, it is difficult to effectively protect the copyright and integrity of the images.
A QR code-based image authentication and copyright anti-counterfeiting technology is proposed. By dividing the original image into multiple sub-image areas, calculating the digital signature and watermark information of each area, generating the QR code, and embedding it in the image, to realize the encryption and authentication of the image.
Improves the security of image propagation on the Internet, enhances resistance to image tampering and copying attacks, and ensures copyright protection and integrity verification of images.
Smart Images

Figure CN114004725B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an image encryption method and device. Background Art
[0002] The easy acquisition of digital images and the development of various image modification technologies have led to the continuous emergence and spread of various forged images, greatly reducing the credibility of digital images. For example, the recent emergence of various "face-changing" apps can easily change images, and malicious tampering and dissemination will have varying degrees of impact and change on people's lives. Therefore, the security issues of digital image storage and dissemination in the network have become increasingly important and urgent, and how to effectively protect images has become the current research focus.
[0003] In related technologies, digital watermarking technology is an effective means of image copyright protection and integrity verification, and is an important branch of information hiding technology research. It embeds watermarks into images visibly or invisibly to achieve image tampering detection, copyright protection, and anti-counterfeiting traceability. However, the emergence of copy attacks has put forward higher requirements for digital watermarking technology. Copy attacks refer to copying a watermark from a legitimate image to another illegal image to legalize the illegal image, that is, copyright forgery. Therefore, the method of encrypting images based on watermarks is also very insecure. Summary of the invention
[0004] The present invention aims to solve one of the technical problems in the related art at least to a certain extent.
[0005] To this end, the first object of the present invention is to provide an image encryption method.
[0006] This paper proposes a QR code-based image authentication and copyright anti-counterfeiting technology to improve the security of image dissemination on the Internet.
[0007] The second object of the present invention is to provide an image encryption device.
[0008] A third object of the present invention is to provide a computer device.
[0009] A fourth object of the present invention is to provide a non-transitory computer-readable storage medium.
[0010] To achieve the above-mentioned purpose, an embodiment of the first aspect of the present invention proposes an image encryption method, comprising the following steps: obtaining an original image, and dividing the original image into M first sub-image areas according to preset size information, where M is a natural number greater than 1; calculating a first digital signature and a first watermark information of each first sub-image area, and generating a first QR code according to the first digital signature and the first watermark information; encrypting the corresponding first sub-image area according to the first QR code to obtain a first target sub-image area; and splicing the M first target sub-image areas to obtain an encrypted first target image.
[0011] To achieve the above-mentioned purpose, the second aspect of the present invention proposes an image encryption device, including: a division module, used to obtain an original image, and divide the original image into M first sub-image areas according to preset size information, where M is a natural number greater than 1; a generation module, used to calculate the first digital signature and the first watermark information of each of the first sub-image areas, and generate a first QR code according to the first digital signature and the first watermark information; an encryption module, used to encrypt the corresponding first sub-image area according to the first QR code to obtain a first target sub-image area; and a splicing module, used to splice the M first target sub-image areas to obtain an encrypted first target image.
[0012] To achieve the above-mentioned purpose, a third aspect of the present invention proposes a computer device, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the image encryption method of the above-mentioned embodiment.
[0013] In order to achieve the above objectives, a fourth aspect of the present invention proposes a non-temporary computer-readable storage medium, which, when instructions in the storage medium are executed by a processor, enables the image encryption method of the above embodiment to be executed.
[0014] The image encryption method and device of the embodiments of the present invention have at least the following technical effects:
[0015] The original image is obtained, and the original image is divided into M first sub-image areas according to the preset size information, where M is a natural number greater than 1, the first digital signature and the first watermark information of each first sub-image area are calculated, and the first QR code is generated according to the first digital signature and the first watermark information, and then, the corresponding first sub-image area is encrypted according to the first QR code to obtain the first target sub-image area, and finally, the encrypted first target image is obtained by splicing the M first target sub-image areas. Therefore, a QR code-based image authentication and copyright anti-counterfeiting technology is proposed to improve the security of image transmission on the Internet.
[0016] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0018] Figure 1 A schematic diagram of a flow chart of an image encryption method provided by an embodiment of the present invention;
[0019] Figure 2 A QR code embedding and extraction flow chart provided by an embodiment of the present invention;
[0020] Figure 3 A flowchart of a QR code-based image authentication and copyright anti-counterfeiting technology provided by an embodiment of the present invention;
[0021] Figure 4 A schematic diagram of a QR code embedding process provided by an embodiment of the present invention;
[0022] Figure 5 A schematic diagram of a flow chart of another image encryption method provided by an embodiment of the present invention;
[0023] Figure 6 A schematic diagram of a QR code extraction process provided by an embodiment of the present invention;
[0024] Figure 7 An image authentication flow chart of an image authentication and copyright anti-counterfeiting technology based on QR code provided by an embodiment of the present invention;
[0025] Figure 8 A schematic diagram of a first application scenario provided by an embodiment of the present invention;
[0026] Fig. 9 A schematic diagram of a second application scenario provided by an embodiment of the present invention;
[0027] Fig.10 A schematic diagram of a third application scenario provided by an embodiment of the present invention;
[0028] Fig.11 A schematic diagram of an image processed with salt and pepper noise and a QR code extraction result provided by an embodiment of the present invention;
[0029] Fig.12 A schematic diagram of a brightened image and a QR code extraction result provided by an embodiment of the present invention;
[0030] Fig.13A schematic diagram of a darkened image and a QR code extraction result provided by an embodiment of the present invention;
[0031] Fig.14 A schematic diagram of an image with occlusion processing and a QR code extraction result provided by an embodiment of the present invention;
[0032] Fig.15 A schematic diagram of an altered image and a QR code extraction result provided by an embodiment of the present invention;
[0033] Fig.16 A schematic diagram of a fourth application scenario provided by an embodiment of the present invention; and
[0034] Fig.17 A schematic diagram of the structure of an image encryption device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0035] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0036] The following describes an image encryption method and apparatus according to an embodiment of the present invention with reference to the accompanying drawings.
[0037] Based on the above analysis, it is found that the anti-copy attack method based on digital signature technology is extremely sensitive to the image itself. For example, the common compression and noise in transmission may cause the final image verification to fail. The anti-copy attack method based on the combination of digital signature technology and digital watermark technology has poor watermark robustness, and the phenomenon of watermark destruction and inability to extract has occurred. Therefore, in order to overcome the deficiencies in the prior art, the present invention proposes a QR code-based image authentication and copyright anti-counterfeiting technology framework.
[0038] Specifically, Figure 1 The following is a flow chart of an image encryption method provided by an embodiment of the present invention. Figure 1 As shown, the method includes:
[0039] Step 101: obtain an original image, and divide the original image into M first sub-image areas according to preset size information, where M is a natural number greater than 1.
[0040] In this example, encryption processing is performed on each image region of the original image. The original image is obtained, and the original image is divided into M first sub-image regions according to preset size information, where M is a natural number greater than 1, wherein the preset size information can be the size of each first image sub-region, or can be the horizontal number and vertical number of evenly distributed original images, etc. For example, the preset size information is 2*2, so the original image is divided into 4 equal first sub-image regions of 2*2, for example, the preset size information is 3*3, so the original image is divided into 9 equal first sub-image regions of 3*3, for example, the original image is divided into 6 equal first sub-image regions, etc. For example, the preset size information is 8*8, so the original image is divided into 64 equal first sub-image regions of 8*8.
[0041] Step 102: Calculate a first digital signature and a first watermark information of each first sub-image area, and generate a first QR code according to the first digital signature and the first watermark information.
[0042] In this embodiment, the first digital signature and the first watermark information of each first sub-image area are calculated, and the first QR code is generated according to the first digital signature and the first watermark information. Thus, the generated first QR code is related to the content of the image itself, thereby increasing the difficulty of being cracked.
[0043] In one embodiment of the present invention, DCT and DWT transformations are performed on each first image sub-region to obtain a reference matrix, a matrix region of a preset region of the reference matrix is extracted, and the mean DCT coefficient of the region is calculated. For example, an 8*8 matrix block in the upper left corner of the reference matrix is extracted, and the low-frequency coefficients of the matrix block are obtained, and the mean of the low-frequency coefficients is used as the mean DCT coefficient.
[0044] Furthermore, a phash algorithm is used to calculate the first digital signature, and each DCT coefficient in the matrix area is compared with the DCT coefficient mean. A signature value corresponding to each DCT coefficient is generated according to the comparison result, wherein if the comparison result is that the DCT coefficient is greater than or equal to the DCT coefficient mean, a signature value of 1 corresponding to the DCT coefficient is determined; if the comparison result is that the DCT coefficient is less than the DCT coefficient mean, a signature value of 0 corresponding to the DCT coefficient is determined, and the DCT coefficient matrix composed of all signature values in the matrix area and the character string composed of the DCT coefficients in the DCT coefficient matrix are used as the first digital signature of the corresponding first image sub-area. For example, continuing with the above-mentioned 8*8 matrix block as an example, a 64-bit "01" character string is obtained, and this character string is encrypted as the first digital signature of the image.
[0045] Then, the image source information of the original image is obtained, and the first watermark information of the first image sub-region is generated according to the image source information, wherein the image source information includes one or more of the name of the image publisher, the image publishing time, the category to which the image belongs, and the like.
[0046] Furthermore, in this embodiment, after the first digital signature and the first watermark information are spliced to obtain spliced information, the spliced information is binary-converted to obtain the first QR code.
[0047] Therefore, in this embodiment, the phash algorithm is used for calculation. First, the DCT coefficients of the original image are calculated, and then its low-frequency coefficients (the 8*8 matrix block in the upper left corner) are selected as image features. Secondly, the average value of the selected low-frequency coefficients is calculated, and the low-frequency coefficient value is compared with the average value. If it is greater than or equal to the average value, it is recorded as 1, and if it is less than, it is recorded as 0. Finally, this process finally generates a 64-bit "01" string, which is encrypted as the first digital signature of the image. The QR code used in the present invention can still be identified by QR code scanning after extraction. Therefore, in order to further improve the recognition of the watermark, some marking information, such as the owner's name, etc., is added to the image signature content as the first watermark information. The first watermark information and the first digital signature are converted into the first QR code through the QR code encoding method as the watermark to be embedded.
[0048] Step 103: encrypt the corresponding first sub-image area according to the first QR code to obtain a first target sub-image area.
[0049] In this embodiment, the first sub-image area corresponding to the first QR code is encrypted to obtain the first target sub-image area.
[0050] In some possible embodiments, the first QR code is added to a preset position of the reference matrix, a target matrix corresponding to each first image sub-region is generated, and IDWT and IDCT transformations are performed on the target matrix to obtain a first target sub-image region corresponding to each first image sub-region. The first QR code can be added to any position of the reference matrix, for example, at the center of the entire first target image.
[0051] In some other possible embodiments, refer to Figure 2 , select the insertion sequence PRN0 or PRN1 according to the "0" or "1" value of the first QR code, where PRN0 and PRN1 are two different random sequences. When the bit position of the first QR code is "0", the random sequence corresponding to the first QR code is determined to be PRN0, and when the bit position of the first QR code is "1", the random sequence corresponding to the first QR code is determined to be PRN1.
[0052] The first QR code is embedded in the first image sub-region using the following formula (1), where formula (1) is:
[0053] (Formula 1)
[0054] Among them, in the above formula, is the DCT coefficient matrix of the matrix obtained by DCT and DWT transformation of the nth first sub-image area, is the coefficient matrix of the first word image area after embedding the first QR code, is the weight adjustment coefficient.
[0055] Then, IDWT and IDCT transformations are performed on the operated first sub-image region to obtain an encrypted first target sub-image region.
[0056] In this embodiment, DWT and DCT transformations may be performed on the first target sub-image region, and the QR code may be extracted according to PRN0 and PRN1. In this embodiment, the corresponding PRN0 and PRN1 are sent to the decoding party in advance.
[0057] Step 104 , obtaining an encrypted first target image by splicing the M first target sub-image regions.
[0058] In this embodiment, the encrypted first target image is obtained by splicing the M first target sub-image regions.
[0059] Therefore, refer to Figure 3 ,In this embodiment, the signature of the original image is ,calculated first, and then the digital signature and watermark information are ,processed into a QR code, and it is ,inserted into the original image as a watermark.
[0060] Specifically, the QR code will be embedded through DCT+DWT transformation. In addition, in order to locate the attacked area of the image, the model first divides the image into sub-blocks, then performs the above operations on each sub-block, and finally combines the sub-blocks into a complete image. Therefore, in the image authentication stage, by extracting each part of the watermark information and the corresponding digital signature information and comparing them with the recalculated data, it is verified whether each sub-block of the image has been attacked. In the present invention, we use the average block method to divide the image equally, then embed the watermark into each sub-block, and finally merge them into a complete image. Next, the watermark embedding and watermark extraction processes will be introduced respectively.
[0061] When embedding the first QR code, refer to Figure 4 , Figure 4In the example of a first image sub-region as the processing object, first, the first digital signature and the first watermark information of the first sub-image region are calculated, and then the first digital signature and the first watermark information are used together to generate the first QR code using the QR code generation method, and finally the first image sub-region and the first QR code are simultaneously transformed to embed the first QR code in the first image sub-region. Of course, after the first target image is generated, the above encryption method will not affect the tampering verification of the image.
[0062] In one embodiment of the present invention, Figure 5 As shown, the method also includes:
[0063] In step 201, a second target image is acquired, and the original image is divided into M second sub-image regions according to preset size information, where M is a natural number greater than 1.
[0064] In this embodiment, a second target image is obtained, and the original image is divided into M second sub-image areas according to preset size information, where M is a natural number greater than 1, and the way in which the second image is divided into sub-image areas is the same as the way in which the original image is divided into the first image sub-image areas.
[0065] In step 202, the second QR code of each second sub-image region and the third sub-image region after the second QR code is removed are extracted.
[0066] In this embodiment, the storage location of the second QR code is pre-stored, for example, the storage location of the second QR code is stored in the central area of the second target image, the second QR code is read according to the storage location, and then the second QR code is extracted to obtain the third sub-image area.
[0067] In some possible examples, DWT and DCT transforms are performed on each second sub-image area to obtain a second target sub-image area corresponding to each second sub-image area, the second QR code in the second target sub-image area is determined at a preset storage location, the second QR code is removed from the second target sub-image area to obtain a fourth target sub-image area, and IDWT and IDCT transforms are performed on the fourth target sub-image area to obtain a third sub-image area.
[0068] In step 203, the second digital signature and the second watermark information corresponding to the second QR code are extracted.
[0069] In this embodiment, the second digital signature and the second watermark information corresponding to the second QR code are extracted.
[0070] In some possible examples, the second digital signature and the second watermark information may be pre-stored and the position information of the second QR code may be recorded, and the second digital signature and the second watermark information may be acquired according to the position information.
[0071] In step 204, it is determined whether the second digital signature and the second watermark information of each third image sub-region are consistent with the first digital signature and the first watermark information of the first sub-image region at the corresponding position.
[0072] In step 205, if they are consistent, it is determined whether the corresponding third image sub-region is also consistent with the first sub-image region at the corresponding position.
[0073] In this embodiment, if the second digital signature and the second watermark information of each third image sub-region are consistent with the first digital signature and the first watermark information of the first sub-image region at the corresponding position, it is determined whether the corresponding third image sub-region is also consistent with the first sub-image region at the corresponding position.
[0074] In some possible examples, the first image feature of the third image sub-region is extracted, the second image feature of the first sub-image region is extracted, the Hamming distance between the first image feature and the second image feature is calculated, and it is determined whether the Hamming distance is less than a preset threshold, where the preset threshold can be 5, etc.
[0075] In step 206, if they are consistent, it is determined that the corresponding third image sub-region is the same as the first sub-image region at the corresponding position.
[0076] In this example, if they are consistent, it is determined that the corresponding third image sub-region is the same as the first sub-image region at the corresponding position, so that the image sub-region has not been tampered with.
[0077] It can also be determined whether the number of differences between the third image sub-region and the first image region is greater than a preset number threshold. If not, it is considered that the second target image and the first target image are one image.
[0078] Specifically, since DCT and DWT transformations are reversible, according to Figure 6 The extraction process described can easily extract the QR code from the image. First, the second target image is transformed to separate the image and QR code from it, and then the inverse transformation is performed to restore the image and QR code, and the signature information and watermark information in the QR code are extracted for image authentication and copyright protection. In this method, we can make use of the powerful error correction processing capability of the QR code. After the watermark is extracted, the watermark information can often still be obtained by scanning the image, so that preliminary copyright confirmation can be quickly performed. Figure 7The processing flow of the image verification phase of this method is shown. First, the Hamming distance between the image features extracted from each sub-block and the recalculated image features is calculated in turn. We call the extracted image features EIF and the recalculated image features OIF. If the Hamming distance between EIF and OIF is less than 5 and the extracted QR code has been recognized, it means that the image has not been attacked. If the corresponding QR code cannot be correctly recognized or the Hamming distance is greater than 5, it means that the image area corresponding to the sub-block has been tampered with.
[0079] To illustrate the effect of the embodiments of the present invention, the following is an explanation in conjunction with a specific application scenario:
[0080] An image with 1024*1024 pixels was selected for testing. The experiment is divided into three parts: (1) verifying that the watermark can be successfully embedded and extracted after the image is divided into blocks; (2) verifying that this method can improve the robustness of the watermark and resist common signal processing; (3) verifying that this method can resist copy attacks. The experimental results show that this method: (1) can significantly improve the robustness of the watermark, especially when it is subject to noise, rotation, and darker or brighter images; (2) can effectively protect the copyright of digital images, especially against copyright copy attacks; (3) supports the location of tampered areas. As for the QR code encoding part, we use the python function library to implement it.
[0081] In Experiment 1, we evenly divide the image into 4, 6, and 9 blocks respectively to verify the correctness of the process of the method of the present invention. Figure 8-10 The experimental results are shown in Figure 2 when the image is segmented into 4, 6, and 9 blocks. Figure 8 For example, Figure 8 (a) is the original image, which is divided into 4 blocks. The watermark image of each sub-block is as follows: Figure 8 As shown in (b), Figure 8 (c) is the image after embedding the QR code. Figure 8 (d) is from Figure 8 (c) The extracted QR code image. The process is not interfered by noise, and each extracted QR code can identify the correct information.
[0082] In Experiment 2, in order to verify the robustness of the watermark, we interfered by adding noise and changing the original brightness of the image. Here, we conducted experiments based on dividing the image into 4 blocks. Figure 11-13The images and QR code extraction results after salt and pepper noise, brightening, and darkening are shown in Table 1. The corresponding Hamming distance and QR code recognition results are shown in Table 1. According to the experimental results, after interference, the original main features of the image have slight changes, but the QR code can be recognized, indicating that the method of the present invention has improved the robustness of the watermark to a certain extent. However, when the image brightness is increased by 10%, two local sub-blocks cannot be recognized. Therefore, we increase the image by 5%. According to the Hamming distance and scanning results, it is found that the QR code can be recognized. This shows that the brightness change has a greater impact on the method of the present invention. Fig.12 It can also be seen that the extracted QR code has changed significantly.
[0083] Table 1 Anti-interference ability experimental results
[0084]
[0085] In Experiment 3, we verified that the method of the present invention can not only locate the tampered area, but also effectively resist copy attacks. In this experiment, we still choose to conduct experiments based on the image segmentation into 4. First, we modify any area of the embedded QR code image, such as Fig.14 and Fig.15 As shown in the figure, the experimental results after the alteration are shown. According to the extracted watermark, we can see that the QR code morphology in the corresponding altered area has changed. At the same time, the Hamming distance and scanning results are shown in Table 2, proving that the altered area cannot be recognized normally. Finally, we copy the image embedded with the QR code and copy the QR code from the original image to another image, as shown in the figure. Fig.16 As shown in (a), although the watermark can be extracted and recognized normally, according to the Hamming distance in Table 2, we find that the features of the image do not match the features carried in the QR code, so it is determined that a copy attack has occurred.
[0086] Table 2 Malicious attack experiment results
[0087]
[0088] In summary, the image encryption method of the embodiment of the present invention effectively improves the robustness of the watermark and can effectively resist copy attacks, providing a new research idea for the development of digital watermark technology.
[0089] In order to implement the above embodiment, the present invention also proposes an image encryption device.
[0090] Fig.17 A schematic diagram of the structure of an image encryption device provided by an embodiment of the present invention.
[0091] like Fig.17As shown, the image encryption device includes: a division module 1710, a generation module 1720, an encryption module 1730, and a splicing module 1740.
[0092] The division module 1710 is used to obtain an original image and divide the original image into M first sub-image regions according to preset size information, where M is a natural number greater than 1;
[0093] A generating module 1720, configured to calculate a first digital signature and a first watermark information for each of the first sub-image regions, and generate a first QR code according to the first digital signature and the first watermark information;
[0094] An encryption module 1730 is used to encrypt the first sub-image area corresponding to the first QR code to obtain a first target sub-image area;
[0095] The stitching module 1740 is used to stitch the M first target sub-image regions to obtain an encrypted first target image.
[0096] It should be noted that the aforementioned explanation of the embodiment of the image encryption method is also applicable to the image encryption device of this embodiment, and will not be repeated here.
[0097] Based on the above embodiments, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in the above embodiments is implemented.
[0098] In order to implement the above embodiments, the present invention further proposes a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method described in the above embodiments is implemented.
[0099] In order to implement the above embodiment, the present invention further proposes a computer program product. When an instruction processor in the computer program product executes, the above-mentioned image encryption method is executed.
[0100] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0101] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0102] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present invention belong.
[0103] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0104] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0105] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0106] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0107] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.
Claims
1. An image encryption method, characterized in that: The following steps are involved: Acquire an original image, and divide the original image into M first sub-image areas according to preset size information, where M is a natural number greater than 1; Calculating a first digital signature and a first watermark information for each of the first sub-image regions, and generating a first QR code according to the first digital signature and the first watermark information; Encrypting the first sub-image area corresponding to the first QR code to obtain a first target sub-image area; Obtaining an encrypted first target image by splicing the M first target sub-image regions; The calculating of the first digital signature and the first watermark information of each of the first sub-image regions comprises: Performing DCT and DWT transformation on each of the first sub-image regions to obtain a reference matrix; Extracting a matrix region of a preset region of the reference matrix, and calculating a mean value of DCT coefficients of the region; Compare each DCT coefficient in the matrix area with the DCT coefficient mean, and generate a signature value corresponding to each DCT coefficient according to the comparison result, wherein if the comparison result is that the DCT coefficient is greater than or equal to the DCT coefficient mean, then determine that the signature value of the corresponding DCT coefficient is 1, and if the comparison result is that the DCT coefficient is less than the DCT coefficient mean, then determine that the signature value of the corresponding DCT coefficient is 0; Taking a DCT coefficient matrix composed of all signature values in the matrix area and a character string composed of DCT coefficients in the DCT coefficient matrix as a first digital signature corresponding to the first sub-image area; Acquire image source information of the original image, and generate first watermark information of the first sub-image area according to the image source information; The generating a first QR code according to the first digital signature and the first watermark information includes: After splicing the first digital signature and the first watermark information to obtain splicing information, performing binary conversion on the splicing information to obtain the first QR code; The method further comprises: Acquire a second target image, and divide the original image into M second sub-image areas according to the preset size information, where M is a natural number greater than 1; extracting the second QR code from each of the second sub-image regions, and the third sub-image region after removing the second QR code; Extracting a second digital signature and a second watermark information corresponding to the second QR code; Determining whether the second digital signature and the second watermark information of each of the third sub-image regions are consistent with the first digital signature and the first watermark information of the first sub-image region at the corresponding position; If they are consistent, determining whether the corresponding third sub-image region is consistent with the first sub-image region at the corresponding position; If they are consistent, determining that the corresponding third sub-image area is the same as the first sub-image area at the corresponding position; If they are consistent, determining whether the corresponding third sub-image area is consistent with the first sub-image area at the corresponding position includes: extracting a first image feature of the third sub-image area; extracting a second image feature of the first sub-image area; Calculating a Hamming distance between the first image feature and the second image feature; It is determined whether the Hamming distance is less than a preset threshold.
2. The method according to claim 1, characterized in that The step of encrypting the first sub-image area corresponding to the first QR code to obtain a first target sub-image area includes: Adding the first QR code to a preset position of the reference matrix to generate a target matrix corresponding to each of the first sub-image areas; IDWT and IDCT transformations are performed on the target matrix to obtain a first target sub-image region corresponding to each of the first sub-image regions.
3. The method according to claim 2, characterized in that The extracting the second QR code from each of the second sub-image regions, and removing the third sub-image region after the second QR code is removed, comprises: Performing DWT and DCT transformation on each of the second sub-image regions to obtain a second target sub-image region corresponding to each of the second sub-image regions; Determine the second QR code in the second target sub-image area at a preset storage location, and remove the second QR code from the second target sub-image area to obtain a fourth target sub-image area; Perform IDWT and IDCT transformations on the fourth target sub-image region to obtain the third sub-image region.
4. An image encryption device, characterized in that: The image encryption device implements the image encryption method according to claim 1, comprising: A division module, used for acquiring an original image, and dividing the original image into M first sub-image regions according to preset size information, where M is a natural number greater than 1; A generating module, configured to calculate a first digital signature and a first watermark information for each of the first sub-image regions, and generate a first QR code according to the first digital signature and the first watermark information; An encryption module, used for encrypting the first sub-image area corresponding to the first QR code to obtain a first target sub-image area; A splicing module is used to splice the M first target sub-image areas to obtain an encrypted first target image.
5. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.
6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Apparatus and method for watermarking digital image
CN1771727A