A method for resisting printed and scanned digital watermarking of text images

By adjusting the ASM of text image characters to embed and extract watermarks, the problem of low watermark capacity in text images is solved, and highly robust watermark embedding and extraction under printing and scanning attacks is achieved.

CN120997026BActive Publication Date: 2026-03-06浣江实验室
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-22
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

Existing digital watermarking technologies have low embedding capacity in text images and are not suitable for print scanning attacks, especially for altering formal documents.

Method used

Watermarks are embedded and extracted by adjusting the average skeleton quality (ASM) of each character in the text image. A blind watermarking algorithm is used, which does not require the original document and is applicable to text images of different languages ​​and fonts.

Benefits of technology

It achieves high-capacity watermark embedding and extraction in text images, resists printing and scanning attacks, is applicable to multiple languages ​​and fonts, and does not change the text content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120997026B_ABST
    Figure CN120997026B_ABST
Patent Text Reader

Abstract

This invention discloses a method for anti-printing and scanning digital watermarking of text images. The algorithm is based on a stroke-like concept for embedding and extracting watermarks. During embedding, characters are segmented and the average skeleton quality (ASM) of each character is determined. Each pair of characters is grouped together, and the ASM of each group of characters is modified according to the information to be embedded to embed the watermark and replace the corresponding characters in the source document. During extraction, ASM is also extracted in pairs of characters. Watermark information is extracted by comparing the ASMs between characters. This application can embed 1 bit of information into two characters, and the character language type and font are not limited. While ensuring the amount of watermark information in the document, it effectively solves the problems of algorithm limitations between different languages ​​and poor robustness and small capacity of digital watermarks in the spatial domain and transform domain against printing and scanning attacks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of digital watermarking technology, and in particular to a method for anti-printing and anti-scanning digital watermarking of text images. Background Technology

[0002] Text data, such as medical records, contracts, and identification documents, plays a crucial role in people's daily lives. Digital watermarking and data hiding technologies have emerged to address this need, enabling the seamless embedding of copyright information into multimedia data. However, most previous image watermarking schemes were designed for color and grayscale images, making them unsuitable for text images, as text images lack redundant information, especially after printing and scanning. Therefore, researching watermarking technologies that can remain intact during printing and scanning is essential. Currently, anti-printing and anti-scanning watermark embedding methods can be broadly categorized into three types: image-based methods, format-based methods, and language-based methods.

[0003] The shortcomings of existing watermarking technologies are: 1) Most image-based methods are based on pixel flipping, which has low capacity and requires high-performance printing and scanning equipment; 2) Most format-based methods are not blind watermarks and also have the disadvantage of low embedding capacity; 3) Existing language-based methods embed watermarks by changing the syntactic and semantic properties of the text, but they are not suitable for some formal documents because some formal documents do not allow changes to the text content, so their applicability is not very wide. Summary of the Invention

[0004] To achieve the above objectives, the present invention is implemented through the following technical solution:

[0005] The present invention provides a method for anti-printing and anti-scanning digital watermarking of text images, the method comprising a watermark embedding process and a watermark extraction process;

[0006] The watermark embedding process includes the following steps:

[0007] Sa-1: Convert the target document into an image and perform binarization to generate a binary text image I;

[0008] Sa-2: Each character in the text image I is segmented using a projection method, denoted as C1, C2, ..., C6. n , where n is the total number of characters;

[0009] Sa-3: Filter the first 2L characters and extract their ASM, where ASM is the average skeleton quality and L is the number of watermark bits;

[0010] Sa-4: Each pair of characters is grouped into two, denoted as... , until , starting from the first character group, watermark bits w1, w2 up to w L are embedded, where L is the number of watermark bits; the ASM of the first character of each character group is denoted as ASM1, and the ASM of the last character is denoted as ASM2; if the current watermark bit is 0, increase ASM1 and decrease ASM2 in the group until ASM1 > ASM2 + th; if the current watermark bit is 1, decrease ASM1 and increase ASM2 in the group until ASM1 < ASM2 - th; where th is a preset value with a range of 0.1 - 0.5; denote the character group after embedding the watermark as , and replace the character with , and repeat the operation until all L watermark bits are embedded;

[0011] Sa-5: Generate a text image with an embedded watermark;

[0012] The watermark extraction process includes the following steps:

[0013] Sb-1: Correct the orientation of the printed and scanned image and remove isolated noise points;

[0014] Sb-2: Convert the corrected image into a binary text image I w ;

[0015] Sb-3: Segment each character in the binary text image I w by the projection method, and denote it as , where n is the total number of characters and is the same as that during embedding;

[0016] Sb-4: Screen the first 2L embeddable characters, extract their ASMs, and record every two characters as a group , the ASM of the first character of each character group is denoted as , and the ASM of the last character is denoted as ;

[0017] Sb-5: Extract the watermark starting from the first group of characters: If , the extracted watermark information is 0; if , the extracted watermark information is 1; until bits of information are extracted and then end;

[0018] Among them, the ASM extraction algorithm is: Assume the size of the current character is (M, N), M is the number of pixel rows of the character height, N is the number of pixel columns of the character width, and count the number of black pixels in the character ; Extract the skeleton length of the character through the skeleton extraction algorithm, that is, the total length of the skeleton pixel points, and the formula is: 。

