A method and system for image tamper detection based on streaming chunking
Patent Information
- Application Number
- CN202610288640.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-10
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2046-03-10
AI Technical Summary
[0005]本发明解决的技术问题是:现有高分辨率图像水印检测方案在低配硬件下内存占用过高,且简单分块处理会导致边界伪影从而引发误报,以及传统方案依赖原图或全图对齐导致的效率低下问题
[0016]本发明的有益效果:本发明通过流式控制模块,将内存空间复杂度从随图像大小线性增长降低为与图像大小无关的常数级,无论图像分辨率如何增加,内存峰值始终稳定,解决了低配设备内存溢出的问题。本发明利用智能读取模块的重叠缓冲机制和镜像填充机制配合差分判决模块的去伪影裁剪单元,通过多读少取的策略,将JPEG压缩产生的边界振铃效应隔离在缓冲区内并最终丢弃,利用镜像数据保证了物理边界处的频域连续性,彻底消除了分块处理带来的网格白线和边缘白线误报。全链路模拟模块创造性地在内存中基于噪声图动态重构经过JPEG损耗的理论基准,通过全流程模拟抵消了合法压缩带来的系统误差,无需原始图像即可实现高精度的半脆弱检测,且移除了冗余的对齐搜索逻辑,大幅提升了检测速度。
Smart Images

