Spaces:
Runtime error
Runtime error
File size: 8,126 Bytes
0823daf 719e71f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | ---
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.
[](https://huggingface.co/spaces/YOUR_USERNAME/colorspaces)
## π Features
This interactive demo covers the following topics:
### π Colorspaces Covered
1. **RGB (Red, Green, Blue)**
- Additive color model
- Channel visualization and manipulation
- Primary and secondary colors
- Device-dependent representation
2. **HSV/HSI (Hue, Saturation, Value/Intensity)**
- Cylindrical color representation
- Perceptually intuitive controls
- Color, saturation, and brightness separation
- Interactive hue shifting and saturation adjustment
3. **CIE-LAB**
- Perceptually uniform colorspace
- Device-independent
- Color difference calculations (ΞE)
- Lightness and opponent color channels
4. **CMYK (Cyan, Magenta, Yellow, Key/Black)**
- Subtractive color model
- Printing and print separation
- Comparison with additive (RGB) model
- Understanding ink absorption
5. **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
6. **Gamma Correction**
- Non-linear display response compensation
- Gamma curves and their effects
- Histogram visualization
- Standard gamma values (sRGB, Rec. 709)
7. **White Balance**
- Color temperature correction
- Different lighting conditions (daylight, incandescent, fluorescent)
- Gray world assumption
- Manual and automatic white balance
8. **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
1. **Clone the repository**
```bash
git clone https://github.com/ubern-image-analysis/colorspaces.git
cd colorspaces
```
2. **Set up the environment**
```bash
make setup
```
3. **Run the application**
```bash
make run
```
4. **Open your browser**
- The app will automatically open at `http://localhost:8501`
### Using Make Commands
```bash
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](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:
1. **Understand color representation** in different colorspaces
2. **Visualize color transformations** between spaces
3. **Explore perceptual properties** of different models
4. **Learn compression techniques** like chroma subsampling
5. **Practice color correction** with gamma and white balance
6. **Design for accessibility** using colorblind simulations
## π Deployment to Hugging Face Spaces
### Prerequisites
1. Create a Hugging Face account at [huggingface.co](https://huggingface.co)
2. Create a new Space:
- Go to [huggingface.co/spaces](https://huggingface.co/spaces)
- Click "Create new Space"
- Choose "Streamlit" as the SDK
- Name it (e.g., `colorspaces`)
3. Install Hugging Face CLI and login:
```bash
pip install huggingface-hub
huggingface-cli login
```
### Deploy
1. **Initialize git (if not already done)**
```bash
git init
git add .
git commit -m "Initial commit"
```
2. **Deploy to Hugging Face**
```bash
make deploy
```
Follow the prompts and enter your Space name (e.g., `username/colorspaces`)
3. **Check status**
```bash
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
1. Create a new tab function in `app.py`
2. Add educational content with markdown
3. Include interactive controls (sliders, buttons)
4. Visualize results with side-by-side comparisons
5. Add explanatory text and key insights
### Testing Locally
```bash
# 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](LICENSE) file for details.
## π₯ Authors
Created for graduate-level image analysis courses at the University of Bern.
## π Acknowledgments
- Based on the [sampling-quantization demo](https://github.com/ubern-image-analysis/sampling-quantization)
- Colorblind simulation algorithms from [Brettel, ViΓ©not, and Mollon](http://www.daltonize.org/)
- Test images from standard image processing datasets
## π§ Contact
For questions or feedback, please open an issue on GitHub.
---
Made with β€οΈ and [Streamlit](https://streamlit.io)
|