A method and system for detecting tampering of a document image
By performing geometric correction and background region texture feature analysis on document images, establishing JPEG grid reference points and high-frequency zero-value masks, and performing grid alignment and frequency domain residual analysis, the problems of false alarms and missed alarms in document tampering detection are solved, and the accuracy and robustness of detection are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAN HUIZHI ZHONGZE ELECTRONIC TECHNOLOGY CO LTD
- Filing Date
- 2026-04-27
- Publication Date
- 2026-05-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing document tampering detection methods, lacking original reference images and subject to global background noise interference, cannot accurately distinguish between original content and local tampering traces, resulting in a large number of false positives and false negatives, affecting the efficiency and accuracy of automated review processes.
By performing geometric correction on the document image, an orthogonal pixel coordinate system is established to obtain the text region and background region of the key text object. Based on the texture features of the background region, a unified JPEG grid reference point and high-frequency zero-value mask are statistically determined for the entire document. The text region is then aligned with the grid using the high-frequency zero-value mask to obtain the frequency domain residual matrix and convert it into a binarized topology map. The noise dispersion is obtained based on the distribution of connected components in the binarized topology map. The key text object is then grouped based on its layout coordinates to determine the tampering status.
In the absence of original reference images and global noise interference, it significantly improves the detection accuracy and robustness of subtle tampering traces in low-quality circulating documents and reduces the false alarm rate.
Smart Images