[0019] Preferably, the projection method described in step Sa-2 is an optimized projection method that removes punctuation marks and is based on the traditional projection method. The specific process of the optimized projection method is as follows:

[0020] First, extract row information and divide character blocks based on the characteristics of character connected components; for the binary text image I, set the white background to 1 and the black text to 0; calculate the pixel sum row by row, and divide the area with a sum of 0 into the text area, thereby obtaining the number of rows and the top and bottom boundaries of each row;

[0021] Then, calculate the column pixel sum for each row, and obtain the left and right boundaries of each character block based on character connectivity; subsequently, judge the width and black pixel height of the character block. If the width is less than 0.4 times the row height and the black pixel height is less than 0.6 times the row height, it is determined as a punctuation mark; the method for judging that a character block is a single character is as follows: check the width of the character block. If the width is between times the row height and b times the row height; where a is 0.6 - 0.7 and b is 1 - 1.1, it is considered a Chinese character; after discarding the punctuation marks, judge whether 3, 2, or 1 consecutive character blocks are a Chinese character in sequence, so as to determine the character position.

[0022] Preferably, in steps Sa-3, Sa-4, Sb-4, and Sb-5, ASM is the average skeleton quality and the pixel width included in the strokes.

[0023] Preferably, the embedding situation in step Sa-4 is divided into the following four types. Let the current character group be , specifically as follows:

[0024] When the watermark bit is 1, if ASM1≥ASM2 - th, decrease ASM1 and increase ASM2 until ASM1 < ASM2 - th;

[0025] When the watermark bit is 1, if ASM1 < ASM2 - th, keep it unchanged;

[0026] When the watermark bit is 0, if ASM1≤ASM2 + th, increase ASM1 and decrease ASM2 until ASM1 > ASM2 + th;

[0027] When the watermark bit is 0, if ASM1 > ASM2 - th, keep it unchanged.

[0028] Preferably, the ASM adjustment for the current character group includes two operations: "decrease ASM1 and increase ASM2" and "increase ASM1 and decrease ASM2":

[0029] Among them, the operation steps of "reducing ASM1 and increasing ASM2" are as follows:

[0030] Si-1: Flip the black pixels in the first character and the white pixels in the last character, initially reduce ASM1 and increase ASM2, and compare the magnitudes of ASM1 and ASM2-th; if ASM1 < ASM2-th, the adjustment is completed;

[0031] Si-2: If ASM1 ≥ ASM2-th, make the thickest stroke in the first character thinner and the thinnest stroke in the last character thicker, and compare the magnitudes of ASM1 and ASM2-th again; if ASM1 < ASM2-th, the adjustment is completed;

[0032] Si-3 If ASM1 ≥ ASM2-th, re-execute step Si-1;

[0033] The operation steps of "increasing ASM1 and reducing ASM2" are as follows:

[0034] Sii-1: Flip the white pixels in the first character and the black pixels in the last character, initially increase ASM1 and reduce ASM2, and compare the magnitudes of ASM1 and ASM2+th; if ASM1 > ASM2+th, the adjustment is completed;

[0035] Sii-2: If ASM1 ≤ ASM2+th, make the thinnest stroke in the first character thicker and the thickest stroke in the last character thinner, and compare the magnitudes of ASM1 and ASM2+th again; if ASM1 > ASM2+th, the adjustment is completed;

[0036] Sii-3: If ASM1 ≥ ASM2-th, re-execute step Sii-1.

[0037] Preferably, the process of adjusting the stroke thickness in steps Si-2 and Sii-2 includes:

[0038] S6-1: Extract the outer contour of the character, denoted as ext_edge, and the inner contour, denoted as int_edge. In the skeleton, extract the skeletons of some strokes through a straight-line search algorithm, denoted as ;

[0039] S6-2: After multiplying by several times and performing an "AND" operation with the inner and outer contours of the character, obtain the inner and outer contours of the stroke. Among them, the inner contour is denoted as , and the outer contour is denoted as ;

[0040] S6-3: After widening the character by several times, perform an AND operation with the character itself to obtain the number of strokes. Calculate the ASM of each stroke and determine the strokes corresponding to the maximum and minimum values.

[0041] S6-4: Take the inner contour of the stroke corresponding to the maximum value, and record the position of all pixels on the same side of the stroke axis in the character according to the axis, excluding the points where "the corresponding pixel in the character is black on both sides perpendicular to the axis direction"; turn the corresponding pixel in the character white to complete the thinning operation.

[0042] S6-5: Take the outer contour of the stroke corresponding to the minimum value, and record the position of all pixels on the same side of the stroke axis in the character according to the axis axis; turn the corresponding pixels in the character into black to complete the thickening operation.

[0043] Preferably, the method for image orientation correction in step Sb-1 is as follows:

[0044] First, the image tilt angle is detected using existing algorithms. Then, the image is rotated by the corresponding angle. After that, the four edges of the image are cropped until there are no black pixels at the edges to remove the black edges caused by the rotation. Isolated noise is removed to ensure the accuracy of character segmentation.

[0045] Preferably, the skeleton extraction algorithm is a morphology-based skeleton extraction method, which extracts the central skeleton of the character through multiple morphological erosion and reconstruction operations to obtain the skeleton length. .

