Spaces:
Runtime error
Runtime error
| # 🎨 Colorspace Explorer - Project Summary | |
| ## Overview | |
| A comprehensive interactive Streamlit application for exploring colorspaces, built for educational purposes in graduate-level image analysis courses. | |
| ## Project Structure | |
| ``` | |
| colorspaces/ | |
| ├── app.py # Main Streamlit application (950+ lines) | |
| ├── requirements.txt # Python dependencies | |
| ├── Makefile # Build and deployment automation | |
| ├── deploy.sh # HuggingFace Spaces deployment script | |
| ├── check_status.sh # Deployment status checker | |
| ├── .python-version # Python version specification | |
| ├── packages.txt # System-level dependencies | |
| ├── README.md # Comprehensive documentation | |
| ├── README_HF.md # HuggingFace Spaces metadata | |
| ├── QUICKSTART.md # Quick start guide | |
| ├── LICENSE # MIT License | |
| └── images/ # Sample images and test patterns | |
| ├── 1-light.png # Colorblind test plates | |
| ├── 3-dark.png | |
| ├── cameraman.png # Standard test images | |
| ├── lena.png | |
| ├── shapes.jpg | |
| └── ... | |
| ``` | |
| ## Features Implemented | |
| ### ✅ Colorspaces Covered | |
| 1. **RGB (Red, Green, Blue)** | |
| - Interactive color mixer with sliders | |
| - Channel separation and visualization | |
| - Grayscale intensity views | |
| - Additive color model demonstration | |
| 2. **HSV/HSI (Hue, Saturation, Value/Intensity)** | |
| - Cylindrical color picker | |
| - Hue circle visualization | |
| - Real-time image manipulation (hue shift, saturation, value) | |
| - Channel separation | |
| 3. **CIE-LAB (Perceptual Colorspace)** | |
| - L*a*b* controls | |
| - Perceptually uniform color differences (ΔE) | |
| - Opponent color channels | |
| - Device-independent representation | |
| 4. **CMYK (Cyan, Magenta, Yellow, Key/Black)** | |
| - Subtractive color model mixer | |
| - RGB to CMYK conversion | |
| - Print separation plates visualization | |
| - Comparison with additive model | |
| 5. **YCbCr (Compression-oriented)** | |
| - Luminance-chrominance separation | |
| - Chroma subsampling demonstration (4:4:4, 4:2:2, 4:2:0) | |
| - Interactive compression ratio visualization | |
| - JPEG/video compression explanation | |
| 6. **Gamma Correction** | |
| - Interactive gamma slider (0.1 - 3.0) | |
| - Visual gamma curve plotting | |
| - Before/after comparison | |
| - Histogram analysis | |
| 7. **White Balance** | |
| - Temperature presets (Daylight, Incandescent, Fluorescent, Shade) | |
| - Manual RGB channel adjustment | |
| - Gray World automatic white balance | |
| - RGB histogram visualization | |
| 8. **Color Blindness Simulation** | |
| - Protanopia (no red cones) | |
| - Deuteranopia (no green cones) | |
| - Tritanopia (no blue cones) | |
| - Monochromacy (grayscale) | |
| - Difference heatmaps | |
| - Accessibility guidelines | |
| - Support for Ishihara test plates | |
| ### 🎓 Educational Features | |
| - **Interactive Controls**: Sliders, radio buttons, and file uploaders | |
| - **Visual Comparisons**: Side-by-side before/after displays | |
| - **Real-time Updates**: Instant feedback on parameter changes | |
| - **Educational Content**: Explanations, formulas, and key insights | |
| - **Practical Applications**: Real-world use cases for each colorspace | |
| - **Sample Images**: Diverse test images including colorblind tests | |
| ### 🛠️ Technical Features | |
| - **Efficient Image Processing**: Using OpenCV and NumPy | |
| - **Matplotlib Integration**: For curves and histograms | |
| - **Responsive Layout**: Wide layout with columns for optimal viewing | |
| - **Image Upload Support**: Users can test with their own images | |
| - **Automatic Resizing**: Handles large images gracefully | |
| - **Caching**: @st.cache_resource for performance | |
| ## Dependencies | |
| - **streamlit** (1.39.0): Web application framework | |
| - **numpy** (1.26.4): Numerical computations | |
| - **opencv-python** (4.10.0.84): Image processing | |
| - **pillow** (10.4.0): Image I/O | |
| - **matplotlib** (3.9.2): Plotting and visualization | |
| ## Usage | |
| ### Local Development | |
| ```bash | |
| # Quick start | |
| make setup # Install everything | |
| make run # Start the app | |
| # Other commands | |
| make test # Run basic tests | |
| make clean # Clean up environment | |
| ``` | |
| ### Deployment | |
| ```bash | |
| # Deploy to HuggingFace Spaces | |
| make deploy | |
| # Check deployment status | |
| make status | |
| ``` | |
| ## Key Algorithms Implemented | |
| 1. **RGB ↔ HSV Conversion**: Using colorsys and OpenCV | |
| 2. **RGB ↔ LAB Conversion**: Using OpenCV color space conversion | |
| 3. **RGB → CMYK Conversion**: K = 1 - max(R,G,B), CMY = (1 - RGB - K)/(1 - K) | |
| 4. **RGB ↔ YCbCr Conversion**: Using OpenCV | |
| 5. **Chroma Subsampling**: 2x downsampling with nearest-neighbor upsampling | |
| 6. **Gamma Correction**: Output = Input^γ | |
| 7. **White Balance**: Per-channel scaling with Gray World algorithm | |
| 8. **Color Blindness Simulation**: Using transformation matrices from Brettel et al. | |
| ## Educational Alignment | |
| This tool complements theoretical lectures on: | |
| - Color representation in digital images | |
| - Perceptual color spaces | |
| - Color transformations | |
| - Image compression techniques | |
| - Display calibration and correction | |
| - Accessibility and inclusive design | |
| ## Testing Recommendations | |
| 1. **RGB Tab**: Use images with distinct colors (shapes.jpg, circles.jpg) | |
| 2. **HSV Tab**: Try hue shifting on colorful images | |
| 3. **LAB Tab**: Test perceptual uniformity on gradients | |
| 4. **CMYK Tab**: Use photos to see print separations | |
| 5. **YCbCr Tab**: Compare subsampling on detailed images | |
| 6. **Gamma Tab**: Use cameraman.png or lena.png | |
| 7. **White Balance Tab**: Test on images with color casts | |
| 8. **Color Blindness Tab**: Use numbered test plates (1-light.png, etc.) | |
| ## Future Enhancements (Optional) | |
| - [ ] Add more colorspaces (XYZ, LUV, LCH) | |
| - [ ] Include color palette generation | |
| - [ ] Add color harmony tools (complementary, triadic, etc.) | |
| - [ ] Implement histogram equalization | |
| - [ ] Add color quantization (K-means) | |
| - [ ] Include color transfer between images | |
| - [ ] Add batch processing capabilities | |
| - [ ] Export processed images | |
| - [ ] Save/load parameter presets | |
| ## Performance Considerations | |
| - Images automatically resized to max 400-600px for interactive tabs | |
| - Caching used for image loading | |
| - Efficient NumPy operations for color transformations | |
| - Matplotlib figures properly closed to prevent memory leaks | |
| ## Deployment Checklist | |
| - [x] Main application (app.py) | |
| - [x] Requirements file | |
| - [x] Makefile with all commands | |
| - [x] Deployment scripts (deploy.sh, check_status.sh) | |
| - [x] Documentation (README.md, QUICKSTART.md) | |
| - [x] HuggingFace metadata (README_HF.md) | |
| - [x] System dependencies (packages.txt) | |
| - [x] Python version specification (.python-version) | |
| - [x] .gitignore file | |
| - [x] Sample images in images/ folder | |
| ## Credits | |
| - Based on the sampling-quantization demo structure | |
| - Color blindness simulation algorithms from Brettel, Viénot, and Mollon | |
| - Educational content aligned with University of Bern image analysis curriculum | |
| ## License | |
| MIT License - Free for educational and research use | |
| --- | |
| **Status**: ✅ Complete and ready for deployment | |
| **Total Lines of Code**: ~950+ lines in app.py | |
| **Total Files**: 13 configuration/documentation files + sample images | |
| **Estimated Build Time**: 2-3 minutes on HuggingFace Spaces | |