Figure CN122116103A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of document image tampering detection technology, and specifically to a document image tampering detection method and system. Background Technology
[0002] In financial auditing, contract compliance review, and automated office processes, document images typically undergo pure digital domain transfer processes such as screenshotting, PDF to image conversion, and compression via instant messaging software. These document images generally have two significant characteristics: first, global background noise is introduced due to multiple lossy compressions or resamplings; second, original metadata such as EXIF is lost, making it impossible to rely on file header information for authenticity verification.
[0003] Existing document tampering detection technologies mainly fall into two categories: one is detection based on file metadata, which becomes completely ineffective after screenshotting or format conversion; the other is passive evidence collection based on image signals, such as error level analysis or recompression detection. However, when processing low-quality compressed images or heavily compressed screenshots, the high-frequency edges of original text strokes have very strong energy in the frequency domain. This is highly confused with the grid misalignment noise introduced by tampering operations (such as pasting or erasing) in terms of energy amplitude. When the overall signal-to-noise ratio of the document is low, conventional energy analysis methods cannot distinguish between the original text edge energy and the abnormal energy caused by tampering, resulting in a large number of false alarms. In addition, non-integer multiple offsets and background texture interference introduced during resampling or scaling further undermine the baseline conditions based on fixed grid analysis, making detection algorithms that rely on absolute thresholds less robust in practical applications. Therefore, existing document tampering detection methods cannot accurately distinguish between original content and local tampering traces in the absence of original reference images and in the presence of global background noise interference, leading to a large number of false alarms and false negatives, which seriously affects the efficiency and accuracy of automated review processes. Summary of the Invention
[0004] To address the technical problem that existing document tampering detection methods cannot accurately distinguish between original content and local tampering traces in the absence of original reference images and in the presence of global noise interference, leading to a large number of false positives and false negatives, the present invention aims to provide a document image tampering detection method and system, the specific technical solution of which is as follows: In a first aspect, one embodiment of the present invention provides a document image tampering detection method, the method comprising the following steps: Perform geometric correction on the document image and establish an orthogonal pixel coordinate system to obtain the text region and background region of key text objects; Based on the texture features of the background region, statistically obtain the unified JPEG grid reference points and high-frequency zero-value masks for the entire document; The text region is aligned with the JPEG grid reference points, and the frequency domain residual matrix of the text region is obtained by combining it with a high-frequency zero-value mask and converted into a binary topology map. The noise dispersion of the text region is obtained based on the distribution of connected components in the binary topology map. The key text objects are grouped based on their layout coordinates, and a reference benchmark for the noise dispersion within each group is obtained. The tampering status of the key text objects is determined based on the difference between the noise dispersion and the reference benchmark.
[0005] Furthermore, the method for obtaining the JPEG grid reference points is as follows: For any key text object, the average grayscale value of all pixels within the text area of the key text object is used as the text reference grayscale value; the average grayscale value of all pixels within the background area of the key text object after removing the text area is used as the background reference grayscale value. When the grayscale value of the text reference is greater than the grayscale value of the background reference, a morphological erosion operation is performed on the background area of the key text object; when the grayscale value of the text reference is less than the grayscale value of the background reference, a morphological dilation operation is performed on the background area of the key text object. The variance of grayscale values within the morphologically processed background region is obtained as the first variance. When the first variance is greater than or equal to the preset fluctuation threshold, the background area of the key text object is marked as valid. For any background region marked as valid, perform sliding window differential energy calculation on the background region to obtain the block boundary differential energy of the background region under all candidate grid offsets; The candidate offset corresponding to the largest block boundary differential energy is taken as the optimal mesh phase for the background region. Using the optimal grid phase and the coordinates of the background region in the orthogonal pixel coordinate system, the global reference candidate coordinates corresponding to the background region are obtained; All global baseline candidate coordinates marked as valid background regions are weighted based on background texture variance and selected as the global baseline candidate coordinates with the highest cumulative weight as the unified JPEG grid reference point for the entire document.
[0006] Furthermore, the method for obtaining the high-frequency zero-value mask is as follows: All marked valid background areas are considered valid background areas. All valid background areas are grid aligned using JPEG grid reference points. The aligned valid background areas are then divided into first pixel blocks with the same size as the coding block corresponding to the JPEG grid reference points. Perform a two-dimensional discrete cosine transform on each first pixel block to obtain the first frequency domain coefficient matrix corresponding to each first pixel block; For any frequency domain coefficient in the first frequency domain coefficient matrix, if the absolute value of the frequency domain coefficient is less than a preset small threshold, the frequency domain coefficient is forcibly set to 0; if the absolute value of the frequency domain coefficient is greater than or equal to the preset small threshold, the frequency domain coefficient is forcibly set to 1. The most frequent binary result at each frequency domain position is obtained from the first frequency domain coefficient matrix after binarization of all valid background regions. This is used as the final result for the corresponding frequency domain position, and a final binary matrix is determined as a unified high-frequency zero-value mask for the entire document.
[0007] Furthermore, the method for obtaining the frequency domain residual matrix is as follows: For any text region, align the text region to the global JPEG grid using the JPEG grid reference point; The aligned text region is divided into second pixel blocks with the same size as the encoding block corresponding to the JPEG grid reference point; Perform a two-dimensional discrete cosine transform on each second pixel block to obtain the second frequency domain coefficient matrix corresponding to each second pixel block; The result of multiplying each second frequency domain coefficient matrix with the high-frequency zero-value mask point by point is used as the frequency domain residual matrix of the text region.
[0008] Furthermore, the method for obtaining the binarized topological graph is as follows: For any text region, the mean of the absolute values of all non-zero elements in all frequency domain residual matrices of the text region is used as the adaptive segmentation threshold. For any element in the frequency domain residual matrix of the text region, if the absolute value of the element is greater than the adaptive segmentation threshold, the element is set to 1; if the absolute value of the element is less than or equal to the adaptive segmentation threshold, the element is set to 0. All frequency domain residual matrices of the binarized text region are concatenated and integrated into a complete binary matrix according to the spatial position of the corresponding second pixel block in the text region, which serves as the binarized topology map of the text region.
[0009] Furthermore, the method for obtaining the noise dispersion is as follows: For any text region, the 8-neighborhood connected component labeling algorithm is used to scan the binarized topology of the text region to obtain independent connected components. The number of pixels contained in each of the connected components is taken as the first quantity; The noise dispersion of the text region is obtained based on the total number of connected components and the largest first number; wherein the total number of connected components is positively correlated with the noise dispersion, and the largest first number is negatively correlated with the noise dispersion.
[0010] Furthermore, the method for obtaining the reference benchmark is as follows: The x-coordinate of the layout coordinates of each key text object in the orthogonal pixel coordinate system is used as the grouping reference value for each key text object; Based on the grouping reference values, the key text objects are grouped using the DBSCAN density clustering algorithm to obtain the object categories; For any object category, sort the noise dispersion of the text regions of the key text objects in that object category to obtain a noise dispersion sequence. The median of the noise dispersion sequence is used as the reference benchmark for noise dispersion within the object category.
[0011] Furthermore, the method for determining the tampering status of key text objects based on the difference between noise dispersion and the reference benchmark is as follows: For any object category, when the reference benchmark for noise dispersion within that object category is greater than a first preset multiple of the global benchmark noise floor mean, all key text objects within that object category are determined to be tampered regions. When the reference benchmark for noise dispersion within the object category is less than or equal to a first preset multiple of the global benchmark noise floor mean, the number of key text objects contained within the object category is obtained as the second number. When the second quantity is greater than or equal to the preset quantity threshold, for any key text object within the object category, the ratio of the noise dispersion of the text region of the key text object to the sum of the reference benchmark of the object category and the preset minimum positive number is used as the deviation degree of the key text object. When the deviation is greater than a preset relative threshold and the noise dispersion of the key text object is greater than a preset background noise threshold, the key text object is determined to be a tampered area. When the deviation is less than or equal to a preset relative threshold, the key text object is determined to be an unaltered area; When the noise dispersion of the key text object is less than or equal to the preset background noise threshold, the key text object is determined to be an untampered area; When the second quantity is less than the preset quantity threshold, for any key text object within the object category, if the noise dispersion of the key text object is greater than the second preset multiple of the preset background noise threshold, the key text object is determined to be a tampered area. When the noise dispersion of the key text object is less than or equal to a second preset multiple of the preset background noise threshold, the key text object is determined to be an unaltered area.
[0012] Furthermore, the method for obtaining the background region is as follows: For any key text object, take the center of the text area of the key text object as the reference, expand outward by a preset pixel distance to obtain a rectangular area containing the text area and the surrounding blank area, which is used as the background area of the key text object.
[0013] Secondly, another embodiment of the present invention provides a document image tampering detection system, the system comprising: a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the computer program, it implements the steps of any of the above methods.
[0014] The present invention has the following beneficial effects: This invention first performs geometric correction on the document image and establishes an orthogonal pixel coordinate system, which helps eliminate potential geometric deformations and ensures the phase consistency of the JPEG compressed grid across the entire image. Then, it obtains the text and background regions of key text objects, providing accurate image samples for subsequent local feature extraction and global benchmark construction. To address the benchmark missing problem in documents without metadata, it statistically obtains a unified JPEG grid benchmark point and a high-frequency zero-value mask for the entire document based on the texture features of the background region, accurately determining the global compression phase and quantization dead zone of the document at the last save, which is beneficial for establishing a reliable self-reference benchmark in the absence of an original reference image. To avoid interference from the high-frequency edge energy of the original text on tamper detection, it further performs grid alignment on the text region based on the JPEG grid benchmark point, and combines this with the high-frequency zero-value mask to obtain the frequency domain residual moments of the text region. The data is converted into a binary topological graph, transforming the feature dimension from easily confused amplitude strength to geometric shape. Then, based on the distribution of connected components in the binary topological graph, the noise dispersion of the text region is obtained, accurately reflecting the spatial fragmentation of the frequency domain residual energy. This helps to significantly distinguish between continuous native signals (clump-like) and discrete noise signals (scattered). To counteract the systematic interference caused by overall document background encoding noise, key text objects are grouped based on their layout coordinates, constructing a context for comparative analysis of source data. A reference benchmark for noise dispersion within each group is then obtained, ensuring that the benchmark value accurately reflects the background noise level of the data column. Finally, based on the difference between the noise dispersion and the reference benchmark, the tampering status of key text objects is accurately determined, effectively improving the accuracy and robustness of detecting weak tampering traces in low-quality circulating documents and reducing the false alarm rate. Attached Figure Description
[0015] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a schematic flowchart illustrating a document image tampering detection method provided in one embodiment of the present invention; Figure 2 This is a structural diagram of a document image tampering detection system provided in one embodiment of the present invention; Figure 3 This is a schematic diagram of a computer device provided according to an embodiment of the present invention. Detailed Implementation
[0017] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of a document image tampering detection method and system proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0018] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0019] The following description, in conjunction with the accompanying drawings, details the specific scheme of the document image tampering detection method and system provided by the present invention.
[0020] Example 1: This invention proposes a method for detecting document image tampering. Please refer to [link / reference]. Figure 1 The diagram illustrates a schematic flowchart of a document image tampering detection method according to an embodiment of the present invention, which includes the following steps: Step S1: Perform geometric correction on the document image and establish an orthogonal pixel coordinate system to obtain the text area and background area of the key text object.
[0021] Specifically, this embodiment uses a single image of a circulating document to be detected (such as a screenshot or an image exported from a PDF) as an example. Subsequent document images will all refer to this circulating document image. Because such documents are prone to losing EXIF metadata during the circulation process and undergo multiple lossy compressions and resampling, traditional header-based tampering detection methods become ineffective. Furthermore, non-integer scaling or slight rotations introduced during some screenshot operations or format conversions can disrupt the JPEG compression mesh (typically...). The phase consistency of the pixel matrix across the entire image causes subsequent grid misalignment-based detection algorithms to fail to align. Therefore, to eliminate potential geometric distortions and ensure the phase consistency of the JPEG compressed grid across the entire image, geometric correction of the document image is necessary.
[0022] The specific steps of geometric correction are as follows: First, edge detection and tilt evaluation are performed, that is, the original document image is converted into a grayscale image, the Canny edge detection operator is used to extract the significant edge lines in the document image, the Hough transform is applied to the extracted edge map, the distribution angle of the main straight lines in the document image is statistically analyzed, the angle with the highest cumulative votes is selected as the principal axis angle of the document, and the deviation angle of the principal axis angle relative to the horizontal direction is calculated and recorded as the tilt angle. Considering that the rotation correction interpolation operation will destroy the JPEG compressed grid structure of the original document image (i.e., the discrete characteristics of pixel values), this embodiment does not perform a full-image rotation resampling operation on the original document image (to avoid destroying the original JPEG compressed grid structure). Instead, an affine transformation matrix from the orthogonal correction coordinate system to the original image coordinate system is constructed based on the tilt angle. That is, a virtual orthogonal pixel coordinate system is logically established. This coordinate system maintains a one-to-one mapping relationship with the original tilted document through the matrix, which serves as the reference benchmark for all subsequent feature extraction. After the above corrections, the row and column directions of the document content are strictly parallel to the row and column directions of the pixel matrix. At this point, a Cartesian coordinate system is established with the top-left corner of the corrected document image as the origin, the positive x-axis pointing horizontally to the right, and the positive y-axis pointing vertically downwards. This coordinate system is the global orthogonal pixel coordinate system upon which all feature extraction and grid alignment in subsequent steps depend. Grayscale processing, the Canny edge detection operator, the Hough transform, cumulative voting, and the affine transformation matrix are all well-known and will not be elaborated upon further.
[0023] After establishing a unified coordinate system, it is necessary to accurately locate the key content regions to be verified (such as contract amount, invoice code, signing date, etc.) from unstructured document images. The specific steps are as follows: First, perform OCR layout analysis, that is, use the affine transformation matrix to perform logically corrected view projection on the original document image, or call an optical character recognition engine that supports tilt correction to perform full-image layout analysis on the document image, and identify the bounding boxes of all text lines in the document and their corresponding string content; then, perform key object filtering, that is, according to preset business rules (such as specific keyword matching, regular expressions, or layout position constraints), filter out the key text objects to be detected from the recognition results; finally, perform coordinate recording and cropping, that is, for each key text object, record its bounding box parameters in the global orthogonal pixel coordinate system, including the coordinates of the top left vertex, width, and height, and crop the region containing complete text strokes from the corrected document image according to the bounding box parameters, as the text region of the key text object. Among them, OCR layout analysis, specific keyword matching, regular expressions, layout position constraints, and bounding boxes are all well-known content and will not be elaborated further.
[0024] To utilize the document's own background noise as a self-referenced compression benchmark (i.e., deriving the global JPEG grid and quantization table from the background), it is necessary to extract the background region surrounding each key text object. This ensures that each key text object carries local background information for global statistical use. The specific steps for obtaining the background region are as follows: For any key text object, using the geometric center of its text region as a reference, expand outwards by a preset pixel distance to extract a rectangular region containing the text region itself and surrounding blank areas. This rectangular region serves as the background region for that key text object. It should be noted that if the expanded background region exceeds the document image boundary, the document image boundary will be used as the reference for extraction. Furthermore, when obtaining the background region, an overlap culling operation is performed: the currently expanded rectangular region is compared with the bounding boxes of the text regions of all other key text objects in the document for collision detection. If overlap exists, the pixel values of the overlapping parts are set to invalid or zero, retaining only the clean background pixels that do not overlap for subsequent texture statistics. This is done to prevent high-frequency edges of adjacent text from contaminating the texture features of the background region during dense layout, ensuring the purity of the background statistics. In this embodiment, the preset pixel distance is set to 32 pixels (i.e., expanding 32 pixels in all directions); the basis for setting the preset pixel distance is to ensure that the background area contains a sufficient amount of data. JPEG grid samples for statistical analysis ( (Grid width), while avoiding excessive expansion that could introduce irrelevant interference. In practical applications, implementers can flexibly adjust the preset pixel distance according to the document's resolution and font size. There are no restrictions here, as long as the area containing the background around the text can be extracted.
[0025] It should be noted that subsequent operations involving extracting text or background regions from a document image based on an orthogonal pixel coordinate system refer to using the inverse transformation of the affine transformation matrix to map the target rectangular region in the orthogonal coordinate system back to the coordinate space of the original document image, followed by pixel resampling. To preserve the grayscale discrete features of the original pixels to the greatest extent possible and avoid the smoothing effect introduced by bilinear or cubic interpolation, which could disrupt the potential JPEG grid structure, this embodiment preferably uses the nearest neighbor interpolation algorithm for resampling to obtain orthogonalized image data blocks. Pixel resampling, bilinear interpolation, cubic interpolation, and nearest neighbor interpolation algorithms are all well-known and will not be elaborated further.
[0026] Step S2: Based on the texture features of the background area, statistically obtain the unified JPEG grid reference points and high-frequency zero-value masks for the entire document.
[0027] Specifically, considering that there may be text regions of different polarities in the document layout (such as typical white background with black text and black background with white text in the title bar), and the inability of solid color backgrounds to provide effective information, it is necessary to perform polarity analysis and effectiveness screening on the background region of each key text object before calculating the global baseline. This is because, in the JPEG compression principle, solid color regions (with minimal pixel value changes) have almost all zero high-frequency coefficients after frequency domain transformation, failing to reflect the true information. The block effect introduced by block compression, if solid color regions are included in the statistics, will introduce a large amount of random phase noise, leading to inaccurate subsequent benchmark calculations. Therefore, this embodiment uses the texture features of the background region to statistically obtain a unified JPEG grid reference point and high-frequency zero-value mask for the entire document, accurately determining the global compression phase and quantization dead zone of the document at the last save. This is beneficial for establishing a reliable self-reference benchmark without metadata, providing phase and frequency domain filtering basis for subsequent tamper detection.
[0028] Preferably, in one feasible manner of this embodiment, the method for obtaining the JPEG grid reference point is as follows: For any key text object, the average gray value of all pixels within the text area of the key text object is used as the text reference gray value; the average gray value of all pixels within the background area of the key text object after removing the text area is used as the background reference gray value; when the text reference gray value is greater than the background reference gray value, it indicates that the key text object belongs to the reverse polarity of bright text and dark background (such as white text on a black background). In order to eliminate the interference of bright text strokes on the background texture statistics, while retaining the effective texture information in the dark background, a morphological erosion operation is performed on the background area of the key text object to ensure that the dark background can cover the bright text area; when the text reference gray value is less than the background reference gray value, it indicates that the key text object belongs to the positive polarity of dark text and bright background (such as black text on a white background). In order to eliminate dark text strokes and retain the effective texture information in the bright background, a morphological dilation operation is performed on the background area of the key text object to ensure that the bright background can cover the dark text area. It should be noted that, in order to prevent polarity judgment errors caused by simple grayscale mean comparison (e.g., mistakenly treating text as background erosion, resulting in text area expansion), this embodiment adds a verification logic after performing morphological operations: calculate the variance of the background area after morphological processing. If the variance after processing is significantly greater than before processing (e.g., more than twice as large, indicating the introduction of more high-frequency edges), then the polarity judgment is determined to be incorrect, and the polarity needs to be reversed (i.e., the original erosion is changed to dilation, and the original dilation is changed to erosion) and the morphological operations are re-executed. In this embodiment, the kernel size for morphological processing is set to an adaptive value, for example, dynamically calculated based on the average stroke width of the document. In the formula, K is the kernel size for morphological processing; W is the average stroke width of the document. Minimum safe size; This is the preset adjustment factor; max is the function to retrieve the maximum value. This is the floor sign; this embodiment sets it as follows: Set to 3 (pixels) to ensure that even in documents with extremely small font sizes or very fine strokes, the kernel size can cover basic noise points and avoid excessive erosion; set The value is set to 1.5, ensuring the kernel size is slightly larger than the character stroke width. This effectively eliminates the main text area while preserving background texture details to the greatest extent possible. Implementers can adjust the value based on the document's resolution and font thickness. and No specific limitations are specified here. It should be noted that the average stroke width of the document is obtained through a skeleton extraction algorithm or connected component width statistics. Morphology, skeleton extraction algorithms, and connected component width statistics are all well-known techniques and will not be elaborated further. Considering that if the background area after morphological processing is too flat (solid color), it cannot reflect the JPEG compression block effect and will introduce noise interference to the global benchmark statistics, in order to filter out the background areas containing effective compression traces, the variance of the gray values in the morphologically processed background area is obtained as the first variance. The larger the first variance, the richer the texture variation in the background area (such as containing JPEG compression artifacts, resampling interpolation traces, or quantization noise), and the more significant the compression feature information contained therein. In order to accurately distinguish between solid color areas and effective texture areas, this embodiment sets a preset fluctuation threshold of 5.0 to ensure that only background areas with a certain texture complexity are included in the subsequent statistics. The implementer can set the size of the preset fluctuation threshold according to the inherent noise level of the image sensor and the document scanning quality, which is not limited here. When the first variance is greater than or equal to the preset fluctuation threshold, it means that the background area is not solid color and contains enough background texture to truly reflect the compression characteristics of the document. At this time, the background area of the key text object is marked as valid, which is beneficial to improving the accuracy and robustness of the subsequent global benchmark statistics. To determine the grid boundary locations most significantly affected by JPEG compression for each marked valid background region, ensuring that each marked valid background region can find its true JPEG block starting point and providing reliable local observations for full-document grid alignment, a sliding window differential energy calculation is performed on any marked valid background region. This involves using a sliding window to traverse the block boundary discontinuities of the region under different grid phases, obtaining the block boundary differential energy of the background region at all candidate grid offsets. The sliding window has a step size of 1 pixel and a size consistent with the JPEG standard coding block size. The pixel matrix is used to calculate the discontinuity of block boundaries for each candidate phase by sliding pixel by pixel, thereby accurately locating the optimal grid boundary. It should be noted that because the JPEG standard uses a fixed... The block coding mechanism allows for a range of values for both the vertical and horizontal shifts of the candidate grid offset. The larger the block boundary difference energy, the more significant the abrupt change in the pixel at the grid boundary corresponding to that phase, which best matches the block artifact characteristics introduced by JPEG compression. To capture this real compression trace, this embodiment uses the candidate offset corresponding to the largest block boundary difference energy as the optimal grid phase for the background region, accurately representing the grid starting position of the local region. Then, using the optimal grid phase and the coordinates of the background region in the orthogonal pixel coordinate system, that is, the coordinates of the upper left corner vertex of the background region's rectangle in the global orthogonal pixel coordinate system, the global reference candidate coordinates corresponding to the background region are obtained. Specifically, through... Determine the candidate coordinates of the global reference; where, The x-coordinate value corresponding to the optimal grid phase; y is the ordinate value corresponding to the optimal grid phase; x is the abscissa value of the background region in the orthogonal pixel coordinate system; y is the ordinate value of the background region in the orthogonal pixel coordinate system; mod is the modulo function; where, the block boundary difference energy is a well-known concept and will not be elaborated further. To derive the unique and most reliable grid origin for the entire document from the scattered local candidate coordinates, a weighted voting process based on the background texture variance (first variance) is performed on all global reference candidate coordinates marked as valid background regions. This ensures that background regions with richer textures and higher signal-to-noise ratios have greater weight in the voting. To eliminate interference from individual noisy regions and obtain the global optimal solution, the global reference candidate coordinate with the highest cumulative weight is selected as the unified JPEG grid reference point for the entire document.
[0029] Preferably, in one feasible implementation of this embodiment, the method for obtaining the high-frequency zero-value mask is as follows: For ease of description, this embodiment treats all marked valid background regions as valid background regions, and performs forced grid alignment processing on all valid background regions using JPEG grid reference points, that is, using JPEG grid reference points to map the coordinates of each valid background region to the global coordinates. In the grid system, the top left corner is aligned with the global grid starting point by cropping or padding; to simulate the block quantization mechanism in the JPEG encoding process, the aligned effective background area is further divided into coding block sizes corresponding to the JPEG grid reference points (i.e., Consistent first pixel blocks are used to ensure that each block contains a complete compression unit. To obtain the energy distribution characteristics of each block in the frequency domain, especially the quantization dead zone information in the high-frequency part, a two-dimensional discrete cosine transform is performed on each first pixel block to convert the pixel values in the spatial domain into energy coefficients in the frequency domain, obtaining the first frequency domain coefficient matrix corresponding to each first pixel block. The upper left corner of the matrix represents the DC component, and the lower right corner represents the high-frequency AC component. The DC component reflects the average brightness of the patch, while the AC component contains texture details and JPEG compression features. The discrete cosine transform is a common technique and will not be elaborated further. To eliminate the interference of minor calculation errors and background noise on the determination of quantization dead zones, for any frequency coefficient in the first frequency coefficient matrix (only AC components are counted, i.e., the DC component coefficient in the upper left corner is excluded, because the DC component represents the average brightness of the tile, which is usually not zero in the background area and is not within the scope of quantization dead zone consideration), when the absolute value of the frequency coefficient is less than a preset small threshold, it indicates that the energy of the frequency point is extremely low and is very likely to be quantized to zero (i.e., dead zone) during the original document compression process. In order to mark this potential abnormal energy forbidden zone, the frequency coefficient is forcibly set to 0 at this time; when the absolute value of the frequency coefficient is greater than or equal to the preset small threshold, it indicates that the frequency point has significant energy and belongs to the normal non-zero coefficient area. In order to mark it as a safe area where energy is allowed, the frequency coefficient is forcibly set to 1 at this time. In this embodiment, the preset small threshold is set to 1.0 to ensure that non-zero coefficients caused by floating-point operation errors or extremely weak background noise can be effectively filtered out, while retaining texture energy with practical significance. The implementer can set the size of the preset small threshold according to the document compression quality factor and the coarseness of the quantization table, which is not limited here; To synthesize the statistical patterns of all local background blocks, a frequency domain map reflecting the universal compression characteristics of the entire document is constructed. Then, the most frequent binary result (i.e., the mode of coefficients of 0 or 1 at that position) is obtained from the first frequency domain coefficient matrix after binarization of all effective background regions. This is used as the final result for the corresponding frequency domain position, thus determining a final binary matrix—a frequency domain mask with dead zone positions set to 0 and non-dead zone positions set to 1—serving as a unified high-frequency zero-value mask for the entire document. It should be noted that the high-frequency zero-value mask indicates which frequency domain positions should not contain energy under a specific compression history of the document. If significant energy is found in these dead zone positions during subsequent detection, it is highly likely due to grid misalignment noise introduced by tampering. It should also be noted that if the frequencies of 0 and 1 are equal at a certain frequency domain position (i.e., a tie), to reduce the risk of false alarms, this position is preferentially marked as a non-dead zone (i.e., set to 1), considered a safe area where energy is allowed.
[0030] Step S3: Align the text region with the grid based on the JPEG grid reference points, and obtain the frequency domain residual matrix of the text region by combining it with the high-frequency zero-value mask and convert it into a binary topology map; obtain the noise dispersion of the text region based on the distribution of connected components in the binary topology map.
[0031] Specifically, to detect whether the foreground text region conforms to the JPEG grid pattern of the entire document and ensure that grid misalignment traces introduced by tampering can be effectively captured, the text region is then forced to align with the grid based on the JPEG grid reference points. This involves mapping the local coordinates of the text region to the global grid system using the JPEG grid reference points, and cropping to make its boundaries coincide with the global grid, thus ensuring the text region... The block phase is consistent with the compression phase of the entire document background. In order to isolate the abnormal high-frequency energy introduced only by the tampering operation, the frequency domain coefficients are further filtered by a high-frequency zero-value mask. That is, the frequency domain coefficient values of the text region at the position marked as dead zone (0) in the mask are extracted to obtain the frequency domain residual matrix of the text region. This accurately reflects the energy leakage of the quantization dead zone caused by grid misalignment, which is helpful for locating potential tiling boundaries and recompression traces.
[0032] To further mitigate the interference of high-frequency edge energy of native text on tamper detection, the feature dimension is transformed from amplitude strength to geometric shape. This allows even text edges with extremely high energy amplitudes to be identified as continuous native features and excluded. Furthermore, the frequency domain residual matrix of the text region is converted into a binary topological map, accurately reflecting the distribution and aggregation of abnormal energy in the frequency domain. This helps distinguish between continuous native signals (manifested as clumps) and discrete noise signals (manifested as scattered points). Based on the distribution of connected components in the binary topological map, the noise dispersion of the text region is obtained, accurately reflecting the fragmentation of the frequency domain residual. This facilitates the quantitative characterization of the significance of tampering traces. A greater noise dispersion indicates a more fragmented and discrete point-like distribution of the frequency domain residual energy in the corresponding text region, more closely matching the grid misalignment noise characteristics introduced by tampering splicing or secondary compression (rather than the continuous clump features of native text), thus increasing the likelihood that the corresponding text region has been tampered with.
[0033] Preferably, in one feasible implementation of this embodiment, the method for obtaining the frequency domain residual matrix is as follows: For any text region, the text region is aligned to the global JPEG grid using JPEG grid reference points. Specifically, the phase deviation of the text region relative to the global grid is calculated using the JPEG grid reference points, and the text region is cropped at the top left corner to logically become part of the full document background grid. Furthermore, to prevent insufficient edge block size from causing a mismatch in the discrete cosine transform dimension, this embodiment performs mirror filling or background color filling on the right and bottom edge regions that are less than 8 pixels, ensuring that the aligned image size is [missing information]. Integer multiples of; To simulate the standard JPEG encoding process, the independent frequency domain features of each block are obtained, and then the aligned text region is divided into encoding block sizes corresponding to the JPEG grid reference points (i.e., Consistent second pixel blocks are beneficial for capturing local grid misalignment traces; in order to convert pixel information in the spatial domain into energy distribution in the frequency domain, so that each The texture and edge features of the blocks can be represented in the form of different frequency components (low frequency represents contour, high frequency represents details and noise). Then, a two-dimensional discrete cosine transform is performed on each second pixel block to obtain the second frequency domain coefficient matrix corresponding to each second pixel block. This accurately reflects the energy strength of the text region in each frequency band, which is beneficial for subsequent comparison with the compressed fingerprint (mask) of the whole document. In order to extract only those abnormal energies that violate the compression rules of the whole document (i.e., dead zone energies that should be zero but are not zero), the result of multiplying each second frequency domain coefficient matrix with the high-frequency zero-value mask point by point is used as the frequency domain residual matrix of the text region, which intuitively shows the quantization noise leakage caused by tampering, splicing or secondary compression.
[0034] Preferably, in one feasible embodiment of this method, the binarized topology map is obtained as follows: For any text region, in order to dynamically adjust the segmentation sensitivity according to the energy level of the text region itself and avoid the failure of the fixed threshold under different brightness or different compression intensities, the mean of the absolute values of all non-zero elements in all frequency domain residual matrices of the text region is used as the adaptive segmentation threshold to ensure that the segmented binary map can highlight significant energy anomalies while suppressing weak background noise; furthermore, for any element (i.e., frequency point) in each frequency domain residual matrix of the text region, when the absolute value of the element is greater than the adaptive threshold, the mean of the absolute values of all non-zero elements in all frequency domain residual matrices of the text region is used as the adaptive segmentation threshold. When the segmentation threshold is reached, it indicates that there is significant energy leakage at that frequency point, which is very likely due to grid noise introduced by tampering. In order to mark it as a significant outlier, this element is set to 1. When the absolute value of this element is less than or equal to the adaptive segmentation threshold, it indicates that the energy at that frequency point is weak, which may be due to normal quantization error or background noise. In order to ignore it, this element is set to 0. It should be noted that if the sum of the absolute values of all elements in the calculated frequency domain residual matrix is 0 (i.e., there is no residual), the adaptive segmentation threshold is directly set to 0, and the corresponding binarized topology is set to 0, skipping the subsequent threshold judgment steps. In order to reconstruct the macroscopic geometric distribution from the microscopic block features, so as to carry out subsequent connected component analysis, and then to convert all frequency domain residual matrices of the binarized text region ( The small blocks are spliced together according to the spatial position of their corresponding second pixel blocks in the text region to form a complete binary matrix, which serves as the binary topological map of the text region, intuitively showing the spatial distribution structure of abnormal frequency domain energy in the entire text region (whether it is clustered or discrete like sand).
[0035] Preferably, in one feasible embodiment of this invention, the method for obtaining noise dispersion is as follows: For any text region, in order to cluster the discrete binarized residual pixels into independent objects with geometric shapes, thereby distinguishing between native signals (continuous clusters) and noise signals (discrete isolated points), the 8-neighborhood connected component labeling algorithm is used to scan the binarized topology of the text region to obtain independent connected components, that is, the set of all 1 pixels that are adjacent in the horizontal, vertical or diagonal directions; wherein, the 8-neighborhood connected component labeling algorithm is common content and will not be described in detail; To quantify the size of each connected component and obtain the number of pixels contained in each connected component, which is taken as the first quantity, essentially the area of the corresponding connected component; considering that the high-frequency edges of the original text usually appear as continuous clumps with few connected components and large individual areas in the frequency domain, while the grid noise introduced by the tampering appears as discrete fragments with many connected components and small individual areas, in order to amplify this difference in geometric shape, the noise dispersion of the text region is obtained based on the total number of connected components and the largest first quantity (i.e., the area of the largest connected component), which accurately reflects the spatial fragmentation of the frequency domain residual energy; The total number of connected components is positively correlated with the noise dispersion, while the largest number is negatively correlated with the noise dispersion. The specific formula for calculating the noise dispersion is as follows: In the formula, Q is the noise dispersion; N is the total number of connected components; and S is the maximum first quantity. The minimum positive number is preset. The preset scaling factor; The first preset constant is greater than 0; ln is the logarithmic function with the natural constant as the base; in this embodiment, it is set as follows: for This ensures that the denominator is not zero even in the extreme case of no noise (S=0), guaranteeing computational stability; [The last part, "Setting," appears to be an error and doesn't need a direct translation.] Set to 100 to amplify minute differences in the ratio of the number of connected components to their area to a numerical range that facilitates observation and threshold setting; set Setting the value to 1 ensures that even with extremely small ratios, the input value of the logarithmic function is always greater than or equal to 1, guaranteeing a non-negative and smooth calculation result. Implementers can set this value based on the bit depth of the input image and the system's numerical precision requirements. , and The size is not limited here.
[0036] It should be noted that, in order to provide a global background noise reference for subsequent implementation, this embodiment also needs to calculate the noise dispersion of all marked valid background regions. Specifically, for any valid background region, the processing flow is exactly the same as that used for the text region: grid alignment is performed using JPEG grid reference points, the frequency domain residual matrix is obtained by combining a high-frequency zero-value mask, it is converted into a binary topological map, and the noise dispersion of the valid background region is calculated using the same formula based on the connected component distribution. Finally, the arithmetic mean of the noise dispersion of all valid background regions is calculated as the average background noise of the entire document.
[0037] Step S4: Group the key text objects based on their layout coordinates and obtain a reference benchmark for the noise dispersion within each group; determine the tampering status of the key text objects based on the difference between the noise dispersion and the reference benchmark.
[0038] Specifically, in order to establish a reliable statistical comparison benchmark, the interference of background noise in the document is offset by the principle of homogeneity. Then, the key text objects are grouped based on the layout coordinates of the key text objects. That is, key text objects with the same layout attributes (such as data in the same column) are grouped into the same category. This helps to build a relative noise reference level within the group and ensures that the benchmark value can truly reflect the generation and compression history of the corresponding group of data.
[0039] To obtain the original image quality benchmark for each group of key text objects under tamper-proof conditions, and to exclude the impact of individual tampering values on the benchmark, which could cause the benchmark itself to be an outlier and result in missed detections, a reference benchmark for noise dispersion within each group is obtained. This ensures that the benchmark value can represent the background noise level corresponding to each group of key text objects, which is beneficial for accurately identifying abnormal objects that deviate significantly from the benchmark. Furthermore, based on the difference between the noise dispersion and the reference benchmark, the tampering status of key text objects can be accurately determined, enabling precise location and identification of subtle tampering traces. This is beneficial for improving the robustness and recall of tampering detection in complex workflow scenarios.
[0040] Preferably, in one feasible embodiment, the reference benchmark is obtained as follows: Considering that in structured documents (such as tables and lists), data in the same column usually undergoes a completely consistent generation and compression process, and therefore should have similar noise characteristics, the abscissa of the layout coordinates of each key text object in the orthogonal pixel coordinate system is used as the grouping reference value for each key text object; wherein, the layout coordinates of the key text object in the orthogonal pixel coordinate system are the coordinates of the upper left corner vertex of the text area of the key text object; in order to automatically identify the column structure in the document and tolerate a certain alignment error, the key text objects are grouped according to the grouping reference value using the DBSCAN density clustering algorithm to obtain the object category (i.e., the set of key text objects in the same column), ensuring that even if the document image has slight distortion or the layout is not strictly aligned, they belong to the same logical category. Key text objects in a column can also be grouped together. In this embodiment, the distance threshold of the DBSCAN density clustering algorithm is set to 2% of the total document width. At the same time, a vertical constraint is introduced in the clustering distance calculation: the horizontal distance is only calculated when the projections of two key text objects in the vertical direction overlap and the height difference is within a preset proportion (such as 20%); otherwise, the distance is set to infinity, and they are prohibited from being grouped into the same category. The minimum number of samples for the DBSCAN density clustering algorithm is set to 1 to ensure that even if there is only a single isolated key text object in the document, it can be identified as an independent group, preventing the algorithm from failing to group or crashing due to insufficient sample size. Implementers can adjust the parameters of the DBSCAN density clustering algorithm according to the density of the document layout, which is not limited here. The DBSCAN density clustering algorithm is well known and will not be described in detail here. To obtain the original noise level of the data in the same column and to prevent individual tampered values (outliers) from raising the baseline and causing missed reports, for any object category, the noise dispersion of the text region of the key text objects in that object category is sorted in ascending order to obtain a noise dispersion sequence. Then, the median of the noise dispersion sequence is used as the reference benchmark for the noise dispersion within that object category, because the median has robust statistical properties, is not affected by extreme values, and can truly reflect the noise level of most of the data (i.e., the untampered part).
[0041] Preferably, in one feasible method of this embodiment, the method for determining the tampering status of key text objects based on the difference between noise dispersion and reference benchmark is as follows: For any object category, when the reference benchmark of noise dispersion within the object category is greater than a first preset multiple of the global benchmark noise floor mean, it indicates that the overall noise level of the column data is much higher than the background noise of the entire document, and it is highly likely that the entire column has been replaced and tampered with (such as the entire amount column being re-pasted). At this time, all key text objects within the object category are determined to be tampered areas to avoid missed detections due to anomalies in the reference benchmark itself. In this embodiment, the noise dispersion mean of all effective background areas is used as the global benchmark noise floor mean to ensure that the judgment standard is linked to the overall document quality. The first preset multiple is set to 3 to ensure that only columns that significantly deviate from the background noise level will be triggered by circuit breaking to avoid false alarms. Implementers can set the first preset multiple according to the document type and sensitivity to anomalies, which is not limited here. When the reference benchmark of noise dispersion within the object category is less than or equal to the first preset multiple of the mean global benchmark noise level, it indicates that the overall noise level of the data in this column is within the normal range compared to the background noise of the entire document, and there is no extreme case of the entire column being replaced. It is suitable for relative comparison within the group. In order to distinguish between cases with sufficient and insufficient sample size, different judgment strategies are adopted to ensure that statistically significant judgment results can be given in cases of sparse samples (such as isolated columns) and dense samples (such as monetary columns). Furthermore, the number of key text objects contained in the object category is obtained as a second quantity. Furthermore, when the second quantity is greater than or equal to the preset quantity threshold, it indicates that the sample size within the object category is sufficient and statistically significant, allowing for reliable calculation of relative outlier. At this point, for any key text object within the object category, to eliminate the influence of background noise fluctuations on the judgment result, the ratio of the noise dispersion of the text region of the key text object to the sum of the reference benchmark of the object category and the preset minimum positive number is used as the deviation degree of the key text object (i.e., the relative outlier multiple), accurately reflecting the degree of abnormality of the key text object relative to other key text objects in the same category. In this embodiment, the preset quantity threshold is set to 3 to ensure that at least 3 samples are needed to calculate a meaningful median and outlier; the preset minimum positive number is set to... To ensure that the denominator is not zero and to ensure computational stability; implementers can set preset quantity thresholds and preset minimum positive numbers according to the requirements of statistical sample size, which are not limited here; The greater the deviation, the more significant the feature difference between the key text object and other key text objects in the same group, and the more likely it is to be affected by local grid misalignment noise. Therefore, this embodiment sets a preset relative threshold of 3 to ensure that an object is only considered abnormal when its noise level is significantly higher than (e.g., more than 3 times) the baseline, thus tolerating normal noise fluctuations in a low-noise background. Implementers can set the size of the preset relative threshold according to the document's sensitivity to false alarm rate requirements, which is not limited here. In addition, considering that in extremely high-quality or high-resolution document images, the background noise (baseline value) may be extremely low (even close to 0), even small normal fluctuations can lead to a huge relative deviation multiple, resulting in a large number of false alarms. To avoid this numerical instability problem caused by an excessively low baseline, this embodiment sets a preset background noise threshold as an absolute fallback threshold to ensure that it is only judged as abnormal when the absolute value of the dispersion is also large enough. Implementers can set the size of the preset background noise threshold according to the full document background statistics (mean of effective background variance or mean of dispersion), which is not limited here. When the deviation exceeds a preset relative threshold and the noise dispersion of the key text object exceeds a preset background noise threshold, it indicates that the key text object is not only relatively outlier but also has an abnormally high absolute noise level. In this case, the key text object is determined to be a tampered region, effectively reducing the false alarm rate of low-noise documents. When the deviation is less than or equal to the preset relative threshold, it indicates that the key text object conforms to the same column feature distribution. In this case, the key text object is determined to be an untampered region. When the noise dispersion of the key text object is less than or equal to the preset background noise threshold, it indicates that the noise level of the key text object is extremely low and within a safe range. In this case, the key text object is determined to be an untampered region. When the second quantity is less than the preset quantity threshold, it indicates that the column is an isolated column or the sample is sparse, making it impossible to establish a reliable relative benchmark. In this case, for any key text object within the object category, if the noise dispersion of the key text object is greater than the second preset multiple of the preset background noise threshold, it indicates that the key text object is significantly higher than the background noise of the entire document, and the key text object is determined to be a tampered area. In this embodiment, the second preset multiple is set to 1.5 to ensure that the judgment threshold (relative to the relative threshold) is appropriately increased when there is a lack of intra-group reference, so as to reduce the risk of false alarms. Implementers can set the size of the second preset multiple according to their experience and risk preferences, which is not limited here. The significance of setting the second preset multiple here is: a safety factor, used to provide a more conservative judgment boundary under small sample uncertainty; when the noise dispersion of the key text object is less than or equal to the second preset multiple of the preset background noise threshold, it indicates that the key text object is within the allowable fluctuation range, and the key text object is determined to be an untampered area.
[0042] In summary, this embodiment performs geometric correction on document images and establishes an orthogonal pixel coordinate system to extract key text objects and their background regions. Based on background texture features, it statistically obtains a unified JPEG grid reference point and a high-frequency zero-value mask for the entire document, thus constructing a self-reference reference. It uses the grid reference and zero-value mask to extract the frequency domain residuals of the text regions and converts them into a binarized topological map. By analyzing the distribution of connected components, it obtains the noise dispersion, transforming the feature dimension from energy amplitude to geometric shape. Based on the layout coordinates, key objects are grouped, and the relative reference reference within each group is calculated. The tampering status is determined by comparing the difference between the noise dispersion and the reference. This invention effectively solves the problem of confusion between native content and tampering traces in documents without metadata and with low signal-to-noise ratios, significantly improving the accuracy and robustness of detection.
[0043] Example 2: This invention also proposes a document image tampering detection system; please refer to [link / reference]. Figure 2 The diagram illustrates a document image tampering detection system according to an embodiment of the present invention. The system includes: a region division module 10, an index acquisition module 20, a noise dispersion acquisition module 30, and a text tampering analysis module 40.
[0044] The region segmentation module 10 is used to perform geometric correction on the document image and establish an orthogonal pixel coordinate system to obtain the text region and background region of the key text object.
[0045] The indicator acquisition module 20 is used to statistically obtain the unified JPEG grid reference points and high-frequency zero-value masks for the entire document based on the texture features of the background area.
[0046] The noise dispersion acquisition module 30 is used to perform grid alignment on the text region based on the JPEG grid reference points, and obtain the frequency domain residual matrix of the text region by combining it with the high-frequency zero-value mask and converting it into a binary topology map; and obtain the noise dispersion of the text region based on the distribution of connected components in the binary topology map.
[0047] The text tampering analysis module 40 is used to group key text objects based on their layout coordinates and obtain a reference benchmark for noise dispersion within each group; based on the difference between the noise dispersion and the reference benchmark, the tampering status of the key text objects is determined.
[0048] It should be noted that the system provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the computer device can be divided into different functional modules to complete all or part of the functions described above. In addition, the document image tampering detection system and the document image tampering detection method embodiment provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiment, which will not be repeated here.
[0049] Example 3: This invention also proposes a document image tampering detection device, which includes a memory and a processor. The memory stores executable program code, and the processor is used to call and execute the executable program code to perform a document image tampering detection method provided in the embodiments of this application. Specifically, the device may be a chip, component, or module. The chip may include a connected processor and memory; wherein the memory stores instructions, and when the processor calls and executes the instructions, it can cause the chip to perform the document image tampering detection method provided in the above embodiments.
[0050] In addition, this embodiment also protects a computer device; please refer to [link to relevant documentation]. Figure 3 The computer device includes a memory 401, a processor 402, and a computer program 403 stored in the memory 401 and running on the processor 402. When the processor 402 executes the computer program 403, the computer device can perform any of the document image tampering detection methods described above.
[0051] Example 4: The present invention also provides a computer-readable storage medium storing computer program code, which, when executed on a computer, causes the computer to perform the aforementioned method steps to implement the document image tampering detection method provided in the above embodiments.
[0052] Example 5: The present invention also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement the document image tampering detection method provided in the above embodiments.
[0053] In this embodiment, the device, computer-readable storage medium, computer program product, or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0054] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. The processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0055] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
Claims
1. A method for detecting document image tampering, characterized in that, The method includes the following steps: Perform geometric correction on the document image and establish an orthogonal pixel coordinate system to obtain the text region and background region of key text objects; Based on the texture features of the background region, statistically obtain the unified JPEG grid reference points and high-frequency zero-value masks for the entire document; The text region is aligned with the JPEG grid reference points, and the frequency domain residual matrix of the text region is obtained by combining it with a high-frequency zero-value mask and converted into a binary topology map. The noise dispersion of the text region is obtained based on the distribution of connected components in the binary topology map. The key text objects are grouped based on their layout coordinates, and a reference benchmark for the noise dispersion within each group is obtained. The tampering status of the key text objects is determined based on the difference between the noise dispersion and the reference benchmark.
2. The document image tampering detection method as described in claim 1, characterized in that, The method for obtaining the JPEG grid reference points is as follows: For any key text object, the average grayscale value of all pixels within the text area of the key text object is used as the text reference grayscale value; the average grayscale value of all pixels within the background area of the key text object after removing the text area is used as the background reference grayscale value. When the grayscale value of the text reference is greater than the grayscale value of the background reference, a morphological erosion operation is performed on the background area of the key text object; when the grayscale value of the text reference is less than the grayscale value of the background reference, a morphological dilation operation is performed on the background area of the key text object. The variance of grayscale values within the morphologically processed background region is obtained as the first variance. When the first variance is greater than or equal to the preset fluctuation threshold, the background area of the key text object is marked as valid. For any background region marked as valid, perform sliding window differential energy calculation on the background region to obtain the block boundary differential energy of the background region under all candidate grid offsets; The candidate offset corresponding to the largest block boundary differential energy is taken as the optimal mesh phase for the background region. Using the optimal grid phase and the coordinates of the background region in the orthogonal pixel coordinate system, the global reference candidate coordinates corresponding to the background region are obtained; All global baseline candidate coordinates marked as valid background regions are weighted based on background texture variance and selected as the global baseline candidate coordinates with the highest cumulative weight as the unified JPEG grid reference point for the entire document.
3. The document image tampering detection method as described in claim 2, characterized in that, The method for obtaining the high-frequency zero-value mask is as follows: All marked valid background areas are considered valid background areas. All valid background areas are grid aligned using JPEG grid reference points. The aligned valid background areas are then divided into first pixel blocks with the same size as the coding block corresponding to the JPEG grid reference points. Perform a two-dimensional discrete cosine transform on each first pixel block to obtain the first frequency domain coefficient matrix corresponding to each first pixel block; For any frequency domain coefficient in the first frequency domain coefficient matrix, if the absolute value of the frequency domain coefficient is less than a preset small threshold, the frequency domain coefficient is forcibly set to 0; if the absolute value of the frequency domain coefficient is greater than or equal to the preset small threshold, the frequency domain coefficient is forcibly set to 1. The most frequent binary result at each frequency domain position is obtained from the first frequency domain coefficient matrix after binarization of all valid background regions. This is used as the final result for the corresponding frequency domain position, and a final binary matrix is determined as a unified high-frequency zero-value mask for the entire document.
4. The document image tampering detection method as described in claim 3, characterized in that, The method for obtaining the frequency domain residual matrix is as follows: For any text region, align the text region to the global JPEG grid using the JPEG grid reference point; The aligned text region is divided into second pixel blocks with the same size as the encoding block corresponding to the JPEG grid reference point; Perform a two-dimensional discrete cosine transform on each second pixel block to obtain the second frequency domain coefficient matrix corresponding to each second pixel block; The result of multiplying each second frequency domain coefficient matrix with the high-frequency zero-value mask point by point is used as the frequency domain residual matrix of the text region.
5. The document image tampering detection method as described in claim 4, characterized in that, The method for obtaining the binarized topology map is as follows: For any text region, the mean of the absolute values of all non-zero elements in all frequency domain residual matrices of the text region is used as the adaptive segmentation threshold. For any element in the frequency domain residual matrix of the text region, if the absolute value of the element is greater than the adaptive segmentation threshold, the element is set to 1; if the absolute value of the element is less than or equal to the adaptive segmentation threshold, the element is set to 0. All frequency domain residual matrices of the binarized text region are concatenated and integrated into a complete binary matrix according to the spatial position of the corresponding second pixel block in the text region, which serves as the binarized topology map of the text region.
6. The document image tampering detection method as described in claim 1, characterized in that, The method for obtaining the noise dispersion is as follows: For any text region, the 8-neighborhood connected component labeling algorithm is used to scan the binarized topology of the text region to obtain independent connected components. The number of pixels contained in each of the connected components is taken as the first quantity; The noise dispersion of the text region is obtained based on the total number of connected components and the largest first number; wherein the total number of connected components is positively correlated with the noise dispersion, and the largest first number is negatively correlated with the noise dispersion.
7. The document image tampering detection method as described in claim 1, characterized in that, The method for obtaining the reference benchmark is as follows: The x-coordinate of the layout coordinates of each key text object in the orthogonal pixel coordinate system is used as the grouping reference value for each key text object; Based on the grouping reference values, the key text objects are grouped using the DBSCAN density clustering algorithm to obtain the object categories; For any object category, sort the noise dispersion of the text regions of the key text objects in that object category to obtain a noise dispersion sequence. The median of the noise dispersion sequence is used as the reference benchmark for noise dispersion within the object category.
8. The document image tampering detection method as described in claim 7, characterized in that, The method for determining the tampering status of key text objects based on the difference between noise dispersion and a reference benchmark is as follows: For any object category, when the reference benchmark for noise dispersion within that object category is greater than a first preset multiple of the global benchmark noise floor mean, all key text objects within that object category are determined to be tampered regions. When the reference benchmark for noise dispersion within the object category is less than or equal to a first preset multiple of the global benchmark noise floor mean, the number of key text objects contained within the object category is obtained as the second number. When the second quantity is greater than or equal to the preset quantity threshold, for any key text object within the object category, the ratio of the noise dispersion of the text region of the key text object to the sum of the reference benchmark of the object category and the preset minimum positive number is used as the deviation degree of the key text object. When the deviation is greater than a preset relative threshold and the noise dispersion of the key text object is greater than a preset background noise threshold, the key text object is determined to be a tampered area. When the deviation is less than or equal to a preset relative threshold, the key text object is determined to be an unaltered area; When the noise dispersion of the key text object is less than or equal to the preset background noise threshold, the key text object is determined to be an untampered area; When the second quantity is less than the preset quantity threshold, for any key text object within the object category, if the noise dispersion of the key text object is greater than the second preset multiple of the preset background noise threshold, the key text object is determined to be a tampered area. When the noise dispersion of the key text object is less than or equal to a second preset multiple of the preset background noise threshold, the key text object is determined to be an unaltered area.
9. The document image tampering detection method as described in claim 1, characterized in that, The method for obtaining the background region is as follows: For any key text object, take the center of the text area of the key text object as the reference, expand outward by a preset pixel distance to obtain a rectangular area containing the text area and the surrounding blank area, which is used as the background area of the key text object.
10. A document image tampering detection system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the document image tampering detection method according to any one of claims 1-9.