[0046] Preferably, the binarization process uses the Otsu thresholding method to automatically determine the binarization threshold and convert the target document into a black and white binarized text image I.

[0047] This invention relates to the application of a method for resisting digital watermarking of text images, including text images of different language types and font types, such as Chinese characters and English.

[0048] Beneficial effects: This invention can embed 1 bit of information into two characters, with no restrictions on the language type or font of the characters. While ensuring the amount of hidden watermark information in a document, it effectively solves the problem of algorithmic limitations between different languages. It also solves the problems of poor robustness and small capacity against print scanning attacks when adding digital watermarks in the spatial domain and transform domain, exhibiting high robustness against print scanning attacks. Attached Figure Description

[0049] Figure 1 This is a flowchart of the embedding process of the present invention.

[0050] Figure 2 This is a flowchart of the extraction process of the present invention.

[0051] Figure 3 This is a diagram showing the differences in the effects of embedding different watermark information in this invention. Detailed Implementation

[0052] The following will refer to the accompanying drawings in the embodiments of the present invention. Figures 1 to 3 The technical solutions in the embodiments of the present invention are clearly and completely described herein. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0053] like Figure 1 The flowchart shown illustrates the steps of watermark embedding: First, the target document is converted into an image and binarized; then, the position of each character is found using the projection method; next, the first 2L characters are selected and their "Average Skeleton Quality (ASM)" is extracted; then, each pair of characters is grouped together, and the "ASM" is changed according to the watermark information to be embedded to perform watermark embedding; finally, the watermarked text image is converted into a PDF document to obtain the watermarked document.

[0054] like Figure 2 The flowchart shown illustrates the watermark extraction process: First, the document containing the watermark is printed and scanned; then, the scanned image is oriented, noise is removed, and binarized; next, the position of each character is found using the projection method; then, the first 2L characters are selected and their "ASM" is extracted; after that, every two characters are grouped together, and the "ASM" is modified according to the watermark information to be embedded for watermark embedding; finally, the text image containing the watermark is converted into a PDF document to obtain the watermarked document.

[0055] like Figure 3 The diagram showing the differences in the effects of embedding different watermark information specifically illustrates the two words "watermark". Figure 3 The watermark on the left side of the middle is embedded with "1". Figure 3 The watermark on the right side of the middle is embedded with "0", that is... Figure 3 The left side shows the effect of embedding "1", and the right side shows the effect of embedding "0". This visually demonstrates the difference in text appearance when embedding different watermark information, reflecting the result of embedding different watermark bits by changing "ASM".

[0056] Technical solution / principle:

[0057] The watermarking algorithm of this invention is a blind watermarking algorithm, which can embed and extract watermarks without the original document. The embedding and extraction of watermarks are achieved by adjusting the average skeleton quality (ASM). The specific principle is as follows:

[0058] I. Creativity includes Average Skeleton Quality (ASM)

[0059] "ASM" is defined as Average Skeleton Quality, which is the pixel width contained in a stroke. It is extracted based on the number of black pixels and the skeleton length of the character, using the following formula: .

[0060] Among them, SUM black : Counts the total number of black pixels in a character. Black pixels are the pixels that represent text after binarization in a text image (pixel value is 0).

[0061] The skeleton length of a character is extracted using a skeleton extraction algorithm (such as a morphology-based skeleton extraction method, multiple morphological erosion and reconstruction operations). The skeleton is the central structure of the character and reflects its shape features.

[0062] II. Watermark Embedding Principle

[0063] Group the characters into pairs and adjust the "ASM" of the two characters in each pair according to the watermark bit (0 or 1) to be embedded:

[0064] When the embedding bit is 1, make the "ASM" of the first character in the group smaller than the "ASM" of the last character (by decreasing the "ASM" of the first character and increasing the "ASM" of the last character).

[0065] The proposed anti-printing scanning digital watermarking method for text images is a blind watermarking algorithm, which includes two processes: watermark embedding and watermark extraction.

[0066] Watermark embedding process:

[0067] Step Sa-1: Convert the target document into an image and perform binarization processing to generate a binarized text image I.

[0068] Step Sa-2: Segment each character in the text image I using the projection method, denoted as C1, C2, ..., C6. n Where n is the total number of characters. The projection method specifically involves first extracting line information and dividing the text into blocks based on the connectivity characteristics of the characters; calculating the pixel sum for each line in the binarized text image I (white background = 1, black text = 0), and defining the regions with a sum of 0 as text areas, thereby obtaining the number of lines and the top and bottom boundaries of each line; then calculating the column pixel sum for each line, and obtaining the left and right boundaries of each character block based on character connectivity; subsequently, determining the width and black pixel height of the character block; if the width is less than 0.4 times the line height and the black pixel height is less than 0.6 times the line height, it is determined to be a punctuation mark; the method for determining if a character block is a single character is to check the character block width; if the width is within... Double row height and Between double the height ( Usually 0.6 - 0.7, usually 1 - 1.1), it is considered a Chinese character; after discarding punctuation marks, judge whether 3, 2, and 1 consecutive character blocks are Chinese characters in sequence to determine the character position.

