# Detection of Forged Images Using a Combination of Passive Methods Based on Neural Networks
## 3 Materials and Methods
### Discrete Wavelet Transform  
DWT stands for denoising [49], which is a mathematical technique used for analyzing signals that can be applied to images [50]. It is a way of decomposing an image into a set of frequency components, with each component representing a different level of detail or resolution [51]. In image manipulation detection, DWT is often used for feature selection as it allows for efficient compression of image data while preserving important image features. The DWT algorithm works by dividing an image into four smaller blocks or \"sub-bands\" of different frequencies: The LL (low-low) sub-band, which contains the low-frequency information, and the LH (low-high), HL (high-low), and HH (high-high) sub-bands, which contain the high-frequency information [52]. The equations to perform DWT can be found in Equations (1) and (2) and the equation to reverse the process known as inverse DWT is presented in Equation (3). \[W_{\varphi}(j_{0},k)=\frac{1}{\sqrt{M}}\sum_{M}f(x)\varphi_{j_{0},k}(x) \tag{1}\]  
Figure 2: Example of ELA. (**Left**), image with power button manipulated. (**Right**) Resulting image after ELA, usually mostly black, except for the two manipulated areas that have differences in compression. \[W_{\psi}(j,k)=\frac{1}{\sqrt{M}}\sum_{k}f(x)\psi_{j,k}(x) \tag{2}\]  
\[ \begin{split} f(x)=&\frac{1}{\sqrt{M}}\sum_{k}W_{ \varphi}(j_{0},k)\varphi_{j_{0},k}(x)\\ &+\frac{1}{\sqrt{M}}\sum_{i=i_{0}}^{\infty}\sum_{k}W_{\psi}(j,k) \psi_{j,k}(x).\end{split}  \tag{3}\]  
This work uses the technique proposed by [18], referred to in the rest of this work as DWT method for abbreviation purposes, which makes use of DWT, Bilateral Filters, and the Laplace operator to remove less meaningful features of an image, resulting in an image only with features containing sharp pixel variation, which is a common indicator of forgery. This technique works by initially the image is converted to grayscale, then DWT is applied to decompose the image information into sub-bands, then the image is reconstructed after discarding the LL band and a bilateral filter, and the Laplace operator is applied, the result is an image where sharp pixel transitions are more easily visible, however when filters are used to mask the manipulation this method fails to highlight the manipulated areas. This work incorporates the image resulting from this method as one of the streams in a Convolutional Neural Network, utilizing it for feature selection to enhance the model's ability to detect large pixel transitions. An example of the result of this process can be seen in Figure 3 that was taken from the RTD and the code used to generate the images is presented in Listing 2. ``` FUNCTIONmethod_2_dwt(image) # Convertimagetograyscaleandperformdiscretewavelettransformgray_image=convertToGrayscale(image) coeffs=discreteWaveletTransform(gray_image) (LL,(LH,HL,HH))=coeffs
#Reconstructthemimagensindylthehigh-frequencycomponentshigh_freq_components=(None,(LH,HL,HH)) joinedLhH1 HH=inverseDiscreteWaveletTransform(high_freq_components)
#Applybilateralfiltertosmooththeimagewhilpreservingedges blurred=bilateralFilter(joinedLhH1 HH,9,75,75)
#ApplyLaplacianedgedetectiontoshighlightedges kernel_size=3 imgLapacianEdgeDetection(blurred,kernel_size)
#Convertnegativevaluestozero final_image=convertScaleToAbs(imgLapacian) RETURNfinal_image ENDFUNCTION

### Proposed Method

The proposed approach first consists of applying the ELA method and the method proposed by [18], both used as a feature selection step to generate two extra sets of images serving as the distinct streams for the subsequent model architecture. Subsequently, the original dataset and the two new sets of images are shuffled and utilized for training and evaluation of three distinct CNNs. Following training, the three models are frozen to preserve the acquired knowledge and then merged. Additional learning layers are appended, and the combined model is fine-tuned through training. These steps are visually represented in Figure 4, providing an overview of the system architecture.