colorspaces / PROJECT_SUMMARY.md
amithjkamath's picture
Update colorspace demo
719e71f
|
Raw
History Blame Contribute Delete
7.15 kB

A newer version of the Streamlit SDK is available: 1.62.0

Upgrade

🎨 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)

    • Lab* 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

# 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

  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

  • 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