A document tracking encryption method based on digital watermark
By embedding digital watermarks in electronic documents and using CRC-4 algorithm and character distance markers for verification after paperization, the problem that documents cannot verify their source after paperization is solved, and the security and reliable source of documents are achieved reduces the cost of manual inspection.
Patent Information
- Application Number
- CN202011516281.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2040-12-21
AI Technical Summary
The prior art cannot effectively protect paper-based electronic documents, resulting in a decrease in document security and the inability to verify the source and integrity of documents.
Using a document tracking and encryption method based on digital watermarks, the human eye is insensitive to subtle text distances, hides information between texts, and embeds and extracts watermarks through CRC-4 algorithm and character distance markers to ensure that the document is paper-based The source can still be verified.
It improves the security and reliability of the source of documents, reduces the cost of manual inspection, ensures the correctness of the source of documents, and prevents malicious tampering.
Smart Images

Figure CN112650992B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of information processing and management, and in particular relates to a document tracking encryption method based on digital watermark. Background Art
[0002] With the development of science and technology, economy and the popularization of the Internet, documents have become a guarantee for people to take up legal weapons to protect their legitimate interests. Since an important document contains a long content, in the era of popularization of computers, people often choose to send electronic documents to the other party for review in advance and stamp them directly on the spot to save time for both parties. If the source of electronic documents can be effectively verified, the security of the documents will be greatly improved. Summary of the invention
[0003] The current digital watermark technology for encrypting electronic documents will lose the security protection of the electronic documents after they are printed into paper documents. Therefore, the present invention provides a document tracking encryption method based on digital watermarks, which uses the human eye's insensitivity to the distance of fine text to hide information between texts. The implementation process includes a watermark embedding process and a watermark reading process.
[0004] The present invention specifically comprises the following steps:
[0005] Step 1, process the original file and complete the watermark embedding;
[0006] Step 2: Read the watermark of the document to be verified to complete the document verification.
[0007] Step 1 includes:
[0008] Step A1, convert the original files into JPG format images;
[0009] Step A2, preprocessing the image to obtain text coordinate information;
[0010] Step A3, using CRC-4 to calculate and obtain complete data;
[0011] Step A4, embedding the complete data loop into the image file to complete the watermark embedding process.
[0012] In step A1, the original file includes a file in doc, docx, or pdf format.
[0013] Step A2 includes: binarizing the image, identifying the text area, scanning line by line, counting and storing the number of pixels in each line, and if the number of pixels in the line is less than the reference value, determining that it is a blank gap in each line, extracting the blank gap between each line, and realizing line segmentation; for each line, detecting the gap between the characters, segmenting each character in the vertical direction, and finally obtaining the character coordinates; and calculating the position where the watermark can be embedded based on the character coordinate data.
[0014] Step A3 includes: using CRC-4 to calculate the check code that needs to be embedded in the watermark information, the watermark information is a randomly generated six-bit binary string, and the watermark information is spliced with the check code to obtain complete data.
[0015] Step A4 includes: according to the text coordinate data and the position where the watermark can be embedded calculated in step A2, and the length of the binary watermark information to be embedded, the watermark information length is the total length of the preset binary string plus the four-bit check code, calculating the number of cyclic embedding times t=l / (j+1), l represents the number of positions where the watermark can be embedded (for example, if the value is 6, it means that there are 6 positions where the watermark can be embedded), j is the length of the binary watermark information, when t is greater than or equal to 1, start to perform the following watermark embedding operation, otherwise it cannot be embedded:
[0016] Data identification is achieved by character distance marking. There are two types of markers: information marker and end marker.
[0017] Information markers refer to: starting from the marker position, the distance between the previous and next characters is 4px and 0px, corresponding to 1 and 0 respectively;
[0018] The end marker means: starting from the marker position, the distance between the previous and next characters is 6px;
[0019] According to the information marker and the end marker, the target text is moved cyclically until the entire text is covered to complete the watermark embedding.
[0020] Step 2 includes:
[0021] Step B1, converting the paper document to be verified into an image;
[0022] Step B2, performing image preprocessing to obtain text coordinate information;
[0023] Step B3, calculating watermark information according to the text coordinate information;
[0024] Step B4, verify the watermark information, return the verified binary information, and complete the watermark decryption process.
[0025] Step B2 includes:
[0026] Convert the paper document into an image, use OpenCV's image grayscale and binarization technology to convert the image into black and white, select the white area, use the black hat algorithm to highlight the text content, select the circumscribed rectangle of the text area and use the affine transformation in OpenCV to project the image proportionally onto a new image G with the same width as the original document;
[0027] By checking the red pixels, it is determined whether there is a seal in image G. The image is converted to HVS color gamut using OpenCV. The pixels with color values between (156, 43, 46) and (180, 255, 255) and (0, 43, 46) and (9, 255, 255) are extracted and written into a new image. The size of the new image is equal to that of image G. The contour search method in OpenCV is used to extract the seal contour area in the new image. The valid pixels in the seal contour area are replaced with white to achieve seal removal.
[0028] For the image obtained after the above processing, the method in step A2 is used to obtain the position where the watermark can be embedded.
[0029] Step B3 includes: according to the position where the watermark can be embedded obtained in step B2, obtaining binary information according to the information marker specification, and using the characteristics of the end marker to split the entire piece of information into multiple pieces of binary information.
[0030] Step B4 includes: according to the binary information obtained in step B3, cyclically checking using the CRC-4 method, if the check result has no remainder, it means that the check is passed, and the check result that passes the check and occurs most frequently is returned as the correct result.
[0031] Beneficial effects:
[0032] The present invention fills the gap in digital watermark encryption technology for paper documents on the market, and the embedded watermark is invisible. Through a large number of tests and verifications, a denoising algorithm is used to remove the seal, and the watermark extraction algorithm is optimized, which greatly improves the correctness of watermark extraction. The average time for watermark recognition is about 500 milliseconds, which can effectively reduce the cost of manual inspection. The technology is used to encrypt relevant documents to ensure the reliability of the document source. Then, the encrypted document can be verified to ensure the correctness of the document source to prevent the document from being maliciously tampered with. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and the above and other advantages of the present invention will become more clear.
[0034] Figure 1 This is the process of obtaining the CRC-4 check code.
[0035] Figure 2 It is the CRC-4 data verification process.
[0036] Figure 3 This is a schematic diagram of the process of embedding watermarks in a document.
[0037] Figure 4 It is a schematic diagram of the recognition image preprocessing process.
[0038] Figure 5 It is a schematic diagram of the process of obtaining and verifying watermark information based on coordinate information.
[0039] Figure 6 It is a schematic diagram of the target text selected according to the text coordinates and embedding rules. DETAILED DESCRIPTION
[0040] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0041] like Figure 3 , Figure 4 , Figure 5 As shown, the present invention provides a document tracking encryption method based on digital watermark, comprising:
[0042] Watermark embedding process:
[0043] Step A1, converting the original files into JPG format image documents;
[0044] Step A2, preprocessing the image document, including binarization, text area selection, line segmentation, character segmentation, etc., and finally obtaining the text coordinate information;
[0045] Step A3, using CRC-4 to calculate and obtain complete data;
[0046] Step A4, embedding the complete data loop into the image file to complete the watermark embedding process.
[0047] Watermark reading process:
[0048] Step B1, using a capture device to convert a paper document into an image;
[0049] Step B2, image preprocessing, including correction, stamp removal, scaling to the original image width, binarization, text area selection, line segmentation, character segmentation, etc., and finally obtaining text coordinate information;
[0050] Step B3, calculating watermark information according to the obtained character spacing;
[0051] Step B4, verify the watermark information and return the verified binary information to complete the watermark decryption process;
[0052] In step A1, the original file is a file in doc, docx or pdf format.
[0053] Step A2 includes: binarizing the image (2480px*3500px), then identifying the text area, scanning line by line, counting and storing the number of pixels in each line, and if the number of pixels in a line is less than a reference value (generally set to 50 pixels), it is determined to be a blank gap in each line, extracting the blank gap between each line to achieve line segmentation; for each line, detecting the gap between the characters, segmenting each character in the vertical direction, and finally obtaining the character coordinates. The position where the watermark can be embedded is calculated based on the character coordinate data (the first and last position of each line, and the gap distance after the sign bit and before the character is greater than 30px).
[0054] Step A3 includes: using CRC-4 to calculate the check code to be embedded in the watermark information, the watermark information is a randomly generated six-bit binary string, and the watermark information is spliced with the check code to obtain the complete data. For example, a binary code (e.g.: 101010), with a total of m bits, is used as a check method using CRC-4, and its polynomial is: G(x) = x 4 +x+1, the 0th, 1st, and 4th digits of the divisor are calculated by the polynomial to be 1, that is, 10011 is used as the divisor, a total of 5 (k) digits, the remainder digit is one digit lower than the divisor, and the number of supplementary digits can be obtained: i=k-1, the number of complete data digits: j=m+k-1, the original data is supplemented with 4 digits of 0 to obtain the data (1010100000), and the modulo-2 division is used to obtain the remainder (111). If it is less than 4 digits, it is supplemented with 0 to obtain the check code (0111), and the complete data (1010100111) is saved. Figure 1 shown.
[0055] Step A4 includes: according to the text coordinate data and the position where the watermark can be embedded calculated in step A2, and the length of the binary watermark information to be embedded, the watermark information length is the total length of the preset binary string plus the four-bit check code, calculating the number of cyclic embedding times t=l / (j+1), l represents the number of positions where the watermark can be embedded, j is the length of the binary watermark information, when t is greater than or equal to 1, starting to perform the following watermark embedding operation, otherwise it cannot be embedded:
[0056] Image embedded data: Data identification is achieved by character distance marking. There are two types of markers: information marker (starting from the marker position, the distance between the previous and next characters is 4px / 0px, corresponding to 1 / 0 respectively), end marker (starting from the marker position, the distance between the previous and next characters is 6px). Based on the above characteristics, the target text is moved cyclically, such as Figure 6 Mark the position in the box until the entire text is covered to complete the watermark embedding.
[0057] Step B1 includes: using a capture device to convert a paper document into an electronic image.
[0058] Step B2 includes:
[0059] Crop and correct the paper document image: Use OpenCV's image grayscale and binarization technology to convert the image into black and white, select the white area, use the black hat algorithm to highlight the text content, select the circumscribed rectangle of the text area and use the affine transformation in OpenCV to project the image proportionally onto a new image with the same width as the original document;
[0060] Stamp removal: Determine whether there is a stamp by checking the red pixels, use OpenCV to convert the image to HVS color gamut, extract pixels with color values between (156, 43, 46) and (180, 255, 255) and write them into a new image (the same size as the original image), use the contour search method in OpenCV to extract the stamp contour area in the new image, and replace the valid pixels in the contour area with white to achieve the stamp removal effect.
[0061] For the image obtained after the above processing, the method in step A2 is used to obtain the position where the watermark can be embedded.
[0062] Step B3 includes: according to the position where the watermark can be embedded obtained in step B2, binary information is obtained according to the information marker specification, and the whole information is split into multiple binary information segments using the characteristics of the end marker. For example, if the full text watermark content is 1010100111 1010100111 1010, 1 and 0 are watermark content markers, and the space is a segment separator. The full text content can be split into two segments 1010100111 and one segment 1010, and the information with insufficient length is discarded, and the two segments 1010100111 are used for verification.
[0063] Step B4 includes: cyclically checking the binary segment obtained in step B3 using the CRC-4 method, and the correct result has no remainder, such as Figure 2 As shown in the figure, the value that passes the check and has the highest weight is returned as the correct result and is verified by the system.
[0064] The present invention provides a document tracking encryption method based on digital watermark. There are many methods and ways to implement the technical solution. The above is only a preferred implementation of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the protection scope of the present invention. All components not specified in this embodiment can be implemented by existing technologies.
Claims
1. A document tracking encryption method based on digital watermark, It is characterized in that The steps include: Step 1, process the original file and complete the watermark embedding; Step 2: Read the watermark of the document to be verified to complete the document verification; Step 1 includes: Step A1, convert the original files into JPG format images; Step A2, preprocessing the image to obtain text coordinate information; Step A3, using CRC-4 to calculate and obtain complete data; Step A4, embedding the complete data loop into the image file to complete the watermark embedding process; In step A1, the original file includes a file in doc, docx, or pdf format; Step A2 includes: binarizing the image, identifying the text area, scanning line by line, counting and storing the number of pixels in each line, if the number of pixels in the line is less than the reference value, determining that it is a blank gap in each line, extracting the blank gap between each line, and realizing line segmentation; for each line, detecting the gap between the characters, segmenting each character in the vertical direction, and finally obtaining the character coordinates; calculating the position where the watermark can be embedded according to the character coordinate data; Step A3 includes: using CRC-4 to calculate the check code to be embedded in the watermark information, the watermark information is a randomly generated six-bit binary string, and the watermark information is spliced with the check code to obtain complete data; Step A4 includes: according to the text coordinate data and the position where the watermark can be embedded calculated in step A2, and the length of the binary watermark information to be embedded, the watermark information length is the total length of the preset binary string plus the four-bit check code, calculating the number of cyclic embedding times t=l / (j+1), l represents the number of positions where the watermark can be embedded, j is the length of the binary watermark information, when t is greater than or equal to 1, starting to perform the following watermark embedding operation, otherwise it cannot be embedded: Data identification is achieved by character distance marking. There are two types of markers: information marker and end marker. Information markers refer to: starting from the marker position, the distance between the previous and next characters is 4px and 0px, corresponding to 1 and 0 respectively; The end marker means that the distance between the previous and next characters is 6px from the marker position.
2. The method according to claim 1, It is characterized in that Step 2 includes: Step B1, converting the paper document to be verified into an image; Step B2, performing image preprocessing to obtain text coordinate information; Step B3, calculating watermark information according to the text coordinate information; Step B4, verify the watermark information, return the verified binary information, and complete the watermark decryption process.
3. The method according to claim 2, It is characterized in that Step B2 includes: Convert the paper document into an image, use OpenCV's image grayscale and binarization technology to convert the image into black and white, select the white area, use the black hat algorithm to highlight the text content, select the circumscribed rectangle of the text area and use the affine transformation in OpenCV to project the image proportionally onto a new image G with the same width as the original document; By checking the red pixels, it is determined whether there is a seal in image G. The image is converted to HVS color gamut using OpenCV. The pixels with color values between (156, 43, 46) and (180, 255, 255) and (0, 43, 46) and (9, 255, 255) are extracted and written into a new image. The size of the new image is equal to that of image G. The contour search method in OpenCV is used to extract the seal contour area in the new image. The valid pixels in the seal contour area are replaced with white to achieve seal removal. For the image obtained after the above processing, the method in step A2 is used to obtain the position where the watermark can be embedded.
4. The method according to claim 3, It is characterized in that Step B3 includes: according to the position where the watermark can be embedded obtained in step B2, obtaining binary information according to the information marker specification, and using the characteristics of the end marker to split the entire piece of information into multiple pieces of binary information.
5. The method according to claim 4, It is characterized in that Step B4 includes: according to the binary information obtained in step B3, cyclically checking using the CRC-4 method, if the check result has no remainder, it means that the check is passed, and the check result that passes the check and occurs most frequently is returned as the correct result.
Citation Information
Patent Citations
Method and device for tampering authentication of paper documents
CN108805787A
