Image tampering detection method, terminal device and storage medium
By combining Faster-RCNN and LSTM networks in image tampering detection, using resampling and Fourier transform to obtain features, and integrating RGB and resampling trace features, the problem of insufficient feature extraction in the existing technology is solved and the image tampering is improved. Detection accuracy and effectiveness.
Patent Information
- Application Number
- CN202111533371.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-15
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-12-15
AI Technical Summary
Existing deep learning methods are insufficient in feature extraction in image tampering detection, making it difficult to distinguish forged areas from untampered areas. Most feature extraction is based on RGB format images, lacking effective feature fusion.
Using the Faster-RCNN network combined with the LSTM network, the resampled spectrogram is obtained through resampling processing and Fourier transform, and the RGB features and resampled trace features are integrated to build an image tampering detection model, using the EM algorithm and bilinear pooling layer. Feature fusion, and finally tampering detection through softmax layer.
It effectively improves the image tampering detection and positioning capabilities, solves the problem of insufficient feature extraction of deep learning networks in the field of forgery and tampering, and improves the ability to distinguish between forged areas and non-tampered areas.
Smart Images

Figure CN114444565B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image detection, and in particular to an image tampering detection method, terminal equipment and storage medium. Background Art
[0002] With the development of technology and the popularization of software, it has become easier and easier to create high-quality and realistic fake pictures through PS. Many high-quality photoshopped pictures can not only deceive the human eye, but also successfully deceive some detection models, which has caused great harm to the development of social security.
[0003] The basic operations of image tampering can be divided into four categories, namely copying the same image (copy-move), splicing different images (splicing), removing pixels and filling them with other pixels (remove), and generating characters (generated). In order to increase the realism of the forged image, the tamperer not only uses tools to perform edge feathering, brush smearing, color change and other operations, but also performs post-processing operations such as adding noise, adding blur, and compression. These operations make it difficult to distinguish the image features of the forged area from the untampered area, which increases the difficulty of detection to a certain extent.
[0004] The methods of PS tampering identification and positioning are mainly divided into traditional identification methods and deep learning-based methods. Traditional detection and positioning algorithms are algorithms that detect and locate based on their own artificially constructed features and statistical characteristics of images, such as DCT-based forgery and tampering detection algorithms, SIFT detection algorithms, and resampling trace detection algorithms. Deep learning-based detection and positioning algorithms autonomously learn relevant features to detect PS tampered image areas.
[0005] Detection and positioning methods based on deep learning have been developed for some time. However, with the development of image tampering technology, the current tampering detection algorithms also have some shortcomings. For example, most tampering detection and positioning algorithms only perform feature extraction based on RGB format images. The extracted features are limited, making it difficult to distinguish between images of forged areas and non-tampered areas. Summary of the invention
[0006] In order to solve the above problems, the present invention proposes an image tampering detection method, a terminal device and a storage medium.
[0007] The specific plan is as follows:
[0008] A method for detecting image tampering comprises the following steps:
[0009] S1: Collect two types of images, tampered and untampered, to form a training set, and mark the tampered areas in the tampered images in the training set;
[0010] S2: Build an image tampering detection model and train the model using the training set;
[0011] The backbone of the network structure of the image tampering detection model uses the Faster-RCNN network. After the input image is input into the Faster-RCNN network, the candidate box output by the RPN layer in the Faster-RCNN network is input into the ROI pooling layer in the Faster-RCNN network on the one hand, and is input into a new ROI pooling layer together with the input image on the other hand. The image output by the ROIpooling layer is resampled to obtain a resampled spectrum map, which is input into the LSTM network to obtain a resampled feature map. The output of the resampled feature map after the upsampling layer and the convolution layer is input into the bilinear pooling layer together with the output of the Faster-RCNN network for fusion. The fusion result passes through a fully connected layer and a softmax layer to obtain the prediction result of whether it is a tampered image.
[0012] S3: Use the trained model to detect whether the image has been tampered with.
[0013] Furthermore, the resampling process is as follows: after processing the candidate frame area in the image by using the EM algorithm, Fourier transform is performed to obtain a resampled spectrum diagram.
[0014] Furthermore, the loss function L of the image tampering detection model is total The calculation formula is:
[0015] L total =L RPN +L tamper +L bbox
[0016] Among them, L RPN represents the loss function of the RPN layer, L tamper Represents the final classification loss function, L bbox Represents the rectangular box regression loss function.
[0017] Furthermore, the loss function of the RPN layer includes the classification loss function L cls And the regression loss function L reg , the calculation formula of the loss function of the RPN layer is:
[0018]
[0019] Among them, g i represents the predicted classification probability of the candidate box, represents the true label of the candidate box, f i Represents the coordinates of the candidate box prediction, represents the real coordinates of the annotation box corresponding to the candidate box, i represents the sequence number of the candidate box, λ represents the weight coefficient, N cls represents the size of the mini-batch, N reg Indicates the number of candidate boxes.
[0020] Furthermore, the final classification loss function adopts the cross entropy loss function, and the rectangular box regression loss function adopts the SmoothL1 loss function.
[0021] An image tampering detection terminal device comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned method in an embodiment of the present invention when executing the computer program.
[0022] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described above in an embodiment of the present invention are implemented.
[0023] The present invention adopts the above technical solution, uses the resampled features in LSTM, explores the connection between the tampered blocks and the untampered blocks, and solves the problem of insufficient feature extraction of the current deep learning network in the field of counterfeiting and tampering. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 Shown is a flow chart of Embodiment 1 of the present invention.
[0025] Figure 2 Shown is a schematic diagram of the network structure of the image tampering detection model in this embodiment. DETAILED DESCRIPTION
[0026] To further illustrate various embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementations and advantages of the present invention.
[0027] The present invention will now be further described with reference to the accompanying drawings and specific implementation methods.
[0028] Embodiment 1:
[0029] The embodiment of the present invention provides an image tampering detection method, such as Figure 1 As shown, the method comprises the following steps:
[0030] S1: Collect two types of images, tampered and non-tampered, to form a training set, and mark the tampered areas in the tampered images in the training set.
[0031] S2: Build an image tampering detection model and train the model using the training set.
[0032] like Figure 2 As shown in the figure, the backbone of the network structure of the image tampering detection model adopts the Faster-RCNN network. After the input image is input into the Faster-RCNN network, the candidate box output by the RPN layer in the Faster-RCNN network is input into the ROI pooling layer in the Faster-RCNN network on the one hand to complete the part of the original Faster-RCNN network, that is, the coordinates of the candidate box are corresponded to the feature map through the ROIpooling layer, and on the other hand, it is input into a new ROIpooling layer together with the input image to correspond the coordinates of the candidate box to the input image. The image output by the ROI pooling layer is resampled to obtain a resampled spectrum map, and the resampled spectrum map is input into the LSTM network to obtain a resampled feature map. The output of the resampled feature map after the upsampling layer and the convolution layer is input into the bilinear pooling layer together with the output of the Faster-RCNN network for fusion. The fusion result passes through a fully connected layer and a softmax layer to obtain a prediction result of whether it is a tampered image.
[0033] In this embodiment, the input image is an RGB image.
[0034] The resampling process in this embodiment is: after processing the candidate frame area in the image by the EM algorithm, Fourier transform is performed to obtain a resampled spectrum graph. The specific process is:
[0035] 1. First, assume that each sampling point belongs to two models. The first model is the M1 model, which represents the point y currently being investigated. i There is a linear correlation with its neighboring points, that is, these points are generated according to the following model:
[0036]
[0037] In the above formula, n(i) is an independent and identically distributed Gaussian distribution with zero mean and unknown variance σ. The second model is the M2 model, which means that there is no linear correlation between the sample point under investigation and its neighboring points, that is, they are generated by independent processes.
[0038] 2. The EM algorithm is a two-step iterative algorithm: (1) E step: the probability of each sample point belonging to the model is first estimated; (2) M step: the special form of the correlation of the sample point is then estimated. i The probability of the M1 model can be obtained through the Bayesian formula:
[0039]
[0040] In the above formula, Pr{y i ∈M1} and Pr{y i ∈M2} is the prior probability, and the initial value is set to 1 / 2. In addition, y i The probability of belonging to the M1 model can be expressed as:
[0041]
[0042] In the M step, the estimate of the weight vector is calculated using the following formula:
[0043]
[0044] (3) The numerator can be expressed as the prediction residual error, that is:
[0045]
[0046] After completing the calculation of step E, start calculating the weight vector in step M The calculation formula is:
[0047]
[0048] The row vector of the Y matrix is the adjacent 2 points of the original image matrix. N The vector composed of points, W is a diagonal matrix, the values on the diagonal of the matrix are the values of ω(i), and the weight vector calculated by this formula is The E step and the M step are iterated repeatedly until convergence, at which time a final weight vector can be obtained.
[0049] 3. Then, the posterior probability map is Fourier transformed to obtain a resampled spectrum map. The purpose of Fourier transform is to extract those high-frequency components with periodicity and remove the low-frequency components through a high-pass filter. After Fourier transform, if the image contains periodic related information, the Fourier transform map will contain periodic bright spots.
[0050] Loss function L of the image tampering detection model total The calculation formula is:
[0051] L total =L RPN +L tamper +L bbox
[0052] Among them, L RPN represents the loss function of the RPN layer, L tamper Represents the final classification loss function, L bbox Represents the rectangular box regression loss function.
[0053] The RPN layer has two tasks: to determine which candidate frames contain the main body of the picture and which contain only the background from among many candidate frames, i.e., the classification task; for the candidate frames containing the main body, to regress and obtain the true target, i.e., the regression task. Therefore, in this embodiment, the loss of the RPN layer is set to include the classification loss function L cls And the regression loss function L reg , the calculation formula of the loss function of the RPN layer is:
[0054]
[0055] Among them, g i Represents the predicted classification probability of the candidate box (anchor), represents the true label of the candidate box (anchor), f i Represents the coordinates of the candidate box (anchor) prediction, Represents the real coordinates of the annotation box (groundtruth) corresponding to the candidate box (anchor), i represents the sequence number of the candidate box, λ represents the weight coefficient, N cls Indicates the size of the mini-batch, N reg Indicates the number of candidate boxes.
[0056] The final classification loss function uses the cross entropy loss function, and the rectangular box regression loss function uses the SmoothL1 loss function.
[0057] S3: Use the trained model to detect whether the image has been tampered with.
[0058] After the image to be detected is input into the trained image tampering detection model, the model outputs whether the image to be detected is a tampered image.
[0059] The method of the embodiment of the present invention helps to solve the problem that the existing deep learning methods are insufficient in extracting forged features of PS tampered images. The RGB features of the forged area and the features of the resampling traces are integrated into the target detection network, effectively improving the tampering detection and positioning capabilities of the PS image.
[0060] Embodiment 2:
[0061] The present invention also provides an image tampering detection terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above-mentioned method embodiment of the first embodiment of the present invention when executing the computer program.
[0062] Further, as an executable solution, the image tampering detection terminal device can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The image tampering detection terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that the composition structure of the above-mentioned image tampering detection terminal device is only an example of an image tampering detection terminal device, and does not constitute a limitation on the image tampering detection terminal device. It may include more or less components than the above, or a combination of certain components, or different components. For example, the image tampering detection terminal device may also include input and output devices, network access devices, buses, etc., which are not limited in the embodiments of the present invention.
[0063] Further, as an executable solution, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the image tampering detection terminal device, and uses various interfaces and lines to connect various parts of the entire image tampering detection terminal device.
[0064] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the image tampering detection terminal device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0065] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method in the embodiment of the present invention are implemented.
[0066] If the module / unit integrated in the image tampering detection terminal device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) and software distribution medium, etc.
[0067] Although the present invention has been specifically shown and described in conjunction with the preferred embodiments, it should be understood by those skilled in the art that various changes may be made to the present invention in form and details without departing from the spirit and scope of the present invention as defined by the appended claims, all of which are within the scope of protection of the present invention.
Claims
1. A method for detecting image tampering, characterized in that: The following steps are involved: S1: Collect two types of images, tampered and untampered, to form a training set, and mark the tampered areas in the tampered images in the training set; S2: Build an image tampering detection model and train the model using the training set; The backbone of the network structure of the image tampering detection model uses the Faster-RCNN network. After the input image is input into the Faster-RCNN network, the candidate box output by the RPN layer in the Faster-RCNN network is input into the first ROI pooling layer in the Faster-RCNN network on the one hand, and is input into the second ROI pooling layer together with the input image on the other hand. The image output by the second ROIpooling layer is resampled to obtain a resampled spectrum map, and the resampled spectrum map is input into the LSTM network to obtain a resampled feature map. The output of the resampled feature map after the upsampling layer and the convolution layer is input into the bilinear pooling layer together with the output of the Faster-RCNN network for fusion. The fusion result is passed through a fully connected layer and a softmax layer to obtain a prediction result of whether it is a tampered image; the resampling process is as follows: after processing the candidate box area in the image by the EM algorithm, Fourier transform is performed to obtain a resampled spectrum map; S3: Use the trained model to detect whether the image has been tampered with.
2. The image tampering detection method according to claim 1, characterized in that: The loss function L of the image tampering detection model total The calculation formula is: L total =L RPN +L tamper +L bbox Among them, L RPN represents the loss function of the RPN layer, L tamper Represents the final classification loss function, L bbox Represents the rectangular box regression loss function.
3. The image tampering detection method according to claim 2, characterized in that: The loss function of the RPN layer includes the classification loss function L cls And the regression loss function L reg , the loss function of the RPN layer is calculated as: Among them, g i represents the predicted classification probability of the candidate box, represents the true label of the candidate box, f i Represents the coordinates of the candidate box prediction, represents the real coordinates of the annotation box corresponding to the candidate box, i represents the sequence number of the candidate box, λ represents the weight coefficient, N cls represents the size of the mini-batch, N reg Indicates the number of candidate boxes.
4. The image tampering detection method according to claim 2, characterized in that: The final classification loss function uses the cross entropy loss function, and the rectangular box regression loss function uses the SmoothL1 loss function.
5. An image tampering detection terminal device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 4 when executing the computer program.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
