Abstract
We propose a simple kernel-based nearest neighbor approach for handwritten digit classification. The "distance" used is a kernel defining the similarity between two images based on the Complex Wavelet Structural Similarity (CW-SSIM) index. We study the effects of different neighbor counts and weighting schemes. With only a few nearest neighbors to vote, the test set error rate on the MNIST database reaches approximately 1.5%–2.0%, which is competitive with many advanced models.
Introduction
Handwritten digit classification is a fundamental challenge in computer vision due to high dimensionality and significant geometric variability. Traditional approaches often rely on complex feature extraction or dimensionality reduction techniques like PCA to handle these variations. Standard similarity measures, such as Mean Squared Error (MSE), are pixel-wise and highly sensitive to minor translations or rotations. This paper proposes a simple K-Nearest Neighbor (K-NN) classifier that utilizes the CW-SSIM index as a perceptual similarity metric, effectively bypassing the need for heavy preprocessing.
Methodology
CW-SSIM Metric
The core of this approach is the CW-SSIM index, which operates in the complex wavelet domain. Unlike spatial-domain metrics, CW-SSIM is robust to small geometric distortions because such changes manifest as consistent phase shifts in wavelet coefficients. By focusing on structural information rather than raw pixel intensities, the metric aligns more closely with human visual perception.
K-Nearest Neighbor Classification
Classification is performed using a K-NN algorithm. For a given test image, the system identifies the $k$ most similar training samples based on their CW-SSIM scores. The final classification is determined by a vote among these neighbors. The authors explored several weighting schemes to optimize performance:
- Unweighted: Each neighbor contributes an equal vote.
- Weighted: Votes are weighted by the CW-SSIM similarity score.
- Decaying Functions: Exponential and Gaussian decaying functions were used to weight neighbors based on their rank, providing a smoother transition and reducing sensitivity to the choice of $k$.
Datasets
The method was evaluated on two primary datasets:
- Simulated Dataset: 2,000 images generated from ten template digits with random shifts, scales, rotations, and blurs.
- MNIST Database: A standard benchmark containing 60,000 training and 10,000 test images of digits 0–9.
Results and Discussion
Performance on Simulated Data
The CW-SSIM metric demonstrated exceptional robustness on the simulated dataset. As shown in the performance analysis, the classifier achieved a 0% error rate for $k \le 20$ neighbors. This confirms the metric's inherent immunity to the types of geometric distortions introduced in the simulation.
MNIST Results
On the full MNIST dataset, the simple K-NN approach remained highly competitive:
- With $k=1$, the error rate was 2.18%.
- Implementing a weighted voting scheme further reduced the error to 1.73%.
- The best performance, a 1.62% error rate, was achieved using a Gaussian decaying weighting function.
These results are comparable to more complex state-of-the-art models, highlighting the effectiveness of a strong similarity metric combined with a large training set.
Conclusion
This research demonstrates that a simple classification architecture can achieve high accuracy if paired with a perceptually relevant similarity metric. By prioritizing structural information over pixel-level comparisons, the CW-SSIM based K-NN method handles geometric variability naturally. Future work could focus on optimizing the computational efficiency of the similarity search and refining the training set to remove ambiguous samples.
Summary updated