[0069] Step Sa-3: Screen the first 2L characters and extract their "Average Skeleton Mass (ASM)" (L is the number of watermark bits). "ASM" is defined as the average skeleton mass, that is, the pixel width included in the stroke. The extraction algorithm assumes that the size of the current character is (M, N) (M is the number of pixels in the character height, N is the number of pixels in the character width), and count the number of black pixels SUM in the character black ; Extract the skeleton length Ls (total length of skeleton pixels) of the character through a morphological-based skeleton extraction method (multiple morphological erosion and reconstruction operations), then .

[0070] Step Sa-4: Take every two characters as a group, denoted as , and start embedding watermark bits from the first character group (L is the number of watermark bits). The ASM of the first character of each character group is denoted as ASM1, and the ASM of the last character is denoted as ASM2. If the current watermark bit is 0, increase ASM1 and decrease ASM2 in the group until ASM1 > ASM2 + th (th is a preset value, ranging from 0.1 - 0.5); if the current watermark bit is 1, decrease ASM1 and increase ASM2 in the group until ASM1 < ASM2 - th. The embedding situation is divided into the following four types (assuming the current character group is ):

[0071] When the watermark bit is 1, if ASM1 ≥ ASM2 - th, decrease ASM1 and increase ASM2 until ASM1 < ASM2 - th;

[0072] When the watermark bit is 1, if ASM1 < ASM2 - th, keep it unchanged;

[0073] When the watermark bit is 0, if ASM1 ≤ ASM2 + th, increase ASM1 and decrease ASM2 until ASM1 > ASM2 + th;

[0074] When the watermark bit is 0, if ASM1 > ASM2 - th, keep it unchanged.

[0075] The adjustment of ASM for the current character group includes two operations: "decrease ASM1 and increase ASM2" and "increase ASM1 and decrease ASM2";

[0076] Among them, the operation steps of "reducing ASM1 and increasing ASM2" are as follows:

[0077] Si-1: Flip the black pixels in the first character and the white pixels in the last character, initially reduce ASM1 and increase ASM2, and compare the size of ASM1 and ASM2-th; if ASM1 < ASM2-th, the adjustment is completed;

[0078] Si-2: If ASM1 ≥ ASM2-th, make the thickest stroke in the first character thinner and the thinnest stroke in the last character thicker, and compare the size of ASM1 and ASM2-th again; if ASM1 < ASM2-th, the adjustment is completed;

[0079] Si-3: If ASM1 ≥ ASM2-th, re-execute step Si-1;

[0080] The operation steps of "increasing ASM1 and reducing ASM2" are as follows:

[0081] Sii-1: Flip the white pixels in the first character and the black pixels in the last character, initially increase ASM1 and reduce ASM2, and compare the size of ASM1 and ASM2+th; if ASM1 > ASM2+th, the adjustment is completed;

[0082] Sii-2: If ASM1 ≤ ASM2+th, make the thinnest stroke in the first character thicker and the thickest stroke in the last character thinner, and compare the size of ASM1 and ASM2+th again; if ASM1 > ASM2+th, the adjustment is completed;

[0083] Sii-3: If ASM1 ≥ ASM2-th, re-execute step Sii-1.

[0084] The process of adjusting the stroke thickness in steps Si-2 and Sii-2 includes:

[0085] S6-1: Extract the outer contour of the character and record it as ext_edge, extract the inner contour and record it as int_edge, and extract the skeletons of some strokes through the straight-line search algorithm in the skeleton, and record it as ;

[0086] S6-2: After multiplying by a certain multiple and performing an "AND" operation with the inner and outer contours of the character, obtain the inner and outer contours of the stroke, where the inner contour is recorded as and the outer contour is recorded as ;

[0087] S6-3: After multiplying by a certain multiple and performing an "AND" operation with the character itself to obtain the stroke, calculate the "ASM" of each stroke, and determine the strokes corresponding to the maximum and minimum values;

[0088] S6-4: Take the inner contour of the stroke corresponding to the maximum value, and record the position of all pixels on the same side of the stroke in the character according to the axis of the stroke. Exclude the points where "the corresponding pixel in the character is black on both sides perpendicular to the axis direction"; turn the corresponding pixel in the character white to complete the thinning operation.

[0089] S6-5: Take the outer contour of the stroke corresponding to the minimum value, and record the position of all pixels on the same side of the stroke axis in the character according to the axis axis; turn the corresponding pixels in the character into black to complete the thickening operation.

[0090] The character group after embedding the watermark is denoted as and characters Replace with Repeat the operation until All watermark bits are embedded.

[0091] Step Sa-5: Generate a text image with an embedded watermark.

[0092] In addition, the watermark extraction process of this invention is as follows:

[0093] Step Sb-1: Correct the orientation of the printed and scanned image and remove isolated noise. The image orientation correction method is as follows: first, detect the image tilt angle using an existing algorithm, then rotate the image by the corresponding angle, and then crop the four edges of the image until there are no black pixels at the edges (remove the black edges caused by rotation); remove isolated noise to ensure the accuracy of character segmentation.

[0094] Step Sb-2: Convert the corrected image into a binary text image I w (The binarization threshold is automatically determined using the Otsu thresholding method).

