# HSB-SPAM: An Efficient Image Filtering Detection Technique
## 3 The Proposed Method
### Pixel Difference Arrays and Markov Chain  
The first order pixel difference array and Markov chain has been used in literature to extract the feature set. The extracted set of features has been used to train the classifier that would be used for classification of images finally. The first order pixel difference array contains from range \(-255\) to \(255\) in the case of 8-bit image. The first order pixel difference array in the vertical direction can be represented as follows for an image \(I\):  
\[\
abla\!\downarrow_{p,q}=I_{p,q}-I_{p,q+1} \tag{1}\]  
Similarly, first order pixel difference arrays in horizontal, main diagonal, and minor diagonal directions can be calculated as per the Figure 5a. Figure 4: The 8-bit and 4-bit depth image statistical analysis. Based on the aforementioned discussion in the Section 2, it is found that the incorporation of second and higher order pixel difference arrays has resulted in better accuracy as additional information is extracted by the incorporation of second and higher order pixel difference arrays. However, there are some shortcomings of higher order pixel difference arrays that are discussed in forthcoming contents. The second order pixel difference array contains from range \(-510\) to \(510\) in the case of 8-bit image. The thresholding loose more information in the second order pixel difference array in comparison to the first order pixel difference array because the range of elements is higher than the first order. Therefore, separated pixel difference array, which provides additional information, and with intact range of elements, \(-255\) to \(255\), are being used instead of the second order pixel difference array. For an image \(I\), the separated pixel difference array in vertical direction can be represented as follows:  
\[\
abla\downarrow^{8}_{pq}=I_{pq}-I_{p+2,q} \tag{2}\]  
Likewise, the separated pixel difference arrays in horizontal, main diagonal, and minor diagonal directions can be calculated as shown in the Figure 5b. In addition to the first order and separated pixel difference arrays, Laplacian operator can also provide more suitable statistical information as it highlights abrupt changes clearly and provides the combined statistical information of horizontal and vertical neighbors. So, the proposed detector makes use of negative Laplacian operator to get the Laplacian difference array. The Laplacian operator can be defined as shown in Figure 5c:  
\[\
abla^{L}_{pq}=4\times I_{p,q}-(I_{p+1,q}+I_{p-1,q}+I_{p,q+1}+I_{p,q-1}) \tag{3}\]  
The image and its corresponding difference arrays--the first order, the second order in the vertical direction, the separated pixel and Laplacian--are all shown in Figure 6. It is evident that each difference array provides the constructive statistical information of the image. Therefore, the features are extracted from the first order pixel difference arrays, separated pixel difference arrays in vertical, horizontal, diagonal, minor diagonal directions and Laplacian difference arrays in the low bit image, which helps in achieving better performance. Figure 6: Image and their corresponding difference arrays: (**a**) color image; (**b**) grayscale image; (**c**) first order difference array; (**d**) second order difference array; (**e**) separated pixel difference array; (**f**) Laplacian difference array. Next, the second order Markov chain is extracted to identify the co-occurrences of difference pixel arrays. Before understanding the second order Markov chain, we have to understand the first order Markov chain firstly. The first order Markov chain for the thresholded vertical first order pixel difference array \((\
abla\downarrow)\) can be defined as follows:  
\[\chi_{\alpha,\beta}=Pr(\
abla\downarrow_{p,q+1}=\alpha\ \ |\ \
abla\downarrow_{p,q}=\beta) \tag{4}\]  
where \(\chi_{\alpha,\beta}=0\) for \(Pr\big{(}\
abla\downarrow_{p,q}=\beta\big{)}=0\).