Figure CN122200308B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of digital image processing and information security, and in particular to an image tampering detection method and system based on streaming block segmentation. Background Technology
[0002] With the development of digital business, in scenarios such as financial bill review, insurance claims, and judicial evidence collection, it is necessary to verify the authenticity of high-resolution image data uploaded by users (such as ID photos and on-site investigation photos with more than 12 million pixels). Semi-fragile watermarking, as a mainstream technology, is widely used in such scenarios. Its characteristic is that it remains robust to slight JPEG compression, but is extremely sensitive to malicious tampering. Semi-fragile watermarking refers to a technology between robust watermarking and fragile watermarking. It is not sensitive to non-malicious operations, but can accurately detect malicious tampering. Discrete Cosine Transform (DCT) is a mathematical transformation that converts an image from the spatial domain to the frequency domain. Boundary artifacts refer to the discontinuities or ringing effects that occur at the edges due to the loss of pixel correlation between blocks in block image processing.
[0003] Existing technologies face two major challenges when processing high-resolution images: First, they consume excessive resources. Traditional full-image processing schemes require decoding the entire image and loading it into memory for frequency domain transformation at once. For high-resolution images, the storage requirements for the DCT coefficient matrix are enormous, which can easily lead to memory overflow (OOM) errors in low-configuration cloud containers or edge devices. Second, block detection suffers from artifact false alarms. To reduce memory usage, existing technologies often employ simple block processing. However, since the JPEG compression algorithm is block-based and involves color sampling of adjacent pixels, independent block processing destroys the pixel correlation between blocks, resulting in strong ringing effects at the edges of sub-blocks. During differential detection, these edge noises are misjudged as tampering traces, forming grid-like white lines in the result image as false alarms, severely affecting detection accuracy.
[0004] Currently, Chinese invention patent application number CN202511853548.5 discloses an image tampering detection method based on consistency maps and region growing clustering. This method guides the region growing clustering process by introducing a local consistency metric, explicitly models the spatial connectivity between pixels, and dynamically determines the tampered region by combining the feature distance between clusters. This effectively solves the problems of isolated noise regions caused by the lack of spatial connectivity constraints and the unstable region segmentation caused by the fixed cluster number setting in the prior art. It has the advantages of improving the accuracy of image tampering region localization, enhancing the spatial connectivity constraint capability, reducing isolated noise regions, and improving the accuracy of detection results. However, existing high-resolution image watermark detection schemes have excessive memory consumption under low-configuration hardware, and simple block processing can lead to boundary artifacts and false alarms. In addition, traditional schemes rely on original image or full image alignment, resulting in low efficiency. Summary of the Invention
[0005] The technical problems solved by this invention are: existing high-resolution image watermark detection schemes have excessive memory consumption under low-configuration hardware, and simple block processing can lead to boundary artifacts and false alarms, as well as the inefficiency caused by traditional schemes relying on original image or full image alignment.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: an image tampering detection method based on streaming block segmentation, comprising the following steps: Step S1: Initialize the streaming processing environment, read the metadata information of the image to be detected, initialize the all-black result container used to store the final detection result, and based on the double loop traversal, load only a single standard logic unit into memory for processing each time, and release the intermediate variables after processing is completed. Step S2: Based on the current standard logical unit index and the overlapping buffer parameters, calculate the theoretical extended reading coordinate range, perform an intersection operation with the physical boundary to obtain the original valid sub-blocks, and use the mirror filling algorithm to reconstruct the boundary to generate extended sub-block data; Step S3: Perform frequency domain transformation on the extended sub-block data to generate a measured binary watermark image, generate a Gaussian random noise image in memory, calculate the global offset based on the absolute position of the current standard logic unit, perform watermark embedding and JPEG simulation compression operations on the Gaussian random noise image, and generate a simulation reference image. Step S4: Calculate the XOR difference between the measured binary watermark image and the simulated baseline image, generate an extended difference image, perform a center cropping operation on the extended difference image, output a clean difference block, map the clean difference block back to the all-black result container, calculate the noise density, and determine the image state according to a preset threshold.
[0007] Preferably, step S1 includes the following sub-steps: Step S11: Initialize the streaming processing environment, read the metadata information of the image to be detected, determine the size of the standard logic unit according to the preset parameters, and initialize the all-black result container used to store the final detection result; Step S12: Construct a double loop traversal structure based on row and column coordinates, and traverse each standard logical unit of the image to be detected in the order from left to right and from top to bottom; Step S13: Within a single iteration cycle of the double loop, perform streaming loading of single data blocks and immediate release of intermediate variables.
[0008] Preferably, step S11 specifically includes the following sub-steps: Step S111: Read only the file header information of the image to be detected through the image decoding library to obtain the physical width W and physical height H of the image to be detected; Step S112: Define the size N of the standard logical unit, calculate the number of logical blocks in the horizontal and vertical directions of the image to be detected, and construct a virtual grid-like segmentation index; Step S113: Allocate and initialize a W×H black result container in memory to fill the detected tampered area.
[0009] Preferably, step S12 specifically includes the following sub-steps: Step S121: The double loop traversal structure includes an outer loop and an inner loop. The outer loop is established to traverse the vertical logical index of the image to be detected and calculate the starting vertical coordinate of the current processing row. Step S122: Establish an inner loop, traverse the horizontal logical index of the image to be detected, and calculate the starting horizontal coordinate of the current processing column; Step S123: Based on the row and column indices of the starting y-coordinate and starting x-coordinate of the current loop ( Combined with the standard logic unit size N, the physical pixel coordinate range of the current standard logic unit in the original image is calculated.
[0010] Preferably, step S13 specifically includes the following sub-steps: Step S131: Based on the physical pixel coordinate range calculated in step S123, dynamically crop and decode the corresponding local pixel data from the source image file, and load it into memory as the current processing block; Step S132: Execute the tamper detection algorithm process on the current processing block, generating temporary intermediate variables in the process; Step S133: After the detection result of the current processing block is written to the result container, the pixel data and all corresponding intermediate variables of the current processing block are immediately released explicitly, and memory control is returned to the operating system.
[0011] Preferably, step S2 includes the following sub-steps: Step S21: Based on the current standard logical unit index and the preset overlap buffer parameters, calculate the theoretical extended read coordinate range, which includes the following sub-steps: Step S211: Define the width of the overlap buffer as P, the size of the standard logic unit as N, and obtain the absolute position of the current standard logic unit, which includes the row index i and the column index j; Step S212: Calculate the initial longitudinal coordinates and termination coordinates and horizontal starting coordinates and termination coordinates This forms an extended read region, whose mathematical expression is: ; in, and The vertical start and end coordinates are... and These are the horizontal start and end coordinates. The preset block size, This is the preset buffer width; Step S213: Record the position information of the extended reading area in the logical coordinate system, which allows negative values and values exceeding the physical size of the image; Step S22: Perform an intersection operation between the theoretical extended reading coordinate range and the physical boundary of the image to be detected to obtain the effective physical reading region and read the pixel data. This includes the following sub-steps: Step S221: Read the physical width W and physical height H of the image to be detected, and perform cropping constraints on the coordinates calculated in step S212 and the physical boundary [0, 0, W, H] to obtain the effective physical reading coordinates. , , , Its constraint logic includes: ; ; ; ; Step S222: Using the file read pointer, read the pixel matrix corresponding to the valid physical read coordinates from the image to be detected to obtain the original valid sub-blocks; Step S223: Calculate the size of the original effective sub-block and compare it with the target expansion size. Compare the data to obtain the number of missing rows and columns of pixels in the four directions: top, bottom, left, and right. Step S23: Reconstruct the boundaries of the original valid sub-blocks using the mirror fill algorithm to generate extended sub-block data of uniform size. This includes the following sub-steps: Step S231: Determine the filling direction and filling width based on the number of missing pixels calculated in step S223; Step S232: Invoke the mirror fill algorithm, using the edge pixels of the original valid sub-block as the axis of symmetry, to symmetrically flip and copy the pixel data inside the sub-block to the outer missing area. The mirror fill algorithm adopts the BORDER_REFLECT_101 mode, and its mathematical expression is: ; Where x and y are the x-coordinate and y-coordinate of the pixel, respectively. These are the pixel values after filling. These are the original image pixel values; When x<0, y<0 and y≥H, the mirror filling algorithm with respect to the corresponding physical boundary is used in a similar manner. Step S233: Integrate the padded data into the final expanded sub-block data, the size of which is strictly equal to the target expanded size.
[0012] Preferably, step S3 includes the following sub-steps: Step S31: Extract frequency domain features from the extended sub-block data to generate a measured binary watermark image, which includes the following sub-steps: Step S311: Convert the extended sub-block data from RGB color space to YUV color space and extract the Y channel components; Step S312: Divide the Y channel components into For each pixel block, perform a two-dimensional discrete cosine transform (DCT). Step S313: According to the preset embedding rules, compare the magnitude relationship of a pair of intermediate frequency coefficients, extract the measured watermark bit sequence, and reassemble it into a two-dimensional measured binary watermark image; Step S32: Construct a full-link simulation environment and generate random noise data for benchmark reconstruction in memory. This includes the following sub-steps: Step S321: Allocate and initialize a Gaussian random noise graph in memory. The size of the Gaussian random noise graph is strictly equal to the size of the extended sub-block data. Step S322: Calculate the global offset of watermark embedding based on the absolute position of the current standard logic unit in the whole picture, to ensure that the simulated watermark pattern is aligned with the measured picture in phase. Step S33: Perform a full-link simulation operation on the random noise data to generate a simulation baseline map.
[0013] Preferably, step S33 specifically includes the following sub-steps: Step S331: Pass the global offset into the embedding algorithm, execute the preset embedding rules on the Gaussian random noise map, and modify the corresponding discrete cosine transform coefficient relationship; Step S332: Perform JPEG simulation compression on the embedded Gaussian random noise map, obtain the quantization table of the image to be detected, set the compression quality factor to be consistent with the image to be detected, and simulate quantization error; Step S333: Perform frequency domain feature extraction on the simulated compressed Gaussian random noise map, and perform 8×8 copy expansion on the extracted block domain bit matrix to generate a simulated reference map.
[0014] Preferably, step S4 includes the following sub-steps: Step S41: Perform pixel-level difference operations and artifact removal cropping to generate a clean difference block, which includes the following sub-steps: Step S411: Calculate the XOR difference between the two-dimensional measured binary watermark image and the simulated baseline image to generate an extended difference image. Its mathematical expression is: ; in, To expand the difference map, These are the pixel coordinates of the difference map. This is a measured binary watermark image. For simulating the baseline diagram; Step S412: Perform a center clipping operation on the extended difference map, retaining only the central region. The data is directly discarded, and the edge data with a width of P around it is output as a clean differential block; Step S42: Map the clean differential block back to the full image result container, and determine the image state based on the noise density. This includes the following sub-steps: Step S421: Based on the row and column index of the current standard logic unit ( ), calculate the write position of the clean differential block in the all-black result container, and fill the write position with the data of the clean differential block; Step S422: After completing the traversal and filling of all blocks in the entire image, count the total number of white noise points in the all-black result container, and calculate the proportion of the total number of white noise points to the total number of pixels in the entire image to obtain the noise density. Step S423: Based on noise density, and according to a preset threshold judgment logic, output the final detection result. The judgment logic includes: ; in, For the test results, The preset compression threshold is used for judgment. The preset tolerance threshold, This represents the noise density.
[0015] A streaming block-based image tampering detection system is provided. This system executes a streaming block-based image tampering detection method, including a streaming control module, an intelligent reading module, a full-link simulation module, and a differential decision module. The streaming control module is used to initialize the streaming processing environment, read the metadata information of the image to be detected, initialize the all-black result container for storing the final detection result, and based on the double loop traversal, load only a single standard logic unit into memory for processing each time, and release the intermediate variables after processing is completed. The intelligent reading module is used to calculate the theoretical extended reading coordinate range based on the current traversal standard logical unit index and the overlapping buffer parameters, perform intersection operation with the physical boundary to obtain the original valid sub-block, and use the mirror filling algorithm to reconstruct the boundary to generate extended sub-block data. The full-link simulation module is used to perform frequency domain transformation on the extended sub-block data to generate a measured binary watermark image, generate a Gaussian random noise image in memory, calculate the global offset based on the absolute position of the current standard logic unit, perform watermark embedding and JPEG simulation compression operations on the Gaussian random noise image, and generate a simulation reference image. The differential decision module is used to calculate the XOR difference between the measured binary watermark image and the simulated reference image, generate an extended differential image, perform a center cropping operation on the extended differential image, output a clean differential block, map the clean differential block back to the all-black result container, calculate the noise density, and determine the image state according to a preset threshold.
[0016] The beneficial effects of this invention are as follows: This invention, through a streaming control module, reduces the memory space complexity from linearly increasing with image size to a constant level independent of image size. Regardless of the increase in image resolution, the memory peak remains stable, solving the memory overflow problem on low-end devices. This invention utilizes the overlapping buffer mechanism and mirror filling mechanism of the intelligent reading module, combined with the artifact removal and cropping unit of the differential decision module. Through a strategy of reading more and fetching less, the boundary ringing effect caused by JPEG compression is isolated in the buffer and ultimately discarded. Mirror data ensures the frequency domain continuity at physical boundaries, completely eliminating false alarms of grid white lines and edge white lines caused by block processing. The end-to-end simulation module creatively reconstructs the theoretical benchmark after JPEG loss in memory based on the noise map. Through end-to-end simulation, it offsets the systematic errors caused by legitimate compression, achieving high-precision semi-fragile detection without the original image. Furthermore, it removes redundant alignment search logic, significantly improving detection speed. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the basic process of an image tampering detection method based on streaming block full-link simulation, provided as an embodiment of the present invention. Detailed Implementation
[0018] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0019] Reference Figure 1 As an embodiment of the present invention, an image tampering detection method based on streaming block segmentation is provided, comprising the following steps: Step S1: Initialize the streaming processing environment, read the metadata information of the image to be detected, initialize the all-black result container used to store the final detection result, and based on the double loop traversal, load only a single standard logic unit into memory for processing each time, and release the intermediate variables after processing is completed. Step S2: Based on the current standard logical unit index and the overlapping buffer parameters, calculate the theoretical extended reading coordinate range, perform an intersection operation with the physical boundary to obtain the original valid sub-blocks, and use the mirror filling algorithm to reconstruct the boundary to generate extended sub-block data; Step S3: Perform frequency domain transformation on the extended sub-block data to generate a measured binary watermark image, generate a Gaussian random noise image in memory, calculate the global offset based on the absolute position of the current standard logic unit, perform watermark embedding and JPEG simulation compression operations on the Gaussian random noise image, and generate a simulation reference image. Step S4: Calculate the XOR difference between the measured binary watermark image and the simulated baseline image, generate an extended difference image, perform a center cropping operation on the extended difference image, output a clean difference block, map the clean difference block back to the all-black result container, calculate the noise density, and determine the image state according to a preset threshold.
[0020] This invention achieves low memory usage through a streaming block architecture and utilizes overlapping buffers, mirror filling, and full-link simulation techniques to eliminate boundary artifacts caused by block partitioning without the original image, thus realizing efficient and accurate tamper detection of high-resolution images.
[0021] Step S1 includes the following sub-steps: Step S11: Initialize the streaming processing environment, read the metadata information of the image to be detected, determine the size of the standard logic unit according to the preset parameters, and initialize the all-black result container used to store the final detection result; Step S12: Construct a double loop traversal structure based on row and column coordinates, and traverse each standard logical unit of the image to be detected in the order from left to right and from top to bottom; Step S13: Within a single iteration cycle of the double loop, perform streaming loading of single data blocks and immediate release of intermediate variables.
[0022] Step S1 aims to solve the memory bottleneck problem in high-resolution image processing by establishing a streaming block architecture to break down large images into smaller parts. By using logical grid partitioning and physical batch loading, the peak memory usage is always limited to a very low level (less than 100MB) when processing images with a resolution of 12 megapixels or even higher. Compared to traditional full-image loading solutions, this streaming processing environment enables high-precision tamper detection algorithms to run on memory-constrained edge devices, IoT terminals, or low-configuration cloud containers, significantly reducing hardware costs and avoiding the risk of service crashes due to OutOfMemoryError (OOM).
[0023] The specific steps of streaming block processing are defined in detail. A memory-friendly processing architecture is constructed through environment initialization, double loop traversal, and immediate release of single data blocks. Its core effect is reducing the space complexity of image processing from O(N), which increases linearly with image size, to a constant O(1), independent of image size. This enables the algorithm to stably process high-resolution images, such as those above 12 megapixels, on memory-constrained edge devices or low-configuration cloud containers, effectively avoiding the risk of OutOfMemoryError (OOM) caused by loading the entire image at once.
[0024] Step S11 specifically includes the following sub-steps: Step S111: Read only the file header information of the image to be detected through the image decoding library to obtain the physical width W and physical height H of the image to be detected; Step S112: Define the size N of the standard logical unit, calculate the number of logical blocks in the horizontal and vertical directions of the image to be detected, and construct a virtual grid-like segmentation index; Step S113: Allocate and initialize a W×H black result container in memory to fill the detected tampered area.
[0025] In this embodiment, in step S111, the image processing library (such as PIL's lazy loading mode) is used to read the metadata, avoiding the use of a full loading mode like cv2.imread, to prevent hundreds of megabytes of memory from being occupied during the initialization phase, and at this time the pixel matrix data of the image is not loaded into memory. In step S112, the size N of the standard logic unit is preset to 512 pixels, and the number of logic blocks is calculated by rounding up to ensure full coverage of the image; In step S113, the all-black result container only stores the binarized detection result (black and white image), which is used to fill the detected tampered area later. Its bit depth is much smaller than the original color image, so the memory usage is extremely low.
[0026] By retrieving metadata from only the file header instead of loading the pixel matrix, the program's startup memory usage is significantly reduced. Simultaneously, initializing a completely black result container (binary image) instead of a full-color image minimizes the memory overhead of the result data while ensuring sufficient storage, laying the foundation for efficient subsequent processing.
[0027] Step S12 specifically includes the following sub-steps: Step S121: The double loop traversal structure includes an outer loop and an inner loop. The outer loop is established to traverse the vertical logical index of the image to be detected and calculate the starting vertical coordinate of the current processing row. Step S122: Establish an inner loop, traverse the horizontal logical index of the image to be detected, and calculate the starting horizontal coordinate of the current processing column; Step S123: Based on the row and column indices of the starting y-coordinate and starting x-coordinate of the current loop ( Combined with the standard logic unit size N, the physical pixel coordinate range of the current standard logic unit in the original image is calculated.
[0028] In this embodiment, steps S121 and S122 together constitute the driving engine of streaming processing. By controlling the processing progress through a dual loop, it ensures that each pixel region is accessed only once (without considering the case of subsequent overlapping buffers). In step S123, the physical pixel coordinate range is used for subsequent file pointer positioning and local reading.
[0029] The double loop ensures complete and comprehensive coverage of high-resolution images by precisely calculating the mapping relationship between row and column indices and physical pixel coordinates. This provides accurate file pointer positioning for subsequent local reads and forms the logical foundation for implementing streaming block processing.
[0030] Step S13 specifically includes the following sub-steps: Step S131: Based on the physical pixel coordinate range calculated in step S123, dynamically crop and decode the corresponding local pixel data from the source image file, and load it into memory as the current processing block; Step S132: Execute the tamper detection algorithm process on the current processing block, generating temporary intermediate variables in the process; Step S133: After the detection result of the current processing block is written to the result container, the pixel data and all corresponding intermediate variables of the current processing block are immediately released explicitly, and memory control is returned to the operating system.
[0031] In this embodiment, in step S13, the system at any given time contains only the data of a standard logic unit and a small number of algorithm context variables in memory; Intermediate variables include: matrix data converted from RGB to YUV color space, coefficient matrix after DCT transformation, generated analog noise map, and local difference map; Step S131 utilizes the random read feature of the file system to load only the necessary data into RAM; Step S133 ensures that the memory usage curve rises in a sawtooth pattern rather than a step pattern by using explicit garbage collection or memory release instructions (such as del operations) to prevent memory leaks.
[0032] Through steps S11 to S13, the original O(N) space complexity operation that required loading the entire image at once is transformed into an O(1) constant-level space complexity operation that is only related to the block size, thereby establishing a stable streaming architecture when processing high-resolution images.
[0033] Define the size of the standard logic unit as N=512. Traverse the logical blocks of the image through a double loop. In each loop, only the memory space required for the current block is requested. After processing, release intermediate variables such as the DCT coefficient matrix and the temporary difference map immediately, so as to ensure that the memory usage is constant-level complexity O(1) and does not accumulate with the increase of image size.
[0034] Dynamic pruning and loading leverages the random access characteristics of the file system, loading only the currently necessary data into memory; by immediately and explicitly releasing and forcibly reclaiming intermediate variables (DCT matrix, YUV data), it ensures that the memory usage curve rises in a sawtooth pattern rather than a step-like manner. This mechanism is a key execution method to ensure that the system does not experience memory leaks and maintains low peak memory usage during long-term operation.
[0035] Step S2 includes the following sub-steps: Step S21: Based on the current standard logical unit index and the preset overlap buffer parameters, calculate the theoretical extended read coordinate range, which includes the following sub-steps: Step S211: Define the width of the overlap buffer as P, the size of the standard logic unit as N, and obtain the absolute position of the current standard logic unit, which includes the row index i and the column index j; Step S212: Calculate the initial longitudinal coordinates and termination coordinates and horizontal starting coordinates and termination coordinates This forms an extended read region, whose mathematical expression is: ; in, and The vertical start and end coordinates are... and These are the horizontal start and end coordinates. The preset block size, This is the preset buffer width; Step S213: Record the position information of the extended reading area in the logical coordinate system, which allows negative values and values exceeding the physical size of the image; Step S22: Perform an intersection operation between the theoretical extended reading coordinate range and the physical boundary of the image to be detected to obtain the effective physical reading region and read the pixel data. This includes the following sub-steps: Step S221: Read the physical width W and physical height H of the image to be detected, and perform cropping constraints on the coordinates calculated in step S212 and the physical boundary [0, 0, W, H] to obtain the effective physical reading coordinates. , , , Its constraint logic includes: ; ; ; ; Step S222: Using the file read pointer, read the pixel matrix corresponding to the valid physical read coordinates from the image to be detected to obtain the original valid sub-blocks; Step S223: Calculate the size of the original effective sub-block and compare it with the target expansion size. Compare the data to obtain the number of missing rows and columns of pixels in the four directions: top, bottom, left, and right. Step S23: Reconstruct the boundaries of the original valid sub-blocks using the mirror fill algorithm to generate extended sub-block data of uniform size. This includes the following sub-steps: Step S231: Determine the filling direction and filling width based on the number of missing pixels calculated in step S223; Step S232: Invoke the mirror fill algorithm, using the edge pixels of the original valid sub-block as the axis of symmetry, to symmetrically flip and copy the pixel data inside the sub-block to the outer missing area. The mirror fill algorithm adopts the BORDER_REFLECT_101 mode, and its mathematical expression is: ; Where x and y are the x-coordinate and y-coordinate of the pixel, respectively. These are the pixel values after filling. These are the original image pixel values; When x<0, y<0 and y≥H, the mirror filling algorithm with respect to the corresponding physical boundary is used in a similar manner. Step S233: Integrate the padded data into the final expanded sub-block data, the size of which is strictly equal to the target expanded size.
[0036] In this embodiment, in step S211, N=512 pixels and P=16 pixels are preset. The buffer width is set based on a multiple of the 8*8 block size of the JPEG compression standard to ensure that the entire compressed block influence field is covered. In step S213, the calculated coordinates may be negative (when processing the left or top edge of the image) or larger than the physical size of the image (when processing the right or bottom edge of the image). These values are used to determine the boundary filling requirements in the subsequent process.
[0037] In this embodiment, in step S222, the read operation only targets the actual pixels that exist in the physical file and does not include any padding data; In step S223, if the current block is located at the center of the image, there are no missing pixels; if it is located at the edge, the missing amount is equal to the buffer width P or the remaining portion of the image edge that is less than N plus P.
[0038] In step S232, if x < 0, the mirror fill logic of the left boundary of the layout is triggered, and mapping is performed with the left edge of the image (index 0) as the axis of symmetry. Its mathematical expression is: ; in, The absolute value of x is used to map negative coordinates to corresponding positive coordinates within the image. If y < 0, the mirror fill logic of the upper boundary is triggered, and mapping is performed with the upper edge of the image (index 0) as the axis of symmetry. Its mathematical expression is: ; in, The absolute value of y is used to map negative ordinates to corresponding positive ordinates within the image. like This triggers the mirror fill logic at the lower boundary, using the lower edge of the image (index). -1) Mapping to the axis of symmetry, its mathematical expression is: ; in, The physical height of the image to be detected is used to map coordinates that extend beyond the lower boundary back into the image. Combining the above logic with the right boundary logic, it is ensured that all coordinates within the extended reading range are legally mapped to the valid physical range of the original image, thereby constructing continuous and smooth out-of-boundary data.
[0039] In this embodiment, instead of copying the boundary pixels themselves, the k-th pixel outside the boundary is mapped to the k-th pixel inside the boundary, with the boundary pixels as the axis (for example, x=-1 is mapped to x=1, x=-2 is mapped to x=2). This avoids unnatural texture caused by the repetition of boundary pixels and ensures the continuity of energy during frequency domain transformation.
[0040] Steps S21 to S23 complete the data preparation stage for the "read more, retrieve less" strategy. Regardless of whether the current processing block is located at the center or edge of the image, the system can obtain an extended sub-block of data with a fixed size and smooth edge frequency domain features. The mirror fill algorithm symmetrically flips and copies the edge pixels inside the image around the boundary axis, ensuring a smooth energy transition during frequency domain transformation. Compared to zero-padding or repeated padding, mirror fill guarantees the continuity of the image at the boundary and the smoothness of the first derivative, avoiding high-frequency artifacts caused by abrupt boundary changes in subsequent DCT frequency domain transformation, thereby preventing false alarms of edge white lines.
[0041] Step S2 aims to address the boundary effects introduced by block processing; The overlapping buffer mechanism ensures that pixels at the edges of standard logical units can obtain complete neighborhood information in subsequent processing steps, thereby limiting the ringing effect caused by JPEG compression to the buffer. By using a mirror filling mechanism, the problem of missing data at physical boundaries is creatively solved. A virtual boundary that conforms to the statistical laws of natural images is artificially constructed, so that the frequency domain transformation algorithm will not produce the Gibbs phenomenon caused by data truncation when processing edge blocks. This is a key preliminary step for achieving zero artifact detection.
[0042] For example: Define the overlap buffer width P=16, and when processing the standard logic unit in the i-th row and j-th column, calculate its extended readout area in the original image. The calculation formula is as follows: ; This yields a dimension of (512+16+16). (512 + 16 + 16) = 544 544 extended region; Detect whether the reading area exceeds the physical boundary W of the original image. If an out-of-bounds error occurs, a mirror fill algorithm is used to fill in the missing pixels. For example, if the rightmost boundary of the image is at x=W, but x=W+5 needs to be read, the mirror fill algorithm will symmetrically copy the pixels from x=W-1 to x=W-6 outside the boundary. This filling method ensures a smooth transition of image content at the boundary, eliminates false alarms of white lines in physical edge detection caused by frequency abrupt changes, and finally outputs a uniformly sized extended sub-block data Block_Padded.
[0043] This ensures that pixels at the edges of standard logical units possess complete neighborhood information in subsequent processing, thus confining the JPEG compression ringing effect inevitably generated by block processing within the buffer and preventing it from contaminating the core data. To address the issue of missing physical boundary data, a smooth virtual boundary is constructed through symmetrical replication. Compared to zero-padding, mirror padding guarantees the continuity of frequency domain energy at the image boundaries, avoiding high-frequency artifacts generated in the DCT transform due to data abrupt changes, thereby completely eliminating false positives for white lines at the physical edges of the image.
[0044] Step S3 includes the following sub-steps: Step S31: Extract frequency domain features from the extended sub-block data to generate a measured binary watermark image, which includes the following sub-steps: Step S311: Convert the extended sub-block data from RGB color space to YUV color space and extract the Y channel components; Step S312: Divide the Y channel component into pixel blocks, and perform two-dimensional Discrete Cosine Transform (DCT) on each pixel block; Step S313: Compare the magnitude relationship of a pair of intermediate frequency coefficients according to a preset embedding rule, extract the measured watermark bit sequence, and reorganize it into a two-dimensional measured binary watermark image; Step S32: Construct a full-link simulation environment, and generate random noise data for reference reconstruction in the memory, which specifically includes the following sub-steps: Step S321: Apply for and initialize a Gaussian random noise map in the memory, and the size of the Gaussian random noise map is strictly equal to the size of the extended sub-block data; Step S322: Calculate the global offset of watermark embedding according to the absolute position of the current standard logic unit in the whole image, so as to ensure that the simulated generated watermark pattern is aligned with the measured image in phase; Step S33: Perform full-link simulation operation on the random noise data to generate a simulated reference image.
[0045] In this embodiment, step S313 specifically includes the following sub-steps: Step S3131: In each DCT transform block, locate the position of the preset intermediate frequency coefficient pair, specifically select the coefficient DCT[4,3] at the 4th row and 3rd column and the coefficient DCT[3,4] at the 3rd row and 4th column; Step S3132: Read the values of the intermediate frequency coefficient pair, perform a numerical comparison operation, and judge the magnitude relationship between DCT[4,3] and DCT[3,4]; Step S3133: Determine the watermark bit value carried by the current block according to the magnitude relationship. If DCT[4,3] DCT[3,4], the extracted watermark bit is determined to be 1; If DCT[4,3]<DCT[3,4], the extracted watermark bit is determined to be 0; Step S3134: Obtain the spatial index of the current pixel block in the extended sub-block data, map the extracted watermark bit to the corresponding coordinate position of the two-dimensional matrix, and reorganize to generate a two-dimensional measured binary watermark image after traversing all pixel blocks.
[0046] In this embodiment, the watermark embedding is the operation of the preset embedding rule; In step S3131, DCT[4,3] and DCT[3,4] are selected because these two mid-frequency coefficients represent the texture intensity of the image patch in the vertical and horizontal directions, respectively. They are in the moderately sensitive area of human visual perception, which can ensure the robustness of the watermark under a certain degree of JPEG compression (semi-fragile characteristics) and can also keenly capture malicious tampering operations through the coefficient quantization relationship. In step S3133, the determination logic is the reverse process of the sending end embedding rules. It does not require the original image to participate and can complete blind extraction based solely on the relative size between coefficients. In step S3134, the generated two-dimensional measured binary watermark image is a binary image matrix, the size of which is the same as that contained in the extended sub-block data. The number of blocks corresponds to the size. This is used for subsequent pixel-level XOR difference operations with the simulated reference image. After traversing all 8×8 pixel blocks, the block watermark bit matrix is obtained, and each bit is copied and filled into its corresponding 8×8 pixel area to generate a measured binary watermark image of the same size as the extended sub-block data, with a size of (N+2P)×(N+2P).
[0047] In this embodiment, in step S321, a pseudo-random number generator is used to generate the Gaussian random noise map, and a seed calculated from a preset key Key and a global offset is used to ensure that noise maps generated at the same position can be reproduced. The size of the generated Gaussian random noise map is 544. 544. Gaussian random noise is used to demonstrate that the detection benchmark is independent of the specific content of the image (such as texture and edges) and is only related to the embedding and compression process, thereby enabling blind detection; Step S322 specifically includes the following sub-steps: Calculate the absolute physical coordinates of the top-left vertex of the extended sub-block data in the original image coordinate system, and use this as the global offset for watermark embedding. Its mathematical expression is: ; When the offset is positive, the global offset is passed into the watermark generation algorithm as a phase correction parameter, so that when watermarking is embedded in the random noise map in memory, the generated binary watermark pattern and the pattern of the original image at the corresponding physical location are spatially consistent. When the offset is negative, the global offset is passed into the watermark generation algorithm as a phase correction parameter. In the watermark generation algorithm, the offset is mapped to the positive period through modulo operation, so that when the random noise map is embedded in memory, the generated binary watermark pattern and the pattern of the original image at the corresponding physical location are spatially consistent.
[0048] In this embodiment, the overlap buffer width P must be included when calculating the global offset because the simulated baseline reconstruction is for a target size expansion. The expansion of the sub-blocks is performed; ignoring P will lead to phase misalignment. Phase alignment is crucial because the watermark is based on preset layout parameters (such as...). If the watermark phase of the simulated reference image is inconsistent with that of the measured image, the two will not be able to cancel each other out during the differential operation, resulting in a large number of artifact noise. By introducing a global offset, it is ensured that the theoretically simulated watermark generated in memory can accurately reproduce the watermark bit distribution that the sender should have at that position, regardless of which block of the image is being processed, thus guaranteeing the effectiveness of differential detection.
[0049] Through steps S31 to S33, benchmark reconstruction based on full-link simulation is realized. On the one hand, the measured watermark is extracted from the extended sub-block data, and on the other hand, the theoretical benchmark with the same loss is dynamically generated in memory.
[0050] Step S3 aims to solve the technical challenge of not having an original, watermark-free image as a comparison benchmark, and adopts a full-link simulation approach; Instead of directly comparing the original image pixels, the measured extracted watermark is compared with the simulated benchmark watermark by dynamically reconstructing the theoretical benchmark after JPEG loss in memory. This step utilizes the complete neighborhood information provided by the extended sub-block data to ensure that the boundary effects in the simulation process are completely consistent with the actual measurement process. Combined with subsequent differential operations, it can effectively distinguish between legitimate JPEG compression traces and malicious tampering traces.
[0051] The watermark extraction logic based on DCT intermediate frequency coefficient comparison was clarified, and blind extraction of semi-fragile watermarks was achieved. By generating a Gaussian random noise map in memory, it was proven that the detection benchmark is independent of the image content, achieving detection without the original image. The phase alignment problem in block processing was solved. By calculating the absolute coordinate offset, it was ensured that the simulated watermark pattern generated in memory and the watermark pattern in the measured image are strictly consistent in spatial phase. This is a prerequisite for subsequent differential operations to correctly cancel the signal in the untampered area.
[0052] Step S33 specifically includes the following sub-steps: Step S331: Pass the global offset into the embedding algorithm, execute the preset embedding rules on the Gaussian random noise map, and modify the corresponding discrete cosine transform coefficient relationship; Step S332: Perform JPEG simulation compression on the embedded Gaussian random noise map, obtain the quantization table of the image to be detected, set the compression quality factor to be consistent with the image to be detected, and simulate quantization error; Step S333: Perform frequency domain feature extraction on the simulated compressed Gaussian random noise map, and perform 8×8 copy expansion on the extracted block domain bit matrix to generate a simulated reference map.
[0053] In this embodiment, step S331 specifically includes the following sub-steps: Step S3311: Perform color space conversion and frequency domain transformation on the Gaussian random noise map, converting it from RGB space to YUV space, extracting the Y channel components, and processing each... Perform a two-dimensional discrete cosine transform (DCT) on the pixel block to obtain the DCT coefficient matrix of the noise map; Step S3312: Utilize global offset Combined with the relative coordinates of the current pixel block within the extended sub-block, calculate the absolute mapping coordinates of the pixel block in the global watermark mask; Step S3313: Based on the absolute mapping coordinates, query the preset watermark generation rules to determine the target watermark bit value that should be embedded in the current pixel block; The preset watermark generation rules include: based on preset strings (such as "TCL") and layout parameters (such as... , The generated global binary mask can accurately determine whether the current block should theoretically carry bit 1 or bit 0 through absolute mapping coordinates; Step S3314: Based on the target watermark bit value, modulate the corresponding intermediate frequency coefficient pairs in the DCT coefficient matrix of the noise map, modify the size relationship between DCT[4,3] and DCT[3,4] according to the preset embedding rules, and introduce the preset intensity factor to complete the embedding operation; The modulation logic is completely identical to that of the transmitter: if the target bit is 1, the adjustment coefficient makes... ; If the target bit is 0, then the adjustment coefficient makes ,in The preset strength factor (e.g., 18) is used to ensure that the watermark has a certain degree of robustness to resist JPEG compression; Step S3315: Perform Inverse Discrete Cosine Transform (IDCT) on the modulated DCT coefficient matrix to restore the data to the spatial domain and generate a watermarked noise map. Performing IDCT is to restore the frequency domain data to image data so that subsequent step S332 can perform standard JPEG compression simulation on the image, thereby completely reproducing the entire signal loss process from embedding to compression.
[0054] Step S332 specifically includes the following sub-steps: Step S3321: Read the file header information of the image to be detected, parse and extract its JPEG quantization table and estimate its compression quality factor. If the image to be detected has no quantization table information, call the preset standard quantization table and default quality factor as control parameters for simulated compression. Step S3322: Using control parameters, perform JPEG encoding on the watermarked Gaussian random noise map generated in step S331, quantize the frequency domain coefficients, and simulate the lossy compression process of the signal. Step S3323: Perform JPEG decoding on the encoded data to restore the data to a spatial domain pixel matrix, resulting in an analog compressed noise map with analog quantization error.
[0055] In this embodiment, in step S3321, in order to ensure the accuracy of the end-to-end simulation, it is necessary to ensure that the quantization step size in the simulation process is consistent with the quantization step size experienced by the image to be detected, and the compression quality factor is between 90 and 95. In steps S3322 and S3323, the encoding to decoding loop is not for compressing file size, but to introduce the same degree of block artifacts and quantization noise as the original image into the Gaussian noise map in memory. This is a key step to offset legitimate compression errors and achieve zero false alarms. In step S333, the extraction logic is exactly the same as the measured extraction logic in step S313, ensuring that in the untampered area, the two-dimensional measured binary watermark image and the simulated reference image should theoretically be consistent (i.e., the bit values are the same), so that they cancel each other out to 0 (black) during differential extraction.
[0056] The end-to-end simulation introduces legitimate loss quantization noise of the same degree as the measured image into the theoretical benchmark by applying embedding rules and JPEG simulation compression identical to those at the sending end to the noise map. This step effectively offsets the errors caused by normal JPEG compression, ensuring that the final difference result only reflects malicious tampering traces, greatly reducing the false alarm rate for compressed images.
[0057] Step S4 includes the following sub-steps: Step S41: Perform pixel-level difference operations and artifact removal cropping to generate a clean difference block, which includes the following sub-steps: Step S411: Calculate the XOR difference between the two-dimensional measured binary watermark image and the simulated baseline image to generate an extended difference image. Its mathematical expression is: ; in, To expand the difference map, These are the pixel coordinates of the difference map. This is a measured binary watermark image. For simulating the baseline diagram; Step S412: Perform a center clipping operation on the extended difference map, retaining only the central region. The data is directly discarded, and the edge data with a width of P around it is output as a clean differential block; Step S42: Map the clean differential block back to the full image result container, and determine the image state based on the noise density. This includes the following sub-steps: Step S421: Based on the row and column index of the current standard logic unit ( ), calculate the write position of the clean differential block in the all-black result container, and fill the write position with the data of the clean differential block; Step S422: After completing the traversal and filling of all blocks in the entire image, count the total number of white noise points in the all-black result container, and calculate the proportion of the total number of white noise points to the total number of pixels in the entire image to obtain the noise density. Step S423: Based on noise density, and according to a preset threshold judgment logic, output the final detection result. The judgment logic includes: ; in, For the test results, The preset compression threshold is used for judgment. The preset tolerance threshold, This represents the noise density.
[0058] In this embodiment, in step S411, since the JPEG compression algorithm relies on adjacent pixels, the four edges of the extended difference map (i.e., the extended P-pixel area) will contain a large number of ringing noise points caused by discontinuous boundary data or padding data. These noise points are an inevitable product of block processing. The XOR operation can detect bits that are inconsistent between the two-dimensional measured binary watermark map and the simulated reference map. Step S412 specifically includes the following sub-steps: Step S4121: Based on the preset overlap buffer width P and standard logic unit size N, determine the effective data index range in the extended difference graph, and define the vertical range of the clipping window as [P, P+N] and the horizontal range as [P, P+N]. Step S4122: Using matrix slicing operation, extract pixel data located within the clipping window from the extended difference map, and physically remove the surrounding annular data region with a width of P. Step S4123: Output the truncated data to generate a clean differential block, the size of which is strictly equal to the size of a standard logic unit. .
[0059] In this embodiment, in step S4121, since the total size of the extended difference map is (N+2P)... (N+2P), the starting index P means skipping the buffers on the left and top sides, and the ending index P+N means discarding the buffers on the right and bottom sides. In step S4122, the removed edge data includes the boundary ringing effect caused by the block-based independent compression process and the frequency domain noise introduced by the padding data; In step S4123, through this strategy of reading more and taking less, the clean differential block that is retained only contains the central pixel with complete neighborhood information, thereby ensuring that the simulated benchmark and the measured data in this area have completely consistent boundary conditions in theory, and completely eliminating the false alarm of grid-like white lines that are common in traditional block detection.
[0060] In step S421, when the current standard logic unit is located at the right or lower boundary of the image, resulting in the effective region size being smaller than... At that time, the clean differential block is cropped accordingly, and only the valid area that overlaps with the physical range of the image is written into the result container.
[0061] In step S423, Set at 70%, If the tampering is determined to be localized, morphological operations (such as dilatation and erosion) are used to perform cluster analysis on the noise points to accurately locate the tampered area.
[0062] By implementing a strategy of reading more and retrieving less, edge data containing ringing effects and filling noise is physically discarded, and only the pure central region is retained, which fundamentally eliminates the grid-like false alarms common in block detection, i.e., artifact removal.
[0063] It provides quantitative grading criteria that can automatically distinguish between original images, compressed images, and tampered images, and accurately locate tampered areas using spatial density, thereby improving the interpretability and accuracy of detection results.
[0064] A streaming block-based image tampering detection system is provided. This system executes a streaming block-based image tampering detection method, including a streaming control module, an intelligent reading module, a full-link simulation module, and a differential decision module. The streaming control module is used to initialize the streaming processing environment, read the metadata information of the image to be detected, initialize the all-black result container used to store the final detection results, and based on the double loop traversal, load only a single standard logic unit into memory for processing each time, and release the intermediate variables after processing is completed. The intelligent reading module is used to calculate the theoretical extended reading coordinate range based on the index of the standard logical unit being traversed and the overlapping buffer parameters, perform an intersection operation with the physical boundary to obtain the original valid sub-block, and use the mirror filling algorithm to reconstruct the boundary to generate extended sub-block data; The full-link simulation module is used to perform frequency domain transformation on the extended sub-block data to generate a measured binary watermark image, generate a Gaussian random noise image in memory, calculate the global offset based on the absolute position of the current standard logic unit, perform watermark embedding and JPEG simulation compression operations on the Gaussian random noise image, and generate a simulation reference image. The differential decision module is used to calculate the XOR difference between the measured binary watermark image and the simulated baseline image, generate an extended differential image, perform a center cropping operation on the extended differential image, output a clean differential block, map the clean differential block back to the all-black result container, calculate the noise density, and determine the image state according to a preset threshold.
[0065] This invention reduces memory space complexity from linearly increasing with image size to a constant level independent of image size through a streaming control module. Regardless of image resolution, the peak memory usage remains stable, resolving memory overflow issues on low-end devices. The invention utilizes the overlapping buffer and mirror filling mechanisms of the intelligent reading module, combined with the artifact removal and cropping unit of the differential decision module. Through a strategy of reading more and retrieving less, it isolates and discards the boundary ringing effect caused by JPEG compression within a buffer. Mirror data ensures frequency domain continuity at physical boundaries, completely eliminating false alarms of grid white lines and edge white lines caused by block processing. The end-to-end simulation module creatively reconstructs the theoretical benchmark after JPEG loss in memory based on a noise map. Through end-to-end simulation, it offsets the systematic errors caused by legitimate compression, achieving high-precision semi-fragile detection without the original image. Furthermore, it removes redundant alignment search logic, significantly improving detection speed.
[0066] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0067] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the protection scope of the present invention.
Claims
1. A method for detecting image tampering based on streaming block segmentation, characterized in that, Includes the following steps: Step S1: Initialize the streaming processing environment, read the metadata information of the image to be detected, initialize the all-black result container used to store the final detection result, and based on the double loop traversal, load only a single standard logic unit into memory for processing each time, and release the intermediate variables after processing is completed. Step S2: Based on the current standard logical unit index and the overlapping buffer parameters, calculate the theoretical extended reading coordinate range, perform an intersection operation with the physical boundary to obtain the original valid sub-blocks, and use the mirror filling algorithm to reconstruct the boundary to generate extended sub-block data; Step S2 includes the following sub-steps: Step S21: Based on the current standard logical unit index and the preset overlap buffer parameters, calculate the theoretical extended read coordinate range, which includes the following sub-steps: Step S211: Define the width of the overlap buffer as P, the size of the standard logic unit as N, and obtain the absolute position of the current standard logic unit, which includes the row index i and the column index j; Step S212: Calculate the initial longitudinal coordinates and termination coordinates and horizontal starting coordinates and termination coordinates This forms an extended read region, whose mathematical expression is: ; in, and The vertical start and end coordinates are... and These are the horizontal start and end coordinates. The preset block size, This is the preset buffer width; Step S213: Record the position information of the extended reading area in the logical coordinate system, which allows negative values and values exceeding the physical size of the image; Step S22: Perform an intersection operation between the theoretical extended reading coordinate range and the physical boundary of the image to be detected to obtain the effective physical reading region and read the pixel data. This includes the following sub-steps: Step S221: Read the physical width W and physical height H of the image to be detected, and perform cropping constraints on the coordinates calculated in step S212 and the physical boundary [0, 0, W, H] to obtain the effective physical reading coordinates. , , , Its constraint logic includes: ; ; ; ; Step S222: Using the file read pointer, read the pixel matrix corresponding to the valid physical read coordinates from the image to be detected to obtain the original valid sub-blocks; Step S223: Calculate the size of the original effective sub-block and compare it with the target expansion size. Compare the data to obtain the number of missing rows and columns of pixels in the four directions: top, bottom, left, and right. Step S23: Reconstruct the boundaries of the original valid sub-blocks using the mirror fill algorithm to generate extended sub-block data of uniform size. This includes the following sub-steps: Step S231: Determine the filling direction and filling width based on the number of missing pixels calculated in step S223; Step S232: Invoke the mirror fill algorithm, using the edge pixels of the original valid sub-block as the axis of symmetry, to symmetrically flip and copy the pixel data inside the sub-block to the outer missing area. The mirror fill algorithm adopts the BORDER_REFLECT_101 mode, and its mathematical expression is: ; Where x and y are the x-coordinate and y-coordinate of the pixel, respectively. These are the pixel values after filling. These are the original image pixel values; When x<0, y<0 and y≥H, the mirror filling algorithm with respect to the corresponding physical boundary is used in a similar manner. Step S233: Integrate the padded data into the final expanded sub-block data, the size of which is strictly equal to the target expanded size; Step S3: Perform frequency domain transformation on the extended sub-block data to generate a measured binary watermark image, generate a Gaussian random noise image in memory, calculate the global offset based on the absolute position of the current standard logic unit, perform watermark embedding and JPEG simulation compression operations on the Gaussian random noise image, and generate a simulation reference image. Step S4: Calculate the XOR difference between the measured binary watermark image and the simulated baseline image, generate an extended difference image, perform a center cropping operation on the extended difference image, output a clean difference block, map the clean difference block back to the all-black result container, calculate the noise density, and determine the image state according to a preset threshold.
2. The image tampering detection method based on streaming block segmentation as described in claim 1, characterized in that, Step S1 includes the following sub-steps: Step S11: Initialize the streaming processing environment, read the metadata information of the image to be detected, determine the size of the standard logic unit according to the preset parameters, and initialize the all-black result container used to store the final detection result; Step S12: Construct a double loop traversal structure based on row and column coordinates, and traverse each standard logical unit of the image to be detected in the order from left to right and from top to bottom; Step S13: Within a single iteration cycle of the double loop, perform streaming loading of single data blocks and immediate release of intermediate variables.
3. The image tampering detection method based on streaming block segmentation as described in claim 2, characterized in that, Step S11 specifically includes the following sub-steps: Step S111: Read only the file header information of the image to be detected through the image decoding library to obtain the physical width W and physical height H of the image to be detected; Step S112: Define the size N of the standard logical unit, calculate the number of logical blocks in the horizontal and vertical directions of the image to be detected, and construct a virtual grid-like segmentation index; Step S113: Allocate and initialize a W×H black result container in memory to fill the detected tampered area.
4. The image tampering detection method based on streaming block segmentation as described in claim 2, characterized in that, Step S12 specifically includes the following sub-steps: Step S121: The double loop traversal structure includes an outer loop and an inner loop. The outer loop is established to traverse the vertical logical index of the image to be detected and calculate the starting vertical coordinate of the current processing row. Step S122: Establish an inner loop, traverse the horizontal logical index of the image to be detected, and calculate the starting horizontal coordinate of the current processing column; Step S123: Based on the row and column indices of the starting y-coordinate and starting x-coordinate of the current loop ( Combined with the standard logic unit size N, the physical pixel coordinate range of the current standard logic unit in the original image is calculated.
5. The image tampering detection method based on streaming block segmentation as described in claim 4, characterized in that, Step S13 specifically includes the following sub-steps: Step S131: Based on the physical pixel coordinate range calculated in step S123, dynamically crop and decode the corresponding local pixel data from the source image file, and load it into memory as the current processing block; Step S132: Execute the tamper detection algorithm process on the current processing block, generating temporary intermediate variables in the process; Step S133: After the detection result of the current processing block is written to the result container, the pixel data and all corresponding intermediate variables of the current processing block are immediately released explicitly, and memory control is returned to the operating system.
6. The image tampering detection method based on streaming block segmentation as described in claim 1, characterized in that, Step S3 includes the following sub-steps: Step S31: Extract frequency domain features from the extended sub-block data to generate a measured binary watermark image, which includes the following sub-steps: Step S311: Convert the extended sub-block data from RGB color space to YUV color space and extract the Y channel components; Step S312: Divide the Y channel components into For each pixel block, perform a two-dimensional discrete cosine transform (DCT). Step S313: According to the preset embedding rules, compare the magnitude relationship of a pair of intermediate frequency coefficients, extract the measured watermark bit sequence, and reassemble it into a two-dimensional measured binary watermark image; Step S32: Construct a full-link simulation environment and generate random noise data for benchmark reconstruction in memory. This includes the following sub-steps: Step S321: Allocate and initialize a Gaussian random noise graph in memory. The size of the Gaussian random noise graph is strictly equal to the size of the extended sub-block data. Step S322: Calculate the global offset of watermark embedding based on the absolute position of the current standard logic unit in the whole picture, to ensure that the simulated watermark pattern is aligned with the measured picture in phase. Step S33: Perform a full-link simulation operation on the random noise data to generate a simulation baseline map.
7. The image tampering detection method based on streaming block segmentation as described in claim 6, characterized in that, Step S33 specifically includes the following sub-steps: Step S331: Pass the global offset into the embedding algorithm, execute the preset embedding rules on the Gaussian random noise map, and modify the corresponding discrete cosine transform coefficient relationship; Step S332: Perform JPEG simulation compression on the embedded Gaussian random noise map, obtain the quantization table of the image to be detected, set the compression quality factor to be consistent with the image to be detected, and simulate quantization error; Step S333: Perform frequency domain feature extraction on the simulated compressed Gaussian random noise map, and perform 8×8 copy expansion on the extracted block domain bit matrix to generate a simulated reference map.
8. The image tampering detection method based on streaming block segmentation as described in claim 1, characterized in that, Step S4 includes the following sub-steps: Step S41: Perform pixel-level difference operations and artifact removal cropping to generate a clean difference block, which includes the following sub-steps: Step S411: Calculate the XOR difference between the two-dimensional measured binary watermark image and the simulated baseline image to generate an extended difference image. Its mathematical expression is: ; in, To expand the difference map, These are the pixel coordinates of the difference map. This is a measured binary watermark image. For simulating the baseline diagram; Step S412: Perform a center clipping operation on the extended difference map, retaining only the central region. The data is directly discarded, and the edge data with a width of P around it is output as a clean differential block; Step S42: Map the clean differential block back to the full image result container, and determine the image state based on the noise density. This includes the following sub-steps: Step S421: Based on the row and column index of the current standard logic unit ( ), calculate the write position of the clean differential block in the all-black result container, and fill the write position with the data of the clean differential block; Step S422: After completing the traversal and filling of all blocks in the entire image, count the total number of white noise points in the all-black result container, and calculate the proportion of the total number of white noise points to the total number of pixels in the entire image to obtain the noise density. Step S423: Based on noise density, and according to a preset threshold judgment logic, output the final detection result. The judgment logic includes: ; in, For the test results, The preset compression threshold is used for judgment. The preset tolerance threshold, This represents the noise density.
9. A streaming block-based image tampering detection system, the system being used to execute any one of the streaming block-based image tampering detection methods as claimed in claims 1 to 8, characterized in that, It includes a streaming control module, an intelligent reading module, a full-link simulation module, and a differential decision module: The streaming control module is used to initialize the streaming processing environment, read the metadata information of the image to be detected, initialize the all-black result container for storing the final detection result, and based on the double loop traversal, load only a single standard logic unit into memory for processing each time, and release the intermediate variables after processing is completed. The intelligent reading module is used to calculate the theoretical extended reading coordinate range based on the standard logical unit index of the current traversal and the overlapping buffer parameters, perform intersection operation with the physical boundary to obtain the original valid sub-block, and use the mirror filling algorithm to reconstruct the boundary to generate extended sub-block data. The full-link simulation module is used to perform frequency domain transformation on the extended sub-block data to generate a measured binary watermark image, generate a Gaussian random noise image in memory, calculate the global offset based on the absolute position of the current standard logic unit, perform watermark embedding and JPEG simulation compression operations on the Gaussian random noise image, and generate a simulation reference image. The differential decision module is used to calculate the XOR difference between the measured binary watermark image and the simulated reference image, generate an extended differential image, perform a center cropping operation on the extended differential image, output a clean differential block, map the clean differential block back to the all-black result container, calculate the noise density, and determine the image state according to a preset threshold.
Citation Information
Patent Citations
Image tampering detection method based on consistency graph and region growing clustering
CN121353883A
Image-tampering detection and recovery method based on energy-domain semi-fragile watermarking
CN101901470A
Image tamper-proofing detection algorithm based on DCT
CN112017093A