[0095] Step Sb-3: Segment each character in the text image I using the same projection method as when embedding the watermark, denoted as... ( (This is the total number of characters, the same as when embedding).

[0096] Step Sb-4: Filter the first 2L embeddable characters, extract their ASM, and group them into pairs. The ASM of the first character of each character group is denoted as The ASM notation for the suffix character is: .

[0097] Step Sb-5: Extract the watermark starting from the first group of characters: If The extracted watermark information is 0; if The extracted watermark information is 1; until the extracted watermark information is 1. End after the bit information.

[0098] The present invention is applicable to text images of different language types including but not limited to Chinese characters, English, etc., and is not restricted by font types.

[0099] Embodiment 1: The technical solution of the present application will be described in detail below with specific examples.

[0100] I. Watermark embedding process (taking the example of embedding 3-bit watermark information of "101" into a Chinese text image containing "Digital watermark technology is very important" as the target document)

[0101] Step Sa-1: Convert the target document containing "Digital watermark technology is very important" into a picture, and perform binarization processing using the Otsu threshold method to generate a binarized text image I. At this time, the image shows a clear effect of black and white text with a white background, where the text part is black (pixel value 0) and the background is white (pixel value 1).

[0102] Step Sa-2: Segment each character in the text image I by the projection method.

[0103] Row information extraction: Calculate the pixel sum of the binarized text image I row by row, and divide the area with a sum of 0 into the text area. For example, the pixel sum of the row where the character "数" is located is 0, so it is determined that this row is a text row, and the top boundary (the pixel position at the top of the row) and the bottom boundary (the pixel position at the bottom of the row) of this row are obtained.

[0104] Column pixel sum calculation and determination of character block boundaries: Calculate the column pixel sum of the row where the character "数" is located, and based on character connectivity, obtain the left and right boundaries (the left pixel position and the right pixel position) of the character block of the character "数".

[0105] Punctuation mark and character judgment: Judge the width and the height of black pixels of the character block. If the width is less than 0.4 times the line height and the height of black pixels is less than 0.6 times the line height, it is determined as a punctuation mark. Here, there is no punctuation mark in "Digital watermark technology is very important", so no discard is made. Then check the width of the character block. The width of the character block of the character "数" is between 0.6 and 0.7 times the line height, and it is determined as a Chinese character. Then perform the same operation on the characters "字", "水", "印", "技", "术", "很", "重", "要" in turn. Finally, these 9 characters are segmented and denoted as C1 (数), C2 (字), C3 (水), C4 (印), C5 (技), C6 (术), C7 (很), C8 (重), C9 (要), and n = 9 is the total number of characters.

[0106] Step Sa-3: Given that 3-bit watermark information needs to be embedded, i.e., L=3, the first 2L=6 characters are filtered out, namely C1 (number), C2 (word), C3 (water), C4 (mark), C5 (technique), and C6 (skill), and their average skeleton quality (ASM) is extracted.

[0107] Taking character C1 (number) as an example, assuming its size is (M=30, N=25) (M is the character height in pixels, N is the character width in pixels), count the number of black pixels in it. The skeleton length Ls=40 (the total length of the skeleton pixels) is extracted using a morphological skeleton extraction method (multiple morphological erosion and reconstruction operations). Then, according to the formula... C1 can be obtained. Similarly, the ASM2 of C2 (character) is calculated to be 2.8, and that of C3 (water) is... C4 (print) has an ASM4 of 2.5, C5 (technical) has an ASM5 of 3.5, and C6 (skill) has an ASM6 of 2.7.

[0108] Step Sa-4: Group each pair of characters to form a total of... , , Three groups, starting with group 1, embedding watermark bits. , (L=3 is the number of watermark bits).

[0109] Group (embedded) ):

[0110] Group The ASM of the first character c1 is denoted as ASM. 11 =3, the ASM of the suffix C2 is denoted as ASM. 12 =2.8.

[0111] Since the current watermark bit is 1, check ASM. 11 ≥ASM 12 -th (assuming th=2), ASM 12 -th=2.8-0.2=2.6, 3≥2.6, so ASM needs to be reduced. 11 Increase ASM 12 Until ASM 11 <ASM 12 -th = 2.6.

[0112] Execute "Reduce ASM" 11 Increase ASM 12 "operate:

[0113] Step Si-1: Flip the black pixels in C1 and the white pixels in C2. After initial adjustments, the SUM value of C1... black It becomes 110, and Ls becomes 42. SUM of C2 black It becomes 130, and Ls becomes 38. .Compare and 2.62 < 3.22, adjustment complete. At this point... After becoming an embedded watermark (Including the adjusted version) and ).

[0114] Group (embedded) ):

[0115] Group The ASM with the first character C3 is denoted as ASM. 21 =3.2, the ASM of the suffix C4 is denoted as ASM. 22 =2.5.

[0116] Since the current watermark bit is 0, check ASM. 21 ≤ASM 22 +th = 2.5 + 0.2 = 2.7, 3.2 > 2.7, so ASM needs to be increased. 21 Reduce ASM 22 Until ASM 21 ASM 22 +th=2.7.

[0117] Implement "Increase ASM" 21 Reduce ASM 22 "operate:

[0118] Step Sii-1: Flip the white pixels in C3 and the black pixels in C4. After initial adjustments, the SUM value of C3... black It becomes 140, and Ls becomes 39. SUM of C4 black It becomes 115, and Ls becomes 45. .Compare and 3.59 > 2.76, adjustment complete. At this point... After becoming an embedded watermark (Including the adjusted version) and ).

