# Object/Scene Recognition Based on a Directional Pixel Voting Descriptor
## 3 The Proposed Algorithm
### Image Preprocessing  
Given a gray scale image \(I(i,j)\), a Gaussian filtering is applied on \(I\) image on order to reduce noise and to remove fine-scale structures that affect the performance of the feature extraction step. The Gaussian filter is defined by Equation (1) as follows:  
\[G(m,n)=\frac{1}{2\pi\sigma^{2}}e^{-\frac{n^{2}+\sigma^{2}}{2\sigma^{2}}} \tag{1}\]  
Figure 3: Block diagram of the proposed algorithm.  
where \(G(m,n)\) is the Gaussian function and \(\sigma\) is the standard deviation, which controls the amount of smoothing applied to the image.  
To perform Gaussian filtering on the image \(I\), a convolution operation is applied between the image \(I\) and a Gaussian kernel \(G\). The Gaussian kernel is usually represented as a odd size 2D matrix or mask. For a generic \(5\times 5\) (\(N\times N\)) Gaussian mask, it can be represented as:  
\[\frac{1}{273}\left(\begin{array}{ccccc}1&4&7&4&1\\ 4&16&26&16&4\\ 7&26&41&26&7\\ 4&16&26&16&4\\ 1&4&7&4&1\end{array}\right)\]  
The above matrix represents the coefficients of the Gaussian mask, which are computed based on the Gaussian function with an appropriate standard deviation. This mask is then applied to the image using convolution, resulting in a smoothed version of the original image.  
\[I_{s}(i,j)=\sum_{m=-\frac{N-1}{2}}^{\frac{N-1}{2}}\sum_{n=-\frac{N-1}{2}}^{ \frac{N-1}{2}}I(i+m,j+n)\cdot G(m+\frac{N-1}{2},n+\frac{N-1}{2})\]  
Given the smoothed image \(I_{s}(i,j)\), the gradients \(g_{x}\) and \(g_{y}\) are calculated via Prewitt operator [33] as follows:  
\[g_{x}(i,j) =(-I_{s}(i-1,j-1)-I_{s}(i,j-1)-I_{s}(i+1,j-1)+I_{s}(i-1,j+1)+I_{s} (i,j+1)+I_{s}(i+1,j+1))\] \[g_{y}(i,j) =(-I_{s}(i-1,j-1)-I_{s}(i-1,j)-I_{s}(i-1,j+1)+I_{s}(i+1,j-1)+I_{s} (i+1,j)+I_{s}(i+1,j+1))\]  
Finally, the direction \(d(i,j)\) is determined as follows:  
\[d(i,j)=\left\{\begin{array}{ll}1&\text{if }(g_{x}(i,j)>g_{y}(i,j))\text{ \& }(g_{x}(i,j)+g_{y}(i,j))\geq\text{th}\\ 2&\text{if }(g_{x}(i,j)\leq g_{y}(i,j))\text{ \& }(g_{x}(i,j)+g_{y}(i,j))\geq\text{th}\\ 0&\text{otherwise}\end{array}\right. \tag{2}\]  
where th is a threshold for a \"valid\" gradient value. We define the possible values of th inspired by the image bit-depth standard format, i.e., 8, 16, 32, 64, and so on. We propose th = 32 as a threshold because, even after the smoothing process using the Gaussian filter, certain levels of noise and fine details may persist in the image. These artifacts can negatively affect the performance of subsequent steps, such as feature extraction or object recognition. By setting a threshold equal to 32, we aim to identify and suppress gradients that are not significant enough to represent relevant features in the image. Gradient values below this threshold may be considered as unwanted noise or fine details that we aim to eliminate. Note that the threshold value th does not explicitly depend on the bit depth of the image. However, given that the gradients \(g_{x}\) and \(g_{x}\) are computed from the absolute values of the image, which inherently depend on its bit depth, it is reasonable to argue that the sum \(g_{xy}\) should be compared to a threshold th that scales with the maximum gray level of the image. Specifically, a fixed threshold value of 32 might be appropriate for images with 8-bit depth (gray values ranging from 0 to 255), but could be inadequate for images with higher bit depths, such as 16-bit images with gray values ranging from 0 to 65,535.