PixelProof is a lightweight classical computer vision system that distinguishes between a real-world photograph and a photograph of a screen.
Unlike deep learning approaches, this project relies entirely on handcrafted image-processing features and traditional machine learning, making it lightweight, interpretable, and suitable for CPU-only inference.
Streamlit web demo - https://pixelproof.streamlit.app/
Demo Video - https://drive.google.com/file/d/1_JT8Q0YUC8PODpAyZb7TEHQy9_eQYZAy/view?usp=drive_link
The system extracts a variety of handcrafted image features including:
- Laplacian Variance (blur/sharpness)
- Edge Density
- Local Binary Patterns (LBP)
- Gray Level Co-occurrence Matrix (GLCM)
- FFT Peak Analysis
- RGB Color Statistics
- HSV Color Statistics
- Brightness
- Contrast
- Shannon Entropy
- Glare Percentage
- Pixel Grid Score
- Hough Line Features
These features are used to train classical machine learning classifiers.
The following models were compared using 5-fold Stratified Cross Validation:
- Random Forest
- Support Vector Machine (SVM)
- XGBoost
The model with the highest validation accuracy is automatically selected and saved.
dataset/
│
├── real/
│ ├── image1.jpg
│ ├── image2.jpg
│ └── ...
│
└── screen/
├── image1.jpg
├── image2.jpg
└── ...
PixelProof/
│
├── dataset/
│ ├── real/
│ └── screen/
│
├── models/
│ └── best_model.pkl
│
├── src/
│ ├── feature_extraction.py
│ ├── train.py
│ ├── predict.py
│ ├── error_analysis.py
│ └── features.csv
│
├── requirements.txt
└── README.md
Clone the repository
git clone <repository-url>
cd PixelProofInstall dependencies
pip install -r requirements.txtRun
cd src
python feature_extraction.pyThis extracts handcrafted features from every image and creates
features.csv
Run
python train.pyThe script
- Performs 5-fold Stratified Cross Validation
- Compares Random Forest, SVM and XGBoost
- Reports Accuracy, Precision, Recall, F1-score and ROC-AUC
- Saves the best model as
models/best_model.pkl
To inspect misclassified images, run
python error_analysis.pyThis generates:
- Confusion Matrix
- Classification Report
- List of misclassified images
Run
python predict.py path/to/image.jpgExample
python predict.py dataset/real/sample.jpgOutput
Score : 0.0021
or
Score : 0.9984
The score represents the probability that the input image is a photograph of a screen.
- Score close to 0 → Real Photo
- Score close to 1 → Screen Photo
Using 5-fold Stratified Cross Validation:
| Metric | Score |
|---|---|
| Accuracy | ~96% |
| Precision | ~96% |
| Recall | ~96% |
| F1 Score | ~96% |
| ROC-AUC | ~0.99 |
Measured on a Windows laptop CPU.
| Stage | Average Time |
|---|---|
| Feature Extraction | ~250–300 ms |
| Prediction | ~60–90 ms |
| Total | ~320–390 ms |
- Python
- OpenCV
- NumPy
- Pandas
- Scikit-learn
- XGBoost
- scikit-image
- Pillow
Possible improvements include:
- Faster FFT implementation
- Parallel feature extraction
- Additional frequency-domain descriptors
- Mobile deployment
- Hybrid classical + deep learning approach
- Larger and more diverse training dataset
This project was developed as part of an image classification assignment for educational purposes.