[0119] Group (embedded) ):

[0120] Group The ASM of the first character C5 is denoted as ASM 31 = 3.5, and the ASM of the last character C6 is denoted as ASM 32 = 2.7.

[0121] Since the current watermark bit is 1, check ASM 31 ≥ ASM 32 -th = 2.7 - 0.2 = 2.5, 3.5 ≥ 2.5, so ASM needs to be reduced 31 and increased ASM 32 , until ASM31 < ASM32 - th = 2.5.

[0122] Execute the operation of "reducing ASM 31 and increasing ASM 32 ":

[0123] Step Si - 1: Flip the black pixels in C5 and the white pixels in C6. After preliminary adjustment, the SUM of C5 black becomes 125, and Ls becomes 50, ; the SUM of C6 black becomes 135, and Ls becomes 36, . Compare with , 2.5 < 3.55, the adjustment is completed. At this time becomes the text image after embedding the watermark (including the adjusted and ).

[0124] Replace the character group after embedding the watermark with the original character group respectively, and complete the embedding of 3 watermark bits.

[0125] Step Sa - 5: Generate the text image with the embedded watermark. At this time, the strokes of the characters "number", "character", "water", "mark", "technology", and "technique" in the image have been adjusted according to the watermark information.

[0126] II. Watermark extraction process (extract the watermark after printing and scanning the text image with the embedded watermark above)

[0127] Step Sb - 1: Correct the orientation of the printed and scanned image and remove isolated noise points.

[0128] Orientation correction: It is detected through the existing algorithm that the image is tilted by 2 degrees. Rotate the image by 2 degrees, and then crop the four sides of the image until there are no black pixel points at the edges, removing the black edges generated by rotation.

[0129] Removing isolated noise: Using connected component analysis, black areas (isolated noise) with an area less than 5 pixels are set to white to ensure the accuracy of character segmentation.

[0130] Step Sb-2: Convert the corrected image into a binary text image I using the Otsu thresholding method. w .

[0131] Step Sb-3: Segment each character in the text image I using the same projection method as when embedding the watermark, denoted as... , , , , , , , , n=9 is the total number of characters (the same as when embedding).

[0132] Step Sb-4: Filter the first 2L=6 embeddable characters Extract "ASM", grouping each pair of characters into a single group. The "ASM" of the first character of each character group is denoted as... The suffix "ASM" is written as .

[0133] Calculated , ; , ; , .

[0134] Step Sb-5: Extract the watermark starting from the first group of characters:

[0135] Group The extracted watermark information is 1.

[0136] Group The extracted watermark information is 0.

[0137] Group The extracted watermark information is 1.

[0138] Finally, the 3-bit information "101" was extracted, which matched the embedded watermark information, and the extraction was completed.

[0139] This invention is applicable to text images in different language types, including but not limited to Chinese characters and English, and is not limited by font type.

[0140] Finally, it should be noted that the present invention is not limited to the above embodiments, and many variations are possible. All variations that can be directly derived or conceived by those skilled in the art from the disclosure of the present invention should be considered within the scope of protection of the present invention.

Claims

1. A method of counter-print-scan digital watermarking for a text image, characterized in that The method comprises a watermark embedding process and a watermark extracting process; The watermark embedding process comprises the following steps: Sa-1: converting the target document into a picture and performing binaryzation processing to generate a binaryzation text image I; Sa-2: segmenting each character in the text image I by a projection method; Sa-3: screening the first 2L characters and extracting the ASM of the characters, L being the number of watermark bits; Sa-4: every two characters as a group, from the first character group to start the watermark bits w1, w2 until w L embedded; the first character of each character group ASM is recorded as ASM1, and the last character of each character group ASM is recorded as ASM2; if the current watermark bit is 0, the ASM1 of the group is increased, and the ASM2 is decreased, until ASM1> ASM2+th; if the current watermark bit is 1, the ASM1 of the group is decreased, and the ASM2 is increased, until ASM1< ASM2-th; the character group after embedding the watermark is recorded as , and the character is replaced with , and the operation is repeated until all L watermark bits are embedded; Sa-5: generating a text image embedded with the watermark; Specifically comprising: Step Sa-1: converting the target document containing "digital watermark technology is important" into a picture, and performing binaryzation processing by using the Otsu threshold method; Step Sa-2: calculating the pixel sum of the binaryzation text image I by row, and dividing the region with a sum of 0 into a text area, thereby determining that the row is a text row and obtaining the top pixel position of the uppermost boundary row and the bottom pixel position of the lowermost boundary row; calculating the column pixel sum of the row where the "number" word is located, and obtaining the left and right boundaries of the "number" word character block based on the character connectivity; judging the width of the character block and the height of the black pixels, and if the width is less than 0.4 times the row height and the height of the black pixels is less than 0.6 times the row height, it is determined that there is no punctuation in "digital watermark technology is important"; then, the width of the character block is verified, and the width of the "number" word character block is between 0.6-0.7 times the row height, which is determined to be a Chinese character; and the same operation is sequentially performed, and finally the 9 characters are segmented, which are recorded as C1 corresponding to "number", C2 corresponding to "word", C3 corresponding to "water", C4 corresponding to "print", C5 corresponding to "technology", C6 corresponding to "technology", C7 corresponding to "very", C8 corresponding to "important", and C9 corresponding to "important", and n=9 is the total number of characters; Step Sa-3: knowing that 3-bit watermark information is to be embedded, i.e. L=3, screening the first 2L=6 characters, i.e. C1 corresponding to "number", C2 corresponding to "word", C3 corresponding to "water", C4 corresponding to "print", C5 corresponding to "technology", and C6 corresponding to "technology", and extracting the average skeleton quality ASM of the characters; Assume that the size of the character is M=30, N=25, M is the number of character height pixels, N is the number of character width pixels, and the number of black pixels is counted ; the skeleton length Ls=40 is extracted by a skeleton extraction method based on morphology, and then according to the formula , the of C1 is obtained ; similarly, the ASM2 of C2 corresponding to the "word" is calculated as 2.8, the ASM4 of C3 corresponding to the "water" is calculated as 2.5, the ASM5 of C5 corresponding to the "technique" is calculated as 3.5, and the ASM6 of C6 corresponding to the "art" is calculated as 2.

