Image tampering detection method
By dividing the image into check blocks and generating watermarks using the MD5 hash function, the high calculation amount and low sensitivity problems of image tamper detection in the prior art are solved, real-time detection and tampering area positioning are realized, and high sensitivity and low cost are achieved. Features.
Patent Information
- Application Number
- CN202411022421.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-11-15
AI Technical Summary
The existing image tamper detection methods have problems such as high computational volume, complex calculations, inability to realize real-time detection, low sensitivity and inability to locate tampered areas.
The original image is divided into verification blocks, a watermark is generated using the MD5 hash function and the least significant bit of the pixel value is embedded. The image tampering is determined by comparing the verification information of the initial watermark image and the watermark image to be detected, and the tampering area is output.
It realizes high-sensitivity image tamper detection, can detect bit-level tampering, low-cost, only requires line cache, is suitable for tampering of any pixel value, and has strong generalization applicability.
Smart Images

Figure CN118967610A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image detection, and in particular relates to an image tampering detection method. Background Art
[0002] In recent years, with the development of computer and network technology, the application of digital images has become more and more extensive. However, due to the characteristics of digital images that are easy to spread and modify, a large number of false forged images have been created, which reduces the reliability of digital images. The security risks of digital images are becoming increasingly serious, and forensic research on malicious tampering has become very important. Image tampering detection technology has emerged as the times require, which greatly protects the authenticity and integrity of images.
[0003] Image tampering can covertly forge images and modify the information conveyed by the image. Existing image tampering detection methods have the following problems: the whole image detection tampering brings high computational complexity and cannot achieve real-time detection; low sensitivity cannot detect specific tampering and is prone to missed detection. Verification information is generated by the whole image, and tampering location cannot be achieved. Summary of the invention
[0004] The purpose of the present invention is to provide an image tampering detection method, which can simultaneously realize the judgment of image tampering and the positioning of tampered areas without the need for additional prior information; it has high sensitivity and can detect bit-level tampering; it has low cost and only involves addition and bit operations and only requires line cache; it has strong generalization and is applicable to any tampering that modifies pixel values.
[0005] The present invention provides an image tampering detection method, comprising:
[0006] S1, dividing the original image into a plurality of check blocks in units of pixels, wherein the check blocks include at least one row of natural pixel areas and at least one row of check pixel areas;
[0007] S2, set the least significant bit of the binary pixel value of each column of pixels in the verification pixel area to zero, perform hash function MD5 verification on the verification block and generate a Y-bit watermark, and embed the Y-bit watermark into the least significant bit of the binary pixel value of each column of pixels in the verification pixel area in sequence; repeat step S2, traverse each of the verification blocks, and embed the verification block into the corresponding watermark to obtain an initial watermark image;
[0008] S3, the initial watermark image may be tampered with during the transmission and use process, and the initial watermark image is defined as the watermark image to be detected after transmission and use;
[0009] S4, selecting a check block of the watermark image to be detected, extracting the least significant bit of the binary pixel value of each column of pixels in the check pixel area of the check block, and setting all the least significant bits to zero; performing MD5 check on the check block of the watermark image to be detected, and calculating the check information;
[0010] S5. Determine whether the verification information of the verification block of the watermark image to be detected at the same position is equal to the verification information of the verification block of the initial watermark image; if they are equal, the watermark image to be detected has not been tampered with; if they are not equal, the watermark image to be detected has been tampered with, and the position of the tampered verification block is output; repeat steps S4 and S5, traverse each of the verification blocks, determine whether the watermark image to be detected has been tampered with, and output the position of the tampered verification block.
[0011] Furthermore, the Y value is 128, the check block includes pixels of n rows*m columns, n is an integer ≥ 2; the product n*m of n and m is an integer multiple of 128, and n*m ≥ 256.
[0012] Furthermore, in one of the verification blocks, the verification pixel area has a total of 128 pixels embedded with the verification watermark.
[0013] Furthermore, after dividing the verification blocks, before the least significant bit of the binary pixel value of each column of pixels in the verification pixel area is set to zero, if the user has hidden information, the image tampering detection method further includes:
[0014] Embed hidden information in the natural pixel area, set the least significant bit of the binary pixel value of each column of pixels in the natural pixel area to zero; embed the hidden information in sequence into the least significant bit of the binary pixel value of each column of pixels in the natural pixel area; the natural pixel area where the hidden information is embedded is defined as an information pixel area.
[0015] Furthermore, the hidden information is represented by a binary string.
[0016] Furthermore, the hidden information in the information pixel area is used to transmit confidential information of the sender, and the information pixel area is used to extract the confidential information transmitted by the sender.
[0017] Furthermore, the coverage area of all the verification blocks is smaller than or equal to the original image.
[0018] Furthermore, among the n rows of pixels in the check block, one row is transmitted normally, and the remaining rows are placed in corresponding row buffers.
[0019] Furthermore, the tampering includes any image tampering including modification of pixel values.
[0020] Furthermore, the image tampering detection method resists at least one of tampering attacks with a mean value of 0, bit tampering attacks, and noise attacks.
[0021] Compared with the prior art, the present invention has the following beneficial effects:
[0022] The present invention provides an image tampering detection method, comprising: S1, dividing an original image into a plurality of check blocks in units of pixels, wherein the check blocks include at least one row of natural pixel areas and at least one row of check pixel areas; S2, setting the least significant bit of the binary pixel value of each column of pixels in the check pixel area to zero, performing a hash function MD5 check on the check block and generating a Y-bit watermark, and embedding the Y-bit watermark into the least significant bit of the binary pixel value of each column of pixels in the check pixel area in sequence; repeating step S2, traversing each of the check blocks, and embedding the check blocks into corresponding watermarks to obtain an initial watermark image; S3, the initial watermark image may be tampered with during transmission and use, and the initial watermark image is defined as a watermark image to be detected after transmission and use; S4, select one of the check blocks of the watermark image to be detected, extract the least significant bit of the binary pixel value of each column of pixels in the check pixel area in the check block, and set all the least significant bits to zero; perform MD5 check on the check block of the watermark image to be detected, and calculate the check information; S5, determine whether the check information of the check block of the watermark image to be detected at the same position is equal to the check information of the check block of the initial watermark image; if they are equal, the watermark image to be detected has not been tampered with; if they are not equal, the watermark image to be detected has been tampered with, and the position of the tampered check block is output; repeat steps S4 and S5, traverse each of the check blocks, determine whether the watermark image to be detected has been tampered with, and output the position of the tampered check block.
[0023] The present invention can simultaneously distinguish image tampering and locate the tampered area without the need for additional priori information; it has high sensitivity and can detect bit-level tampering; it is low-cost and only involves addition and bit operations and only requires line cache; it has strong generalization and is applicable to any tampering that modifies pixel values. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 The figure is a flow chart of an image tampering detection method according to an embodiment of the present invention.
[0025] Figure 2 It is a schematic diagram of dividing an original image into a plurality of check blocks in the image tampering detection method of the present invention.
[0026] Figure 3 It is a schematic diagram of embedding the least significant bit of the binary pixel value of each column of pixels in the verification pixel area in sequence in the image tampering detection method of the present invention.
[0027] Figure 4 Schematic diagram of comparison between the original image and the initial watermark image in the image tampering detection method of the present invention.
[0028] Figure 5 It is a schematic diagram for comparing the initial watermark image, the watermark image to be detected and the detection result image in the image tampering detection method of the present invention.
[0029] The reference numerals are as follows:
[0030] 10-natural pixel area; 20-check pixel area; A-original image; B-check block. DETAILED DESCRIPTION
[0031] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The advantages and features of the present invention will become more apparent from the following description. It should be noted that the accompanying drawings are in a very simplified form and use an inaccurate scale, which is only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention.
[0032] For ease of description, some embodiments of the present application may use spatially relative terms such as "above", "below", "top", "below", etc. to describe the relationship between one element or component and another (or other) elements or components as shown in the various figures of the embodiments. It should be understood that in addition to the orientations described in the drawings, the spatially relative terms are also intended to include different orientations of the device in use or operation. For example, if the device in the drawings is turned over, the elements or components described as being "below" or "below" other elements or components will subsequently be positioned as being "above" or "above" other elements or components. The terms "first", "second", etc. below are used to distinguish between similar elements and are not necessarily used to describe a specific order or time sequence. It is to be understood that these terms used in this way are interchangeable where appropriate.
[0033] The embodiment of the present invention provides an image tampering detection method, such as Figure 1 As shown, including:
[0034] S1, dividing the original image into a number of check blocks in units of pixels, wherein the check blocks include at least one row of natural pixel areas and at least one row of check pixel areas;
[0035] S2, set the least significant bit of the binary pixel value of each column of pixels in the check pixel area to zero, perform hash function MD5 check on the check block and generate a Y-bit watermark, and embed the Y-bit watermark into the least significant bit of the binary pixel value of each column of pixels in the check pixel area in sequence; repeat step S2, traverse each check block, embed the check block into the corresponding watermark to obtain the initial watermark image;
[0036] S3, the initial watermark image may be tampered with during the transmission and use process, and the initial watermark image is defined as the watermark image to be detected after transmission and use;
[0037] S4, selecting a check block of the watermark image to be detected, extracting the least significant bit of the binary pixel value of each column of pixels in the check pixel area of the check block, and setting all the least significant bits to zero; performing MD5 check on the check block of the watermark image to be detected, and calculating the check information;
[0038] S5. Determine whether the verification information of the verification block of the watermark image to be detected at the same position is equal to the verification information of the verification block of the initial watermark image; if they are equal, the watermark image to be detected has not been tampered with; if they are not equal, the watermark image to be detected has been tampered with, and the position of the tampered verification block is output; repeat steps S4 and S5, traverse each verification block, determine whether the watermark image to be detected has been tampered with, and output the position of the tampered verification block.
[0039] The following describes the various steps of the embodiment of the present invention in detail.
[0040] Step S1: Figure 2 and Figure 3 As shown, the original image A is divided into several check blocks B in units of pixels, and the check blocks include at least one row of natural pixel area 10 and at least one row of check pixel area 20. The coverage area of all check blocks B is less than or equal to the original image A, and the coverage area of all check blocks B is as close to the size of the original image A as possible.
[0041] Step S2, set the least significant bit (LSB) of the binary pixel value of each column of pixels in the check pixel area 20 to zero, perform hash function MD5 check on the check block B and generate a Y-bit watermark, and embed the Y-bit watermark into the least significant bit of the binary pixel value of each column of pixels in the check pixel area 20 in turn; repeat step S2, traverse each check block B, and embed each check block B into the corresponding watermark to obtain an initial watermark image.
[0042] Figure 4 Schematic diagram of the comparison between the original image and the initial watermark image in the image tampering detection method of the present invention. Figure 4 As shown, the watermark embedded in the initial watermark image is invisible, and the least significant bit of the binary pixel value of each column of pixels in the check pixel area 20 is embedded in the watermark. The least significant bit has a very subtle effect on the image and does not affect the display format of the image. There is no visual difference between the original image and the initial watermark image, and the PSNR (peak signal-to-noise ratio) = 44.2dB (PSNR>38dB represents high quality).
[0043] A hash function is a function that transforms an input string of any length into an output string of fixed length. The length of the output string is called the number of bits of the hash function. Hash functions, such as MD5, are mostly 128 bits and longer.
[0044] MD5 is a one-way hash function, and the MD5 checksum of a file is a method for verifying the integrity of a file. MD5 (Message Digest Algorithm 5) is a hash algorithm that can convert data of any length into a hash value of a fixed length. In the MD5 algorithm, the input data is divided into 512-bit blocks and processed through a series of bit operations and non-linear functions. In file verification, the MD5 algorithm converts the file content into a unique 128-bit (16-byte) hash value by calculating the hash value of the file. This hash value can be used to verify the integrity of the file, that is, to determine whether the file has been tampered with or damaged. The summary information generated by MD5 is 128 bits.
[0045] The check block B is checked by hash function MD5 and a Y-bit watermark is generated. The Y value is, for example, 128. The check block includes pixels of n rows and m columns, where n is an integer ≥ 2; the product of n and m, n*m, is an integer multiple of 128, and n*m ≥ 256. The check block B includes, for example, pixels of 2 rows and 128 columns, pixels of 4 rows and 64 columns, pixels of 4 rows and 128 columns, etc. The number of rows and columns of the check block is selected to match the 128-bit watermark. The 128-bit watermark is inserted (embedded) into the least significant bit of the binary pixel value of each column of pixels in the check pixel area 20.
[0046] In one of the check blocks, any row of n rows of pixels can be used as a check pixel area 20. When the total number of pixels in a row is less than 128, more than two rows of check pixel areas 20 can be set, as long as the total number of pixels embedded with the check watermark in the check pixel area 20 in the check block B is 128.
[0047] Among the n rows of pixels in the check block B, one row is transmitted normally, and the remaining rows are placed in the corresponding row buffer. In the example where the check block B is 2 rows*128 columns of pixels, one row is transmitted normally, and the other row only needs row buffering, which has low hardware cost.
[0048] Step S3: The initial watermark image may be tampered with during the transmission and use process. After the initial watermark image is transmitted and used, it is defined as the watermark image to be detected. Tampering includes any image tampering that modifies pixel values, such as deletion, copying and pasting, etc.
[0049] Step S4, selecting a check block of the watermark image to be detected, extracting the least significant bit of the binary pixel value of each column of pixels in the check pixel area in the check block, and setting all the least significant bits to zero; performing MD5 check on the check block of the watermark image to be detected, and calculating the check information;
[0050] Step S5, determine whether the verification information of the verification block of the watermark image to be detected at the same position is equal to the verification information of the verification block of the initial watermark image; if they are equal, the watermark image to be detected has not been tampered with; if they are not equal, the watermark image to be detected has been tampered with, and the position of the tampered verification block is output; repeat steps S4 and S5, traverse each verification block, determine whether the watermark image to be detected has been tampered with, and output the position of the tampered verification block.
[0051] The present invention is a tampering detection method based on hash function and self-generated watermark. The present invention uses hash function MD5 to self-generate a unique watermark (also called image block fingerprint) for integrity verification. A sparse check block is constructed, and only half of the pixel LSB is used to embed the self-generated watermark. The natural pixel area 10 is not embedded with the self-generated watermark, and the self-generated watermark is embedded in the check pixel area 20, thereby ensuring a higher image quality.
[0052] Optionally, in another example, after dividing the check blocks B in step S1, before the least significant bit of the binary pixel value of each column of pixels in the check pixel area 20 is set to zero, if the user has hidden information, the image tampering detection method further includes:
[0053] Embed hidden information in the natural pixel area 10, set the least significant bit of the binary pixel value of each column of pixels in the natural pixel area 10 to zero; embed the hidden information in the least significant bit of the binary pixel value of each column of pixels in the natural pixel area 10 in sequence; the natural pixel area 10 where the hidden information is embedded is defined as the information pixel area. The hidden information is represented by a binary string; for example, the hidden information is the character 'A', whose ascii code value is 0100 0001, and the hidden information is represented by the binary string 01000001. The hidden information in the information pixel area is used to transmit the confidential information of the sender, and the information pixel area is used to extract the confidential information transmitted by the sender.
[0054] The check block of the present invention includes at least one row of natural pixel areas 10 and at least one row of check pixel areas 20; the check block B adopts a branch structure of the natural pixel area 10 and the check pixel area 20, which can embed custom hidden information while hiding the watermark position, providing higher security.
[0055] It has been verified that the present invention can effectively resist various tampering attacks, that is, it can effectively detect various tampering. Tampering attacks include, for example, at least one of mean attack, bit attack, and noise attack. In the first example mean attack, the initial watermark image is partially tampered with, and the tampering adds a disturbance with a mean of 0. The tampered area includes a brighter part and a darker part, and the brightness mean of the brighter part and the darker part is 0. The tampering is concealed, and the tampering is passed by the brightness mean equal to 0. However, the image tampering detection method of the present invention is used to clearly detect the tampering area of the mean attack.
[0056] In the second example bit attack, the initial watermark image bits are tampered with, for example, the least significant bit (LSB) of at least one check block in the tampered area is set to zero. The least significant bit has a small impact on the image. Using the image tampering detection method of the present invention, the bit attack tampered area is still clearly detected.
[0057] In the third example noise attack, Figure 5 As shown, the watermark image to be detected is tampered with and salt and pepper noise is added (the white part in the red frame), and the tampered detection area in the detection result diagram is represented by a black block. By using the image tampering detection method of the present invention, the tampered area attacked by the salt and pepper noise is clearly detected.
[0058] In summary, the present invention provides an image tampering detection method, comprising: S1, dividing the original image into a number of check blocks in units of pixels, the check blocks including at least one row of natural pixel areas and at least one row of check pixel areas; S2, setting the least significant bit of the binary pixel value of each column of pixels in the check pixel area to zero, performing a hash function MD5 check on the check block and generating a Y-bit watermark, and embedding the Y-bit watermark into the least significant bit of the binary pixel value of each column of pixels in the check pixel area in sequence; repeating step S2, traversing each check block, and embedding each check block into a corresponding watermark to obtain an initial watermark image; S3, the initial watermark image may be tampered with during the transmission and use process, and the initial watermark image is defined as watermark image to be detected; S4, select a check block of the watermark image to be detected, extract the least significant bit of the binary pixel value of each column of pixels in the check pixel area in the check block, and set all the least significant bits to zero; perform MD5 check on the check block of the watermark image to be detected, and calculate the check information; S5, determine whether the check information of the check block of the watermark image to be detected at the same position is equal to the check information of the check block of the initial watermark image; if they are equal, the watermark image to be detected has not been tampered with; if they are not equal, the watermark image to be detected has been tampered with, and the position of the tampered check block is output; repeat steps S4 and S5, traverse each check block, determine whether the watermark image to be detected has been tampered with, and output the position of the tampered check block.
[0059] The present invention can simultaneously distinguish image tampering and locate the tampered area without the need for additional priori information; it has high sensitivity and can detect bit-level tampering; it is low-cost and only involves addition and bit operations and only requires line cache; it has strong generalization and is applicable to any tampering that modifies pixel values.
[0060] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the method disclosed in the embodiment, since it corresponds to the device disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0061] The above description is only a description of the preferred embodiment of the present invention, and is not any limitation on the scope of rights of the present invention. Any technical personnel in this field can make possible changes and modifications to the technical solution of the present invention by using the methods and technical contents disclosed above without departing from the spirit and scope of the present invention. Therefore, any simple modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the protection scope of the technical solution of the present invention.
Claims
1. A method for detecting image tampering, It is characterized in that include: S1, dividing the original image into a plurality of check blocks in units of pixels, wherein the check blocks include at least one row of natural pixel areas and at least one row of check pixel areas; S2, set the least significant bit of the binary pixel value of each column of pixels in the verification pixel area to zero, perform hash function MD5 verification on the verification block and generate a Y-bit watermark, and embed the Y-bit watermark into the least significant bit of the binary pixel value of each column of pixels in the verification pixel area in sequence; repeat step S2, traverse each of the verification blocks, and embed the verification block into the corresponding watermark to obtain an initial watermark image; S3, the initial watermark image may be tampered with during the transmission and use process, and the initial watermark image is defined as the watermark image to be detected after transmission and use; S4, selecting a check block of the watermark image to be detected, extracting the least significant bit of the binary pixel value of each column of pixels in the check pixel area of the check block, and setting all the least significant bits to zero; performing MD5 check on the check block of the watermark image to be detected, and calculating the check information; S5. Determine whether the verification information of the verification block of the watermark image to be detected at the same position is equal to the verification information of the verification block of the initial watermark image; if they are equal, the watermark image to be detected has not been tampered with; if they are not equal, the watermark image to be detected has been tampered with, and the position of the tampered verification block is output; repeat steps S4 and S5, traverse each of the verification blocks, determine whether the watermark image to be detected has been tampered with, and output the position of the tampered verification block.
2. The image tampering detection method according to claim 1, It is characterized in that The Y value is 128, the check block includes pixels of n rows*m columns, n is an integer ≥ 2; the product of n and m n*m is an integer multiple of 128, and n*m ≥ 256.
3. The image tampering detection method according to claim 2, It is characterized in that In one of the verification blocks, the verification pixel area has a total of 128 pixels embedded with the verification watermark.
4. The image tampering detection method according to claim 1, It is characterized in that After dividing the check blocks, before setting the least significant bit of the binary pixel value of each column of pixels in the check pixel area to zero, if the user has hidden information, the image tampering detection method further includes: Embed hidden information in the natural pixel area, set the least significant bit of the binary pixel value of each column of pixels in the natural pixel area to zero; embed the hidden information in sequence into the least significant bit of the binary pixel value of each column of pixels in the natural pixel area respectively; the natural pixel area where the hidden information is embedded is defined as an information pixel area.
5. The image tampering detection method according to claim 4, It is characterized in that The hidden information is represented by a binary string.
6. The image tampering detection method according to claim 4, It is characterized in that The hidden information in the information pixel area is used to transmit the confidential information of the sender, and the information pixel area is used to extract the confidential information transmitted by the sender.
7. The image tampering detection method according to claim 1, It is characterized in that The coverage area of all the verification blocks is smaller than or equal to the original image.
8. The image tampering detection method according to claim 1, It is characterized in that Among the n rows of pixels in the check block, one row is transmitted normally, and the remaining rows are placed in corresponding row buffers.
9. The image tampering detection method according to claim 1, It is characterized in that The tampering includes any image tampering that modifies pixel values.
10. The image tampering detection method according to claim 9, It is characterized in that The image tampering detection method resists at least one of a tampering attack with a mean value of 0, a bit tampering attack, and a noise attack.
Citation Information
Patent Citations
Self-embedding bifunctional image watermarking method
CN102194209A
Semi-fragile watermarking method based on image tampering positioning and recovering
CN107742272A
Medical image self-recovery method based on image restoration algorithm
CN116416112A
Block fragile watermark generation and authentication method based on chaos hash function
CN1835018A
Data processing method and apparatus
US20030012406A1
