## 2 Materials and Methods
### Sift  
The SIFT algorithm excels in its ability to generate, for each identified keypoint, a descriptor vector that synthesizes the information contained in the adjacent pixels [27]. Although SIFT was initially developed for grayscale images, it has been demonstrated that the feature vector, composed of 128 elements, provides a comprehensive overview of the intensity level configurations in the immediate surroundings of the keypoints. This approach ensures a rich and detailed representation of cellular texture and shape, facilitating subsequent analysis and interpretation in specific biomedical contexts, as discussed in [28]. This methodology not only enhances the accuracy of the cell identification and classification process but also significantly contributes to the robustness and reliability of advanced cytological studies.  
The SIFT (Scale-Invariant Feature Transform) algorithm is used to robustly and efficiently detect and describe local features in images. Below are the key mathematical formulas that underpin each step of the algorithm.  
To achieve scale invariance, SIFT generates a set of smoothed images by applying Gaussian convolutions to the original image. The smoothed image \(L(x,y,\sigma)\) is defined as follows:  
\[L(x,y,\sigma)=G(x,y,\sigma)*I(x,y) \tag{1}\]  
Figure 5: Cells from a low-grade lesion cytology captured at various focal distances and different levels of zoom, using slides provided by SPHLM.  
where \(G(x,y,\sigma)\) is a Gaussian kernel and \(I(x,y)\) is the input image. The Gaussian kernel is given by  
\[G(x,y,\sigma)=\frac{1}{2\pi\sigma^{2}}e^{-\frac{x^{2}+y^{2}}{2x^{2}}} \tag{2}\]  
The Difference of Gaussians (DoG), used to detect keypoints, is calculated by subtracting two smoothed images with different standard deviations as follows:  
\[D(x,y,\sigma)=L(x,y,k\sigma)-L(x,y,\sigma) \tag{3}\]  
Keypoints are identified as local maxima and minima in the DoG scale space. Each candidate keypoint is verified by interpolating the location using a Taylor series expansion of the DoG scale space around the keypoint as follows:  
\[D(x)=D+\frac{\partial D}{\partial x}x+\frac{1}{2}x^{T}\frac{\partial^{2}D}{ \partial x^{2}}x \tag{4}\]  
where \(x=(x,y,\sigma)^{T}\). The keypoint displacement is found by solving  
\[\hat{x}=-\frac{\partial^{2}D^{-1}}{\partial x^{2}}\frac{\partial D}{\partial x} \tag{5}\]  
For each keypoint, the gradient \(m(x,y)\) and orientation \(\theta(x,y)\) are calculated in a region around the keypoint as follows:  
\[m(x,y)=\sqrt{(L(x+1,y)-L(x-1,y))^{2}+(L(x,y+1)-L(x,y-1))^{2}} \tag{6}\]  
\[\theta(x,y)=\tan^{-1}\biggl{(}\frac{L(x,y+1)-L(x,y-1)}{L(x+1,y)-L(x-1,y)} \biggr{)} \tag{7}\]  
The gradient orientations are accumulated into a histogram weighted by the gradient magnitude and a Gaussian window centered at the keypoint.  
A keypoint descriptor is constructed by dividing the region around the keypoint into a 4 \(\times\) 4 grid and computing an 8-bin orientation histogram for each grid cell. The resulting descriptor is the following 128-dimensional vector (4 \(\times\) 4 \(\times\) 8):  
\[\text{Descriptor}=[h_{1},h_{2},\dots,h_{128}] \tag{8}\]  
where each \(h_{i}\) represents the accumulation of gradient magnitudes in a specific direction within a grid cell. To ensure invariance to illumination changes, the descriptor for each keypoint is normalized by dividing by its \(L_{2}\) norm as follows:  
\[\text{Normalized descriptor}=\frac{\text{Descriptor}}{\|\text{Descriptor}\|} \tag{9}\]  
This process enhances the robustness of the descriptor against variations in image intensity.