7. Step Sa-4: Embedding watermark bits in every two characters, forming three groups, starting from the first group , , three groups, starting from the first group , ; group , embedded : Group The ASM of the first character c1 is denoted as ASM 11 = 3, and the ASM of the last character C2 is denoted as ASM 12 = 2.8; the current watermark bit is 1, check ASM 11 ≥ ASM 12 -th, where let th = 2, ASM 12 -th = 2.8 - 0.2 = 2.6, 3 ≥ 2.6, so ASM needs to be reduced 11 , and ASM needs to be increased 12 , until ASM 11 < ASM 12 -th = 2.6; Perform "Reduce ASM 11 , Increase ASM 12 " operation: Step Si-1: Flip the black pixels in C1 and the white pixels in C2. After initial adjustments, the SUM value of C1... black It becomes 110, and Ls becomes 42. SUM of C2 black It becomes 130, and Ls becomes 38. ;Compare and 2.62 < 3.22, adjustment complete; at this point... After becoming an embedded watermark Including the adjusted and ; group , embedded : Group The ASM of the first character C3 is denoted as ASM 21 = 3.2, and the ASM of the last character C4 is denoted as ASM 22 = 2.5; the current watermark bit is 0, and the ASM is checked 21 ≤ ASM 22 + th = 2.5 + 0.2 = 2.7, 3.2 > 2.7, so the ASM needs to be increased 21 , the ASM is decreased 22 , until ASM 21 > ASM 22 + th = 2.7; Perform "Increase ASM 21 , Decrease ASM 22 " operation: Step Sii-1: Flip the white pixels in C3 and the black pixels in C4. After initial adjustments, the SUM value of C3... black It becomes 140, and Ls becomes 39. SUM of C4 black It becomes 115, and Ls becomes 45. ;Compare and 3.59 > 2.76, adjustment complete; at this point... After becoming an embedded watermark This includes the adjusted and ; group , embedded : Group The ASM of the first character C5 is denoted as ASM 31 = 3.5, and the ASM of the last character C6 is denoted as ASM 32 = 2.7; the current watermark bit is 1, and the ASM is checked 31 ≥ ASM 32 -th = 2.7 - 0.2 = 2.5, 3.5 ≥ 2.5, so the ASM needs to be reduced 31 , and the ASM is increased 32 , until ASM31< ASM32-th = 2.5; Perform "reduce ASM 31 , increase ASM 32 " operation: Step Si-1: flip the black pixel in C5 and the white pixel in C6, after preliminary adjustment, SUM of C5 becomes 125, Ls becomes 50, black ; SUM of C6 becomes 135, Ls becomes 36, black ; compare , 2.5 < 3.55, adjustment is completed; at this time , contains the adjusted ;​​​​​ character group after embedding watermarks respectively replace the original character group , complete the embedding of 3 watermark bits; Step Sa-5: generating a text image embedded with the watermark, and at this time, the "number", "word", "water", "print", "technology", and "technology" words in the image have adjusted the stroke "ASM" according to the watermark information.

2. The method of claim 1, wherein, The watermark extracting process comprises the following steps: Sb-1: performing direction correction on the image after printing and scanning, and removing isolated noise points; Sb-2: converting the corrected image into a binarized text image I w ; Sb-3: binarized text image I is segmented into individual characters by the projection method w each character is segmented out; Sb-4: screening the first 2L characters that can be embedded, and extracting the ASM of the characters, each two characters being a group; Sb-5: Extract the watermark from the 1st group of characters: if , the extracted watermark information is 0; if , the extracted watermark information is 1; until the extraction of bit information is finished. Wherein, the extraction algorithm of ASM is: assuming that the size of the current character is (M, N), M is the number of character height pixels, and N is the number of character width pixels, the number of black pixels in the character is counted ; the skeleton length of the character is extracted through the skeleton extraction algorithm , and the formula is: .

