Add comprehensive explanation and demo for SRCNN image cropping (modcrop function)
This PR addresses the common question: "Why do we need to crop images before inputting them to SRCNN?" by providing a comprehensive explanation and interactive demonstration.
Problem
Users were confused about the modcrop function's purpose and necessity. The original issue mentioned an image going from (176, 197, 3) to (174, 194, 3) and questioned why this cropping step was required.
Solution
Added detailed documentation and an interactive demo script that explains:
1. Quick Start Guide
A new section at the top of README.md directly addresses the cropping question with:
- Simple explanation of why cropping is necessary
- Mathematical example correcting the user's calculation: (176, 197, 3) → (174, 195, 3) (not 194)
- Reference to interactive demo and detailed FAQ
2. Enhanced modcrop Documentation
The modcrop function now includes comprehensive docstrings and explanations covering:
- Network Architecture Constraints: SRCNN uses 9×9 and 5×5 conv layers with 'valid' padding
- Scale Factor Alignment: Dimensions must be divisible by scale factor (3) to prevent artifacts
- Training Consistency: Maintains compatibility with model's training methodology
- Minimal Impact: Typically <2% pixel loss for significant quality improvement
3. Interactive Demo Script
New modcrop_demo.py provides hands-on learning with:
- Mathematical analysis of different image sizes and scale factors
- SRCNN architecture constraint visualization
- Pixel loss calculations showing minimal impact
- Practical examples users can run locally
4. Comprehensive FAQ
Added detailed FAQ section explaining:
- Technical reasons for cropping requirement
- SRCNN architecture details and padding effects
- Alternative approaches and their trade-offs
- Impact assessment on image quality
Key Technical Insights
- Architecture: SRCNN reduces dimensions by 12 pixels total (8 + 4 from valid padding)
- Math Correction: User's example should yield (174, 195, 3), not (174, 194, 3)
- Efficiency: Cropping 2-3 pixels per dimension is negligible compared to super-resolution benefits
- Necessity: Required for proper network operation, not arbitrary preprocessing
Usage
Users can now run python modcrop_demo.py to see interactive demonstrations and understand the cropping process through practical examples.
Fixes #1.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
@xoraus 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.
I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.