Watermark embedding, extraction method, device and electronic equipment
By using DCT discrete cosine transformation and feature point technology in the watermark embedding and extraction methods, the problems of low efficiency and poor concealment in the existing technology are solved, and more efficient and accurate watermark processing is achieved, and robustness is improved.
Patent Information
- Application Number
- CN202010925638.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-04
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2040-09-04
AI Technical Summary
The existing watermark embedding and extraction methods are inefficient and poor in handling massive data, resulting in low accuracy of watermark extraction results, affecting work efficiency.
By acquiring the feature points of the grayscale image, determining the addition or extraction area based on the size of the watermark matrix, performing DCT discrete cosine transformation on the submatrix, calculating new coefficient pairs and inversely DCT replacement, realizing the embedding and extraction of the watermark image.
It improves the efficiency and accuracy of watermark embedding and extraction, and enhances the secrecy and robustness of watermark processing technology.
Smart Images

Figure CN112070648B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer data security, and in particular to a watermark embedding and extraction method, device and electronic equipment. Background Art
[0002] With the promotion of digital photography and photography technology and the development of Internet technology, the application of digital media (digital audio, digital images, digital video, etc.) is becoming more and more widespread, and the awareness of sensitive information protection and copyright protection of digital media is increasing. Digital watermarking technology has become an effective means to solve technical problems in this field. Existing watermark embedding and extraction methods embed watermarks in images with relatively simple backgrounds, which will reduce the confidentiality and affect the original image effect, and cannot balance confidentiality and robustness. When processing massive amounts of data, the current method cannot fully guarantee efficiency, and the accuracy of watermark extraction results is low, which will affect the progress of the entire task and reduce work efficiency. Summary of the invention
[0003] The embodiments of the present application provide a watermark embedding and extraction method, device and electronic device, which can solve the technical problems of low embedding and extraction efficiency, poor robustness and confidentiality of watermark technology. The technical solution is as follows:
[0004] In a first aspect, an embodiment of the present application provides a watermark embedding method, comprising:
[0005] Get the grayscale image to be watermarked;
[0006] Extracting a plurality of feature points of the grayscale image;
[0007] Get the watermark matrix;
[0008] Determine the watermark adding area of the grayscale image with each feature point as the center and the size of the watermark matrix;
[0009] Performing DCT discrete cosine transform on the submatrix in the watermark adding area to obtain a DCT coefficient matrix;
[0010] Taking two coefficients at preset positions in the DCT coefficient matrix as an initial coefficient pair;
[0011] Calculating new coefficient pairs based on the corresponding relationship between the watermark matrix and the sub-matrix;
[0012] Updating the new coefficient pair to the DCT coefficient matrix;
[0013] Perform inverse DCT on the updated DCT coefficient matrix to obtain an inverse DCT coefficient matrix, and replace the area at the corresponding position of the grayscale image with the inverse DCT coefficient matrix to obtain a watermark image.
[0014] In a second aspect, an embodiment of the present application provides a watermark extraction method, comprising:
[0015] Obtain a watermark image to be extracted;
[0016] Extracting a plurality of feature points of the watermark image;
[0017] Determine the watermark extraction area of the watermark image with each feature point as the center;
[0018] Performing DCT discrete cosine transform on the submatrix in the watermark extraction area to obtain a DCT coefficient matrix;
[0019] Taking two coefficients at preset positions in the DCT coefficient matrix as an initial coefficient pair;
[0020] According to the relationship between the initial coefficient pairs, a watermark matrix is parsed.
[0021] In a third aspect, an embodiment of the present application provides a watermark embedding device, the device comprising:
[0022] The acquisition module is used to acquire the grayscale image to be watermarked; and acquire the watermark matrix;
[0023] An extraction module, used to extract multiple feature points of the grayscale image; determine the watermark adding area of the grayscale image with each feature point as the center and the size of the watermark matrix;
[0024] A generating module, configured to perform DCT discrete cosine transform on the submatrix in the watermark adding area to obtain a DCT coefficient matrix; take two coefficients at preset positions in the DCT coefficient matrix as an initial coefficient pair; calculate a new coefficient pair based on the corresponding relationship between the watermark matrix and the submatrix; and update the new coefficient pair to the DCT coefficient matrix;
[0025] The replacement module is used to perform inverse DCT on the updated DCT coefficient matrix to obtain an inverse DCT coefficient matrix, and replace the area at the corresponding position of the grayscale image with the inverse DCT coefficient matrix to obtain a watermark image.
[0026] In a fourth aspect, an embodiment of the present application provides a watermark extraction device, the device comprising:
[0027] An acquisition module, used for acquiring a watermark image to be extracted;
[0028] An extraction module, used to extract multiple feature points of the watermark image; and determine a watermark extraction area of the watermark image with each feature point as the center;
[0029] A generating module, used for performing DCT discrete cosine transform on the sub-matrix in the watermark extraction area to obtain a DCT coefficient matrix;
[0030] The parsing module is used to take two coefficients at preset positions in the DCT coefficient matrix as an initial coefficient pair; and parse out a watermark matrix according to the relationship between the initial coefficient pairs.
[0031] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a memory and a processor; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.
[0032] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:
[0033] When the watermark embedding and extraction method, device and electronic device are working, the grayscale image to be watermarked is obtained, feature points are extracted, the adding area is determined based on the size of the watermark matrix, the DCT discrete cosine transform is performed on the submatrix in the area to obtain the coefficient matrix, the coefficient matrix is updated based on the correspondence between the watermark matrix and the submatrix, and the coefficient matrix is replaced with the corresponding position of the grayscale image after inverse DCT to obtain the watermark image. The extraction method is based on the embedding method for extraction. The embodiment of the present application can improve the efficiency of embedding and extracting watermarks and the accuracy of extracting watermarks, and improve the confidentiality and robustness of watermark processing technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] Figure 1 It is a flowchart of a watermark embedding method provided by an embodiment of the present application;
[0036] Figure 2 is a schematic diagram of a method for obtaining a watermark matrix provided in an embodiment of the present application;
[0037] Figure 3 This is a schematic diagram of determining a feature area using a feature point provided in an embodiment of the present application;
[0038] Figure 4 is a schematic diagram of determining the position of an initial coefficient pair provided in an embodiment of the present application;
[0039] Figure 5 is a schematic diagram of an update coefficient matrix provided in an embodiment of the present application;
[0040] Figure 6 is a schematic diagram of replacing a corresponding area provided in an embodiment of the present application;
[0041] Figure 7 It is a flow chart of a watermark extraction method provided in an embodiment of the present application;
[0042] Figure 8 It is a structural schematic diagram of a watermark embedding device provided in an embodiment of the present application;
[0043] Fig. 9 It is a structural schematic diagram of a watermark extraction device provided in an embodiment of the present application;
[0044] Fig.10 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0046] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0047] In the description of this application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previously associated objects are in an "or" relationship.
[0048] In order to solve the technical problems mentioned above that the embedding and extraction of watermarks in the traditional technology cannot well balance the confidentiality and robustness, cannot meet the efficiency when processing a large amount of data, and the watermark extraction accuracy is low, the embodiment of the present application can be implemented by relying on a computer program and can be run on a computer system based on the von Neumann system and equipped with a camera or a rotatable camera. The computer system can be a computer device equipped with a camera, such as a smart phone, a laptop computer, a tablet computer, etc.
[0049] In the following method embodiments, for the sake of convenience, only the execution subject of each step is introduced and described as a computer.
[0050] The following will be combined with the attached Figures 1 to 7 , the watermark embedding and extraction method provided in the embodiment of the present application is introduced in detail.
[0051] See also Figure 1 , which is a flow chart of a watermark embedding method provided in an embodiment of the present application. The method may include the following steps:
[0052] S101, obtaining a grayscale image to be watermarked.
[0053] Generally, a grayscale image refers to an image that is displayed as grayscale from the darkest black to the brightest white. In the field of digital image processing, before a computer processes an image, it is usually necessary to convert the original color image into a grayscale image using an algorithm, such as floating point algorithm, integer point algorithm, shift algorithm, and average algorithm. The computer can acquire images in real time through a camera, read image files stored on it, etc.
[0054] S102: Extract multiple feature points of the grayscale image.
[0055] Generally, feature points refer to points where the grayscale value of an image changes dramatically or points with large curvature on the edge of an image (i.e., the focus of two edges). Image feature points play a very important role in watermark processing algorithms and image matching algorithms based on feature points. Computers can extract feature points based on image geometric features, image grayscale change features, etc.
[0056] In one embodiment, the computer uses the SURF algorithm to calculate the Hessian matrix determinant of the grayscale image pixel points, and extracts multiple pixel points that meet preset conditions as feature points to obtain multiple feature points.
[0057] S103: Obtain a watermark matrix.
[0058] Generally, the computer needs to convert the watermark information into a binary watermark information sequence, and then convert the binary watermark information sequence into a watermark matrix, and fill the watermark matrix with 0. For example: image watermark information, text watermark information, audio watermark information, and video watermark information. Since the computer needs to determine multiple areas with the feature point as the center, the closer the determined area is to a square, the higher the image space utilization rate, and the watermark matrix should be kept as square as possible.
[0059] In one embodiment, the computer uses ASCII encoding to convert the watermark information into the binary watermark sequence, detects the length L of the binary watermark sequence, and sets the watermark sequence to an a×b watermark matrix in a column storage manner, wherein the a and b value selection rules satisfy the condition a·b≈L, so that the value of |ab|+|a·b-1| is the smallest, and a and b are integers greater than 1. Figure 2 As shown in the figure, the watermark information is encoded in ASCII to obtain a set of binary watermark sequences (1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0), with a length of 14. After calculation, a takes the value of 4, b takes the value of 4, and the column storage is set to 4×4 as shown in the figure. Since it cannot be fully filled, the remaining space is filled with 0.
[0060] S104, determining a watermark adding area of the grayscale image with each feature point as the center and the size of the watermark matrix.
[0061] Generally, the watermarking area refers to the location area where the watermark information is embedded in the image. To ensure the confidentiality of the watermarked image, the computer needs to accurately determine the watermarking area of the image. The embodiment of the present application uses the feature points extracted as the center of the feature area and determines the feature area based on the size of the watermark matrix.
[0062] In one embodiment, the computer uses a greedy algorithm to perform overlap judgment on the watermark adding area, and determines the watermark adding area that meets the preset conditions as the watermark adding area, wherein the size of the watermark adding area is (a·m)×(b·m), m×m is the size of the area sub-matrix, a·m is the area height, b·m is the area width, and a, b and m are integers greater than 1. Figure 3 As shown in the figure, each small square represents a pixel, and the dots on the figure represent the determined feature points. Assuming that the calculated values of a, b, and m are 3, the feature area is determined to be the area represented by the thick line with a matrix size of (3·3) × (3·3) with the feature point dot as the center. The feature area can be divided into 9 sub-matrices of 3×3 size.
[0063] S105, performing DCT discrete cosine transform on the sub-matrix in the watermark adding area to obtain a DCT coefficient matrix.
[0064] Generally, a submatrix refers to a small matrix divided in a feature region. For example, if the feature region is a matrix, the number of rows in the matrix is a·m, the number of columns is b·m, and the size of the submatrix is m×m, generally an 8×8 submatrix. Discrete Cosine Transform (DCT) is a transform related to Discrete Fourier Transform (DFT). It is similar to discrete DFT, but only uses real numbers. DCT is equivalent to a discrete DFT with a length of about twice that of DCT. This discrete DFT is performed on a real even function, and in some deformations, the input or output position needs to be moved by half a unit. When a computer performs DCT on a submatrix, it will obtain a coefficient matrix of the same size, and the binary watermark information is embedded by processing the submatrix.
[0065] S106: Take two coefficients at preset positions in the DCT coefficient matrix as an initial coefficient pair.
[0066] Generally, after the computer obtains the coefficient matrix, it is necessary to select two coefficients from the matrix as the initial coefficient pair. For example: when the computer obtains an 8×8 coefficient matrix, select the two coefficients (4,5) and (5,4) in the matrix as the initial coefficient pair. Figure 4 As shown, the coefficient matrix size is 8×8, and the coefficients corresponding to (4,5) and (5,4) in the matrix are selected as the initial coefficient pairs, where c1 takes the value of 0.735 and c2 takes the value of 0.529.
[0067] S107: Calculate new coefficient pairs based on the corresponding relationship between the watermark matrix and the sub-matrix.
[0068] Generally, the correspondence refers to the positional relationship between the elements on the watermark matrix and the submatrix of the feature region, because the size of the feature region is determined based on the size of the watermark matrix. The computer can embed the watermark information into the coefficient pair through the corresponding transformation formula. For example:
[0069] In real business scenarios, the categories of images such as certificates are clear. The d value in the following formula can be adjusted differently according to different types of images to achieve the optimal effect for that type of image.
[0070]
[0071] When the embedded watermark information is 0:
[0072]
[0073] When the embedded watermark information is 1:
[0074]
[0075] In the above formula, the values of q1 and q2 are 51 and 56, the value of r is 1, and c1 and c2 are the initial coefficient pairs of the two selected discrete cosine coefficients. The value can be adjusted according to the specific type of picture and is a dynamic value.
[0076] In one embodiment, the computer uses the calculated new coefficient pair as the initial coefficient pair to perform multiple cycles of processing to calculate new coefficient pairs. One calculation update is equivalent to embedding watermark information once. Generally, for an image with a simple background, it can be embedded about 10 times.
[0077] S108: Update the new coefficient pair to the DCT coefficient matrix.
[0078] Generally, the computer updates the new coefficient pair after calculation and transformation to the same position of the DCT coefficient matrix, and the other positions of the coefficient matrix remain unchanged. The computer needs to operate each sub-matrix in each feature area to complete the watermark information embedding. Figure 5 As shown, the initial coefficient pair c1 takes the value of 0.735 and c2 takes the value of 0.529. After calculation, the new coefficient pair c1 takes the value of 0.345 and c2 takes the value of 0.876. The new coefficient pair replaces the corresponding position of the coefficient matrix, and the coefficients in other positions remain unchanged. The watermark information has been embedded into the coefficient matrix.
[0079] S109, performing inverse DCT on the updated DCT coefficient matrix to obtain an inverse DCT coefficient matrix, and replacing the area at the corresponding position of the grayscale image with the inverse DCT coefficient matrix to obtain a watermark image.
[0080] Generally, a watermark image refers to an image after watermark information is embedded. Inverse DCT refers to performing DCT again on the coefficient matrix of the original matrix after DCT to obtain the original matrix. The computer performs inverse DCT on the updated coefficient matrix to obtain the original pixel matrix of the embedded watermark information, and replaces the corresponding area of the original image with this area to obtain the watermark image. Figure 6 As shown, the updated coefficient matrix is subjected to inverse DCT transformation to obtain a coefficient matrix with little change in the grayscale of the pixels in the original image. The coefficient matrix is used to replace the original image for the regional position, and the watermark is embedded in the original image to obtain the watermarked image. Since the grayscale of the pixels in this area does not change much, the confidentiality of the watermarked image is guaranteed.
[0081] From the above content, it can be seen that the grayscale image to be watermarked is obtained, feature points are extracted, the adding area is determined based on the size of the watermark matrix, the DCT discrete cosine transform is performed on the submatrix in the area to obtain the coefficient matrix, the coefficient matrix is updated based on the correspondence between the watermark matrix and the submatrix, and the coefficient matrix is replaced with the corresponding position of the grayscale image after inverse DCT to obtain the watermark image. The embodiment of the present application can improve the efficiency of embedding and improve the confidentiality and robustness of the watermark processing technology.
[0082] See also Figure 7 , a flow chart of a watermark extraction method is provided for an embodiment of the present application. The method may include the following steps:
[0083] S701, obtaining a watermark image from which watermark is to be extracted.
[0084] Generally, a watermark image refers to an image after watermark information is embedded. After the computer reads the watermark image, it first needs to be preprocessed, for example, image perspective transformation, ROI area extraction and image scaling. If the preprocessed watermark image is a color image, the computer needs to grayscale the color image. In the embodiment of the present application, the computer uses the Y channel algorithm to grayscale.
[0085] S702: Extract multiple feature points of the watermark image.
[0086] Generally, the computer uses the SURF algorithm to dynamically adjust the Hessian matrix determinant threshold to determine whether the watermark image pixel is a feature point. This threshold is different from the threshold when extracting feature points embedded in the watermark to determine multiple feature points.
[0087] S703: Determine a watermark extraction area of the watermark image with each feature point as the center.
[0088] Generally, the watermark extraction area refers to the area where the computer embeds the watermark information into the original image. After the computer extracts the feature point, the watermark extraction area is determined based on the size of the watermark matrix in the watermark embedding process, with the feature point as the center.
[0089] S704: Perform DCT discrete cosine transform on the sub-matrix in the watermark extraction area to obtain a DCT coefficient matrix.
[0090] Generally, in order to obtain a watermark matrix, a computer needs to perform a DCT discrete cosine transform on a sub-matrix in a watermark extraction area to obtain a DCT coefficient matrix.
[0091] S705: Take two coefficients at preset positions in the DCT coefficient matrix as an initial coefficient pair.
[0092] Generally, the computer selects two coefficients at preset positions in the obtained DCT coefficient matrix as initial coefficient pairs.
[0093] S706: Analyze the watermark matrix according to the relationship between the initial coefficient pairs.
[0094] In general, it can be known from the above embedding method that there is a size relationship between the initial coefficient pairs. For example, the coefficient pair is x and y, if x is greater than y, the pixel point of the watermark matrix corresponding to the submatrix is 1; if x is less than y, the pixel point of the watermark matrix corresponding to the submatrix is 0, and all sub-regions of all feature regions are judged to obtain the same number of initial watermark matrices as the feature regions, and all initial watermark matrices are judged, for example, different initial watermark matrices are selected to obtain the result value by XOR calculation, if the result value is less than the preset threshold, the initial watermark matrix is retained and further processed later; if the result value is greater than the preset threshold, the initial watermark matrix is filtered out. After the computer results are judged, the number of 0 or 1 at the same pixel position is counted based on the remaining watermark matrices, and more than half are determined as the value of the position on the final watermark matrix, and the watermark matrix is parsed;
[0095] As can be seen from the above content, a watermark image to be extracted is obtained, multiple feature points of the watermark image are extracted, and the watermark extraction area of the watermark image is determined with each feature point as the center, and a DCT discrete cosine transform is performed on the submatrix in the watermark extraction area to obtain a DCT coefficient matrix, and two coefficients at preset positions in the DCT coefficient matrix are taken as initial coefficient pairs, and the watermark matrix is parsed according to the relationship of the initial coefficient pairs. The embodiment of the present application can improve the efficiency and accuracy of extraction, and improve the confidentiality and robustness of watermark processing technology.
[0096] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0097] See also Figure 8 , which shows a schematic diagram of the structure of a watermark embedding device provided by an exemplary embodiment of the present application, hereinafter referred to as control device 8. Control device 8 can be implemented as all or part of the terminal through software, hardware or a combination of both. It includes:
[0098] The acquisition module 801 is used to acquire the grayscale image to be watermarked; and acquire the watermark matrix;
[0099] The extraction module 802 is used to extract multiple feature points of the grayscale image; determine the watermark adding area of the grayscale image based on each feature point as the center and the size of the watermark matrix;
[0100] The generating module 803 is used to perform DCT discrete cosine transform on the submatrix in the watermark adding area to obtain a DCT coefficient matrix; take two coefficients at preset positions in the DCT coefficient matrix as initial coefficient pairs; calculate new coefficient pairs based on the corresponding relationship between the watermark matrix and the submatrix; and update the new coefficient pairs to the DCT coefficient matrix;
[0101] The replacement module 804 is used to perform inverse DCT on the updated DCT coefficient matrix to obtain an inverse DCT coefficient matrix, and replace the area at the corresponding position of the grayscale image with the inverse DCT coefficient matrix to obtain a watermark image.
[0102] Optionally, the acquisition module 801 further includes:
[0103] The setting unit is used to convert the watermark information into the binary watermark sequence by using ASCII encoding; detect the length L of the binary watermark sequence; and set the watermark sequence to an a×b watermark matrix in a column storage manner; wherein the a and b value selection rules satisfy the condition a·b≈L, so that the value of |ab|+|a·b-1| is the smallest, and a and b are integers greater than 1.
[0104] Optionally, the extraction module 802 further includes:
[0105] The detection unit is used to calculate the Hessian matrix determinant of the grayscale image pixel points by using the SURF algorithm; and extract multiple pixel points that meet the preset conditions as feature points to obtain multiple feature points.
[0106] Optionally, the extraction module 802 further includes:
[0107] A judgment unit is used to use a greedy algorithm to perform overlapping judgment on the watermark adding area; and determine the watermark adding area that meets the preset conditions as the watermark adding area; wherein the size of the watermark adding area is (a·m)×(b·m), m×m is the size of the area sub-matrix, a·m is the area height, b·m is the area width, and a, b and m are integers greater than 1.
[0108] Optionally, the generating module 803 further includes:
[0109] The circulation unit is used to perform multiple circulation processes using the calculated new coefficient pair as the initial coefficient pair; and calculate the new coefficient pair.
[0110] The embodiments of this application and Figure 1 The method embodiments are based on the same concept, and the technical effects they bring are also the same. The specific process can be referred to Figure 1 The description of the method embodiment will not be repeated here.
[0111] The device 8 can be a field-programmable gate array (FPGA), a dedicated integrated chip, a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processing circuit, a microcontroller unit (MCU), and a programmable logic device (PLD) or other integrated chips.
[0112] When the scheme of the embodiment of the present application is executed, the grayscale image to be watermarked is obtained, feature points are extracted, the adding area is determined based on the size of the watermark matrix, the DCT discrete cosine transform is performed on the submatrix in the area to obtain a coefficient matrix, the coefficient matrix is updated based on the correspondence between the watermark matrix and the submatrix, and the coefficient matrix is replaced with the corresponding position of the grayscale image after inverse DCT to obtain the watermark image. The embodiment of the present application can improve the efficiency of embedding and improve the confidentiality and robustness of the watermark processing technology.
[0113] See also Fig. 9 , which shows a schematic diagram of the structure of a watermark extraction device provided by an exemplary embodiment of the present application, hereinafter referred to as control device 9. Control device 9 can be implemented as all or part of the terminal through software, hardware or a combination of both. It includes:
[0114] An acquisition module 901 is used to acquire a watermark image to be extracted;
[0115] The extraction module 902 is used to extract multiple feature points of the watermark image; determine the watermark extraction area of the watermark image with each feature point as the center;
[0116] A generating module 903 is used to perform DCT discrete cosine transform on the sub-matrix in the watermark extraction area to obtain a DCT coefficient matrix;
[0117] The parsing module 904 is used to take two coefficients at preset positions in the DCT coefficient matrix as an initial coefficient pair; and parse out a watermark matrix according to the relationship between the initial coefficient pairs.
[0118] Optionally, the acquisition module 901 further includes:
[0119] The first judgment unit is used to judge whether the original image is a grayscale image. If not, the original image is converted into a grayscale image; and the grayscale image is obtained as a watermark image to be extracted.
[0120] Optionally, the parsing module 904 further includes:
[0121] The second judging unit is used to judge all the watermark matrices, filter out the watermark matrices that do not meet the preset conditions, and parse out the watermark matrix based on the remaining watermark matrices.
[0122] The embodiments of this application and Figure 7 The method embodiments are based on the same concept, and the technical effects they bring are also the same. The specific process can be referred to Figure 7 The description of the method embodiment will not be repeated here.
[0123] The device 9 can be a field-programmable gate array (FPGA), a dedicated integrated chip, a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processing circuit, a microcontroller unit (MCU), and a programmable logic device (PLD) or other integrated chips.
[0124] When the scheme of the embodiment of the present application is executed, a watermark image to be extracted is obtained, multiple feature points of the watermark image are extracted, and the watermark extraction area of the watermark image is determined with each feature point as the center, and a DCT discrete cosine transform is performed on the submatrix in the watermark extraction area to obtain a DCT coefficient matrix, and two coefficients at preset positions in the DCT coefficient matrix are taken as initial coefficient pairs, and the watermark matrix is parsed according to the relationship between the initial coefficient pairs. The embodiment of the present application can improve the efficiency and accuracy of extraction, and improve the confidentiality and robustness of watermark processing technology.
[0125] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the template control method described in the above embodiments.
[0126] See also Fig.10 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device 10 may include: at least one processor 1001 , at least one network interface 1004 , a user interface 1003 , a memory 1005 , and at least one communication bus 1002 .
[0127] The communication bus 1002 is used to realize the connection and communication between these components.
[0128] The user interface 1003 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 1003 may also include a standard wired interface and a wireless interface.
[0129] The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0130] Among them, the processor 1001 may include one or more processing cores. The processor 1001 uses various interfaces and lines to connect various parts in the entire terminal 1000, and executes various functions and processes data of the terminal 1000 by running or executing instructions, programs, code sets or instruction sets stored in the memory 1005, and calling data stored in the memory 1005. Optionally, the processor 1001 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 1001 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 1001, and it can be implemented separately through a chip.
[0131] Among them, the memory 1005 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer-readable storage medium. The memory 1005 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 1005 may also be optionally at least one storage device located away from the aforementioned processor 1001. As Fig.10 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a watermark embedding and extraction application.
[0132] exist Fig.10 In the electronic device 1000 shown, the user interface 1003 is mainly used to provide an input interface for the user and obtain the data input by the user; and the processor 1001 can be used to call the watermark embedding and extraction application stored in the memory 1005, and specifically perform the following operations:
[0133] Get the grayscale image to be watermarked;
[0134] Extracting a plurality of feature points of the grayscale image;
[0135] Get the watermark matrix;
[0136] Determine the watermark adding area of the grayscale image with each feature point as the center and the size of the watermark matrix;
[0137] Performing DCT discrete cosine transform on the submatrix in the watermark adding area to obtain a DCT coefficient matrix;
[0138] Taking two coefficients at preset positions in the DCT coefficient matrix as an initial coefficient pair;
[0139] Calculating new coefficient pairs based on the corresponding relationship between the watermark matrix and the sub-matrix;
[0140] Updating the new coefficient pair to the DCT coefficient matrix;
[0141] Perform inverse DCT on the updated DCT coefficient matrix to obtain an inverse DCT coefficient matrix, and replace the area at the corresponding position of the grayscale image with the inverse DCT coefficient matrix to obtain a watermark image.
[0142] This application also includes:
[0143] Obtain a watermark image to be extracted;
[0144] Extracting a plurality of feature points of the watermark image;
[0145] Determine the watermark extraction area of the watermark image with each feature point as the center;
[0146] Performing DCT discrete cosine transform on the submatrix in the watermark extraction area to obtain a DCT coefficient matrix;
[0147] Taking two coefficients at preset positions in the DCT coefficient matrix as an initial coefficient pair;
[0148] According to the relationship between the initial coefficient pairs, a watermark matrix is parsed.
[0149] In one embodiment, the processor 1001 executes obtaining a watermark matrix, including:
[0150] Using ASCII encoding, converting the watermark information into the binary watermark sequence;
[0151] Detecting the length L of the binary watermark sequence;
[0152] The watermark sequence is set as an a×b watermark matrix in a column storage manner;
[0153] Among them, the selection rule of a and b values satisfies the condition a·b≈L, so that the value of |ab|+|a·b-1| is minimized, and a and b are integers greater than 1.
[0154] In one embodiment, the processor 1001 performs the step of extracting a plurality of feature points of the grayscale image, including:
[0155] Calculate the Hessian matrix determinant of the grayscale image pixel points using the SURF algorithm;
[0156] A plurality of pixel points satisfying a preset condition are extracted as feature points to obtain a plurality of feature points.
[0157] In one embodiment, the processor 1001 determines the watermark adding area of the grayscale image with each feature point as the center and the size of the watermark matrix, including:
[0158] Using a greedy algorithm to perform overlap judgment on the watermark adding area;
[0159] Determine the watermark area that meets the preset conditions as the watermark adding area;
[0160] The size of the watermark adding area is (a·m)×(b·m), where m×m is the area submatrix size, a·m is the area height, b·m is the area width, and a, b and m are integers greater than 1.
[0161] In one embodiment, the processor 1001 calculates a new coefficient pair based on the corresponding relationship between the watermark matrix and the sub-matrix, including:
[0162] Perform multiple cycles of processing using the calculated new coefficient pair as the initial coefficient pair;
[0163] Compute new coefficient pairs.
[0164] In one embodiment, the processor 1001 performs the following steps to parse out a watermark matrix according to the relationship between each pair of initial coefficients:
[0165] Judging all the watermark matrices, and filtering the watermark matrices that do not meet the preset conditions;
[0166] A watermark matrix is parsed based on the remaining watermark matrix.
[0167] The technical concept and Figure 1 or Figure 7 The technical concept is the same as that of Figure 1 or Figure 7 The method embodiments are not described in detail here.
[0168] In an embodiment of the present application, a grayscale image to be watermarked is obtained, feature points are extracted, the area to be added is determined based on the size of the watermark matrix, a DCT discrete cosine transform is performed on the submatrix in the area to obtain a coefficient matrix, the coefficient matrix is updated based on the correspondence between the watermark matrix and the submatrix, and the coefficient matrix is inversely DCTed and replaced to the corresponding position of the grayscale image to obtain a watermark image. The extraction method is based on the embedding method for extraction. The embodiment of the present application can improve the efficiency of embedding and extracting watermarks and the accuracy of extracting watermarks, and improve the confidentiality and robustness of watermark processing technology.
[0169] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A watermark embedding method, characterized in that: The method comprises: Get the grayscale image to be watermarked; Extracting a plurality of feature points of the grayscale image; Get the watermark matrix; Determine the watermark adding area of the grayscale image with each feature point as the center and the size of the watermark matrix; Based on the size of the watermark adding area, dividing the watermark adding area into a plurality of sub-matrices; Performing DCT discrete cosine transform on each of the sub-matrices in the watermark adding area to obtain multiple DCT coefficient matrices; Taking two coefficients at preset positions in each of the DCT coefficient matrices as initial coefficient pairs; Calculating new coefficient pairs based on the corresponding relationship between the watermark matrix and each of the sub-matrices; Updating the new coefficient pairs to each of the DCT coefficient matrices; Perform inverse DCT on each of the updated DCT coefficient matrices to obtain multiple inverse DCT coefficient matrices, and use the multiple inverse DCT coefficient matrices to replace the areas at corresponding positions of the grayscale image to obtain a watermark image.
2. The method according to claim 1, characterized in that: The step of obtaining a watermark matrix comprises: Using ASCII encoding, the watermark information is converted into a binary watermark sequence; Detecting the length L of the binary watermark sequence; The watermark sequence is set as an a×b watermark matrix in a column storage manner; Among them, the selection rule of a and b values satisfies the condition a·b≈L, so that the value of |ab|+|a·b-1| is minimized, and a and b are integers greater than 1.
3. The method according to claim 1, characterized in that: The extracting a plurality of feature points of the grayscale image comprises: Calculate the Hessian matrix determinant of the grayscale image pixel points using the SURF algorithm; A plurality of pixel points satisfying a preset condition are extracted as feature points to obtain a plurality of feature points.
4. The method according to claim 1, characterized in that: The step of determining the watermark adding area of the grayscale image with each feature point as the center and the size of the watermark matrix comprises: Using a greedy algorithm to perform overlap judgment on the watermark adding area; Determine the watermark area that meets the preset conditions as the watermark adding area; The size of the watermark adding area is (a·m)×(b·m), m×m is the area submatrix size, a·m is the area height, b·m is the area width, and a, b and m are integers greater than 1.
5. The method according to claim 1, characterized in that: The calculating new coefficient pairs based on the corresponding relationship between the watermark matrix and each of the sub-matrices comprises: Perform multiple cycles of processing using the calculated new coefficient pair as the initial coefficient pair; Compute new coefficient pairs.
6. A watermark extraction method, characterized in that: The method comprises: Obtain a watermark image to be extracted; Extracting a plurality of feature points of the watermark image; Determine the watermark extraction area of the watermark image with each feature point as the center; Based on the size of the watermark extraction area, dividing the watermark extraction area into a plurality of sub-matrices; Performing DCT discrete cosine transform on each of the sub-matrices in the watermark extraction area to obtain multiple DCT coefficient matrices; Taking two coefficients at preset positions in each of the DCT coefficient matrices as initial coefficient pairs; According to the relationship between the initial coefficient pairs in each of the DCT coefficient matrices, multiple watermark matrices are parsed.
7. The method according to claim 6, characterized in that: The method of parsing multiple watermark matrices based on the relationship between each pair of initial coefficients includes: Judging all the watermark matrices, and filtering the watermark matrices that do not meet the preset conditions; A watermark matrix is parsed based on the remaining watermark matrix.
8. A watermark embedding device, characterized in that: include: An acquisition module, used for acquiring a grayscale image to be watermarked; Get the watermark matrix; An extraction module, used for extracting a plurality of feature points of the grayscale image; Determine the watermark adding area of the grayscale image with each feature point as the center and the size of the watermark matrix; A generating module is used to divide the watermark adding area into a plurality of sub-matrices based on the size of the watermark adding area; perform DCT discrete cosine transform on each of the sub-matrices in the watermark adding area to obtain a plurality of DCT coefficient matrices; take two coefficients at a preset position in each of the DCT coefficient matrices as an initial coefficient pair; calculate a new coefficient pair based on the corresponding relationship between each of the watermark matrices and the sub-matrices; and update the new coefficient pair to each of the DCT coefficient matrices; The replacement module is used to perform inverse DCT on each of the updated DCT coefficient matrices to obtain multiple inverse DCT coefficient matrices, and replace the areas at corresponding positions of the grayscale image with the multiple inverse DCT coefficient matrices to obtain a watermark image.
9. A watermark extraction device, characterized in that: include: An acquisition module, used for acquiring a watermark image to be extracted; An extraction module, used for extracting a plurality of feature points of the watermark image; Determine the watermark extraction area of the watermark image with each feature point as the center; A generating module, configured to divide the watermark extraction region into a plurality of sub-matrices based on the size of the watermark extraction region; and perform DCT discrete cosine transform on each of the sub-matrices in the watermark extraction region to obtain a plurality of DCT coefficient matrices; A parsing module, used for taking two coefficients at preset positions in each of the DCT coefficient matrices as initial coefficient pairs; According to the relationship between the initial coefficient pairs in each of the DCT coefficient matrices, multiple watermark matrices are parsed.
10. An electronic device, characterized in that: include: A memory and a processor; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 7.