3. The method of claim 2, wherein, The projection method in step Sa-2 is an optimized projection method based on a traditional projection method, and the specific process of the optimized projection method is as follows: First, perform row information extraction, and divide the character block based on the character connectivity domain characteristics; for the binaryzation text image I, set the white background as 1 and the black text as 0; calculate the pixel sum by row, and divide the region with a sum of 0 into a text area, thereby obtaining the number of rows and the uppermost and lowermost boundaries of each row; Next, calculate the column pixel sum for each row, and obtain the left and right boundaries of each character block based on character connectivity; then determine the width and black pixel height of the character block. If the width is less than 0.4 times the row height and the black pixel height is less than 0.6 times the row height, it is determined to be a punctuation mark. The method to determine if a character block is a single character is: check the width of the character block; if the width is within... Between double row height and b double row height; If the value of b is 0.6-0.7 and the value of b is 1-1.1, then it is considered to be a Chinese character. After discarding the punctuation marks, we sequentially determine whether 3, 2, and 1 consecutive character blocks are a Chinese character, thereby determining the character position.

4. The method of claim 2, wherein, The ASM in steps Sa-3, Sa-4, Sb-4, and Sb-5 is the average skeleton quality, and the stroke contains the pixel width.

5. The method of claim 2, wherein, The embedding case in step Sa-4 is classified into the following four cases, assuming that the current character group is , as follows: When the watermark bit is 1, if ASM1≥ASM2-th, decrease ASM1 and increase ASM2 until ASM1<ASM2-th; When the watermark bit is 1, if ASM1<ASM2-th, keep unchanged; When the watermark bit is 0, if ASM1≤ASM2+th, increase ASM1 and decrease ASM2 until ASM1>ASM2+th; When the watermark bit is 0, if ASM1>ASM2-th, keep unchanged.

6. The method of claim 5, wherein, ASM adjustment of the current character group contains two operations: "decrease ASM1, increase ASM2" and "increase ASM1, decrease ASM2": The operation steps of "decreasing ASM1 and increasing ASM2" are as follows: Si-1: flip the black pixels in the first character and the white pixels in the last character, preliminarily decrease ASM1 and increase ASM2, and compare the size of ASM1 and ASM2-th; if ASM1<ASM2-th, the adjustment is completed; Si-2: if ASM1≥ASM2-th, make the thickest stroke in the first character thinner and the thinnest stroke in the last character thicker, and compare the size of ASM1 and ASM2-th again; if ASM1<ASM2-th, the adjustment is completed; Si-3: if ASM1≥ASM2-th, re-execute step Si-1. The operation steps of "increasing ASM1 and decreasing ASM2" are as follows: Sii-1: flip the white pixels in the first character and the black pixels in the last character, preliminarily increase ASM1 and decrease ASM2, and compare the size of ASM1 and ASM2+th; if ASM1>ASM2+th, the adjustment is completed; Sii-2: if ASM1≤ASM2+th, make the thinnest stroke in the first character thicker and the thickest stroke in the last character thinner, and compare the size of ASM1 and ASM2+th again; if ASM1>ASM2+th, the adjustment is completed; Sii-3: if ASM1≥ASM2-th, re-execute step Sii-1.

7. The method of claim 6, wherein, The process of adjusting the stroke thickness in steps Si-2 and Sii-2 includes: S6-1: The outer contour extraction of the character is denoted as ext_edge, the inner contour extraction is denoted as int_edge, and the skeleton of part of strokes is extracted in the skeleton by a straight line searching algorithm, denoted as ; S6-2: Perform an AND operation between the increased number of times and the inner and outer contours of the character to obtain the inner and outer contours of the stroke, wherein the inner contour is denoted as and the outer contour is denoted as ;​ S6-3 : Calculate the "ASM" of each stroke after the "AND" operation of the increased number of times and the character itself, and determine the stroke corresponding to the maximum value and the minimum value. S6-3 : Calculate the "ASM" of each stroke after the "AND" operation of the increased number of times and the character itself, and determine the stroke corresponding to the maximum value and the minimum value. S6-4: take the inner contour of the stroke corresponding to the maximum value, record the positions of all pixel points on the same side of the axial direction in the character according to the axial direction of the stroke, exclude the points in which the pixel points corresponding to the positions in the character are black on both sides perpendicular to the axial direction, change the pixel points corresponding to the positions in the character into white, and complete the thinning operation; S6-5: take the outer contour of the stroke corresponding to the minimum value, record the positions of all pixel points on the same side of the axial direction in the character according to the axial direction of the stroke, change the pixel points corresponding to the positions in the character into black, and complete the thickening operation.

8. The method of claim 2, wherein, The method of image direction correction in step Sb-1 is as follows: First, detect the image tilt angle by using the existing algorithm, then rotate the image by the corresponding angle, then cut the four edges of the image until there is no black pixel point on the edge, and remove the black edge generated by rotation; remove isolated noise points to ensure the accuracy of character segmentation.

9. The method of claim 2, wherein, The skeleton extraction algorithm is a morphological-based skeleton extraction method, which extracts the center skeleton of the character through multiple morphological erosion and reconstruction operations to obtain the skeleton length .

10. The method of claim 2, wherein, The binarization processing adopts Otsu threshold method to automatically determine the binarization threshold and convert the target document into a black and white binary text image I.

Citation Information

Patent Citations

  • Method for embedding and extracting printing and scanning resistant digital watermark for text image

    CN116977149A