Spaces:
Runtime error
A newer version of the Streamlit SDK is available: 1.62.0
title: Interactive Colorspace Exploration
emoji: π¨
colorFrom: purple
colorTo: pink
sdk: streamlit
sdk_version: 1.39.0
python_version: '3.9'
app_file: app.py
pinned: false
π¨ Interactive Colorspace Exploration
An educational Streamlit application for exploring different colorspaces and color models used in image processing and computer vision. Built for graduate-level image analysis courses.
π Features
This interactive demo covers the following topics:
π Colorspaces Covered
RGB (Red, Green, Blue)
- Additive color model
- Channel visualization and manipulation
- Primary and secondary colors
- Device-dependent representation
HSV/HSI (Hue, Saturation, Value/Intensity)
- Cylindrical color representation
- Perceptually intuitive controls
- Color, saturation, and brightness separation
- Interactive hue shifting and saturation adjustment
CIE-LAB
- Perceptually uniform colorspace
- Device-independent
- Color difference calculations (ΞE)
- Lightness and opponent color channels
CMYK (Cyan, Magenta, Yellow, Key/Black)
- Subtractive color model
- Printing and print separation
- Comparison with additive (RGB) model
- Understanding ink absorption
YCbCr (Luma, Blue-difference, Red-difference)
- Compression-oriented colorspace
- Chroma subsampling (4:4:4, 4:2:2, 4:2:0)
- JPEG and video compression applications
- Luminance-chrominance separation
Gamma Correction
- Non-linear display response compensation
- Gamma curves and their effects
- Histogram visualization
- Standard gamma values (sRGB, Rec. 709)
White Balance
- Color temperature correction
- Different lighting conditions (daylight, incandescent, fluorescent)
- Gray world assumption
- Manual and automatic white balance
Color Blindness Simulation
- Protanopia (no red cones)
- Deuteranopia (no green cones)
- Tritanopia (no blue cones)
- Monochromacy (no color vision)
- Accessibility guidelines
- Ishihara test images
π Quick Start
Local Installation
Clone the repository
git clone https://github.com/ubern-image-analysis/colorspaces.git cd colorspacesSet up the environment
make setupRun the application
make runOpen your browser
- The app will automatically open at
http://localhost:8501
- The app will automatically open at
Using Make Commands
make help # Show all available commands
make setup # Set up virtual environment and install dependencies
make run # Run the Streamlit app locally
make clean # Remove virtual environment and cache files
make test # Run basic tests
make deploy # Deploy to Hugging Face Spaces
make status # Check deployment status
π¦ Requirements
- Python 3.8 or higher
- See requirements.txt for package dependencies:
- streamlit
- numpy
- opencv-python
- pillow
- matplotlib
πΌοΈ Images
The demo includes various test images in the images/ folder:
- Ishihara colorblind test plates (numbered images)
- Standard test images (cameraman, Lena, etc.)
- Geometric shapes and patterns
- Natural scenes with people and objects
You can also upload your own images to explore different colorspaces!
π Educational Goals
This tool is designed to help students:
- Understand color representation in different colorspaces
- Visualize color transformations between spaces
- Explore perceptual properties of different models
- Learn compression techniques like chroma subsampling
- Practice color correction with gamma and white balance
- Design for accessibility using colorblind simulations
π Deployment to Hugging Face Spaces
Prerequisites
Create a Hugging Face account at huggingface.co
Create a new Space:
- Go to huggingface.co/spaces
- Click "Create new Space"
- Choose "Streamlit" as the SDK
- Name it (e.g.,
colorspaces)
Install Hugging Face CLI and login:
pip install huggingface-hub huggingface-cli login
Deploy
Initialize git (if not already done)
git init git add . git commit -m "Initial commit"Deploy to Hugging Face
make deployFollow the prompts and enter your Space name (e.g.,
username/colorspaces)Check status
make status
Your Space will be live at https://huggingface.co/spaces/YOUR_USERNAME/colorspaces!
π Usage Tips
For Students
- Start with the RGB tab to understand the basics
- Progress through HSV to see perceptual color representation
- Explore LAB for color difference calculations
- Compare RGB (additive) with CMYK (subtractive)
- Learn about compression with YCbCr
- Experiment with gamma correction and white balance
- Test your designs for colorblind accessibility
For Instructors
- Use this alongside lecture materials on color theory
- Demonstrate concepts interactively in class
- Assign exercises using different colorspaces
- Have students test their designs for accessibility
- Compare compression artifacts in YCbCr
π§ Development
Project Structure
colorspaces/
βββ app.py # Main Streamlit application
βββ requirements.txt # Python dependencies
βββ Makefile # Build and deployment commands
βββ deploy.sh # Deployment script for HuggingFace
βββ check_status.sh # Status checking script
βββ README.md # This file
βββ LICENSE # License file
βββ images/ # Sample images
βββ 1-light.png # Colorblind test images
βββ cameraman.png # Standard test images
βββ ...
Adding New Features
- Create a new tab function in
app.py - Add educational content with markdown
- Include interactive controls (sliders, buttons)
- Visualize results with side-by-side comparisons
- Add explanatory text and key insights
Testing Locally
# Run tests
make test
# Start the app
make run
# Clean up
make clean
π References
Color Science
- CIE 1931 color space: https://en.wikipedia.org/wiki/CIE_1931_color_space
- sRGB specification: https://en.wikipedia.org/wiki/SRGB
- Color difference (ΞE): https://en.wikipedia.org/wiki/Color_difference
Colorspaces
- RGB: https://en.wikipedia.org/wiki/RGB_color_model
- HSV: https://en.wikipedia.org/wiki/HSL_and_HSV
- LAB: https://en.wikipedia.org/wiki/CIELAB_color_space
- CMYK: https://en.wikipedia.org/wiki/CMYK_color_model
- YCbCr: https://en.wikipedia.org/wiki/YCbCr
Compression
- Chroma subsampling: https://en.wikipedia.org/wiki/Chroma_subsampling
- JPEG: https://en.wikipedia.org/wiki/JPEG
Accessibility
- Color blindness: https://en.wikipedia.org/wiki/Color_blindness
- Ishihara test: https://en.wikipedia.org/wiki/Ishihara_test
- Web accessibility: https://www.w3.org/WAI/WCAG21/Understanding/use-of-color.html
π€ Contributing
Contributions are welcome! Please feel free to:
- Report bugs
- Suggest new features
- Add more colorspaces or demonstrations
- Improve documentation
- Add more test images
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π₯ Authors
Created for graduate-level image analysis courses at the University of Bern.
π Acknowledgments
- Based on the sampling-quantization demo
- Colorblind simulation algorithms from Brettel, ViΓ©not, and Mollon
- Test images from standard image processing datasets
π§ Contact
For questions or feedback, please open an issue on GitHub.
Made with β€οΈ and Streamlit