We used the MNIST dataset, which contains 70,000 grayscale images of handwritten digits (0-9), each of size 28x28 pixels.
| Class | Number of Samples | 
|---|---|
| 0–9 | ~6000-7000 images per class | 
We applied a Thresholding filter at value 100 to convert grayscale images to binary (black/white).
Purpose:
- Highlight digit structure
- Simplify image features for easier classification by the CNN model.
| Layer | Type | Parameters | 
|---|---|---|
| 1 | Conv2D (32 filters, 3x3) | Input: (28, 28, 1) | 
| 2 | MaxPooling2D (2x2) | |
| 3 | Conv2D (64 filters, 3x3) | |
| 4 | MaxPooling2D (2x2) | |
| 5 | Flatten | |
| 6 | Dense (128 neurons, ReLU) | |
| 7 | Dense (10 neurons, Softmax) | 
- Optimizer: Adam
- Loss Function: Sparse Categorical Cross-Entropy
- Epochs: 10
- Batch Size: 32
- Training Accuracy: ~99.8%
- Validation Accuracy: ~98.86%
 
Training and validation accuracy and loss curves across 10 epochs. The model shows rapid convergence with minimal overfitting, achieving high accuracy (~99.7% training and ~98.9% validation), indicating successful learning
 
 
A grid of 25 sample images from MNIST, showing handwritten digits (0–9) with their labels to visualize and verify dataset correctness.
 
 
The original and thresholded versions of a handwritten digit "3". Thresholding filter was applied to enhance the contrast and simplify the image, converting it into a binary format (black and white) for better feature extraction.
 
Applying the Thresholding filter successfully simplified the input images while preserving essential classification features.
As a result, the CNN model achieved high accuracy, demonstrating the effectiveness of preprocessing (thresholding) in digit classification tasks.
- img.py: Load and display images.
- minst.py: Example for handling and classifying digit datasets.
- save_images.py: Save processed images to disk.
- python.image1.pdf: Sample exported PDF for results.
- Ensure Python is installed.
- Install the required libraries: pip install matplotlib numpy pillow
- Run any of the scripts as needed: python img.py
- Rodina Ahmed → GitHub Profile
- Farida Ayman → GitHub Profile
- Nada Attia → GitHub Profile