Skip to content

RodinaAhmed2/python-image-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MNIST Digit Classification with CNN

1. Dataset Description

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

2. Applied Filter: Thresholding

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.

3. CNN Architecture

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

4. Results

  • Training Accuracy: ~99.8%
  • Validation Accuracy: ~98.86%
image

5. Visualizations

Model Performance

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

image image

Sample Digit Grid

A grid of 25 sample images from MNIST, showing handwritten digits (0–9) with their labels to visualize and verify dataset correctness.

image image

Thresholding Example

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.

image

6. Conclusion

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.

7. Project Files

  • 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.

8. How to Run

  1. Ensure Python is installed.
  2. Install the required libraries: pip install matplotlib numpy pillow
  3. Run any of the scripts as needed: python img.py

🧑‍💻 Author

About

Image thresholding was used to simplify input data and boost CNN accuracy for digit classification.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages