# Analyzing Benford's Law's Powerful Applications in Image Forensics
## 4 Discussion  
Before moving further, it is important to restate that the developed algorithm finds the quality factor with which the image was compressed only once. The second quality factor is only applied by the algorithm in an incomplete second compression. Its only purpose is to obtain the JPEG coefficients (which is an intermediary step of JPEG compression). In light of the abovementioned observations, we make the following complete statement. Given an input image, compressed with a quality factor \(\text{QF}_{1}\in\{90,\,80,\,70,\,60,\,50\}\), to determine it, the following algorithm can be applied:  
1. Calculate the JPEG coefficients for each \(\text{QF}_{2}\in\{90,\,80,\,70,\,60,\,50\}\), denoted by \(\text{JPEG}_{i}\), \(i\in\{90,\,80,\,70,\,60,\,50\}\);
2. For all coefficients, in relationship with the GBL, perform the chi square test and determine the \(p\)-values, denoted by \(\text{p}_{i}\), \(i\in\{90,\,80,\,70,\,60,\,50\}\);
3. If all \(\text{p}_{i}\) satisfy the relationship \(\text{p}_{i}>0.6\), the initial quality factor is \(\text{QF}_{1}=90\);
4. Else, the largest \(\text{QF}_{2}\) for which \(\text{p}_{i}>0.6\) is the initial quality factor \(\text{QF}_{1}=\text{QF}_{2}\). In what follows, this property is exemplified on 100 images from the UCID, for each channel Y, R, G, and B, for \(\text{QF}_{1}\in\{90,\,80,\,70,\,60,\,50\}\). To represent graphically the outcome, the average \(p\)-values are calculated. Figures 14-17 show the results. The threshold \(p\)-value is represented as a dashed red line for each case. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Quality Factor for the Initial** & **Quality Factor for the Initial** & **Average \(p\)-Valuefor** \\
**Compression \(\text{QF}_{1}\)** & **Compression \(\text{QF}_{2}\)** & **100 Images** \\ \hline \multirow{4}{*}{Initially uncompressed} & 90 & 0.999242 \\  & 80 & 0.997895 \\  & 70 & 0.975055 \\  & 60 & 0.951813 \\  & 50 & 0.946787 \\ \hline \multirow{4}{*}{90} & 90 & 0.999219 \\  & 80 & 0.990972 \\ \cline{1-1}  & 70 & 0.978843 \\ \cline{1-1}  & 60 & 0.970747 \\ \cline{1-1}  & 50 & 0.947362 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Comparison between JPEG coefficients and the GBL, using Y channel. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Quality Factor for the Initial** & **Quality Factor for the Initial** & **Average \(p\)-Value for** \\
**Compression \(\text{QF}_{1}\)** & **Compression \(\text{QF}_{2}\)** & **100 Images** \\ \hline \multirow{4}{*}{60} & 90 & 0 \\  & 80 & 0 \\  & 70 & 0.052688 \\ \cline{1-1}  & 60 & 0.955229 \\ \cline{1-1}  & 50 & 0.917083 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Comparison between JPEG coefficients and the GBL, using Y channel. Figure 16: The JPEG coefficients compared to the GBL, using the G channel. Figure 14: The JPEG coefficients compared to the GBL, using the Y channel. Figure 15: The JPEG coefficients compared to the GBL, using the R channel. As it can be observed, the threshold \(p\)-value \(\mathrm{n}=0.6\) represented by the red dashed line seems to be an appropriate choice for the algorithm. However, in Table 6, the results are shown for different threshold values. Random images are taken from the UCID database. They are compressed with different quality factors \(\mathrm{QF}_{1}\in\{90,\ 80,\ 70,\ 60,\ 50\}\). Then, the abovementioned algorithm computes the quality factor \(\mathrm{QF}_{1}\), using the JPEG coefficients obtained from the luminance channel. Besides the overall algorithm accuracy, we have also included the accuracies with which each original quality factor was determined. Therefore, the threshold \(p\)-value is chosen to be \(\mathrm{n}=0.7\) since it conducts to the best results for our algorithm. Moreover, the accuracy of the algorithm decreases when detecting smaller quality factors. We believe that one of the reasons behind this is the parameters of the GBL. Tuning these parameters for our algorithm is a future goal. However, the original algorithm only makes use of one channel, the luminance.