Spaces:
Runtime error
Runtime error
A newer version of the Streamlit SDK is available: 1.62.0
π¨ 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
RGB (Red, Green, Blue)
- Interactive color mixer with sliders
- Channel separation and visualization
- Grayscale intensity views
- Additive color model demonstration
HSV/HSI (Hue, Saturation, Value/Intensity)
- Cylindrical color picker
- Hue circle visualization
- Real-time image manipulation (hue shift, saturation, value)
- Channel separation
CIE-LAB (Perceptual Colorspace)
- Lab* controls
- Perceptually uniform color differences (ΞE)
- Opponent color channels
- Device-independent representation
CMYK (Cyan, Magenta, Yellow, Key/Black)
- Subtractive color model mixer
- RGB to CMYK conversion
- Print separation plates visualization
- Comparison with additive model
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
Gamma Correction
- Interactive gamma slider (0.1 - 3.0)
- Visual gamma curve plotting
- Before/after comparison
- Histogram analysis
White Balance
- Temperature presets (Daylight, Incandescent, Fluorescent, Shade)
- Manual RGB channel adjustment
- Gray World automatic white balance
- RGB histogram visualization
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
# Quick start
make setup # Install everything
make run # Start the app
# Other commands
make test # Run basic tests
make clean # Clean up environment
Deployment
# Deploy to HuggingFace Spaces
make deploy
# Check deployment status
make status
Key Algorithms Implemented
- RGB β HSV Conversion: Using colorsys and OpenCV
- RGB β LAB Conversion: Using OpenCV color space conversion
- RGB β CMYK Conversion: K = 1 - max(R,G,B), CMY = (1 - RGB - K)/(1 - K)
- RGB β YCbCr Conversion: Using OpenCV
- Chroma Subsampling: 2x downsampling with nearest-neighbor upsampling
- Gamma Correction: Output = Input^Ξ³
- White Balance: Per-channel scaling with Gray World algorithm
- 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
- RGB Tab: Use images with distinct colors (shapes.jpg, circles.jpg)
- HSV Tab: Try hue shifting on colorful images
- LAB Tab: Test perceptual uniformity on gradients
- CMYK Tab: Use photos to see print separations
- YCbCr Tab: Compare subsampling on detailed images
- Gamma Tab: Use cameraman.png or lena.png
- White Balance Tab: Test on images with color casts
- 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
- Main application (app.py)
- Requirements file
- Makefile with all commands
- Deployment scripts (deploy.sh, check_status.sh)
- Documentation (README.md, QUICKSTART.md)
- HuggingFace metadata (README_HF.md)
- System dependencies (packages.txt)
- Python version specification (.python-version)
- .gitignore file
- 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