AKA Math
Fix README frontmatter for HuggingFace
3f689b4
|
Raw
History Blame Contribute Delete
3.31 kB

A newer version of the Streamlit SDK is available: 1.62.0

Upgrade
metadata
title: Image Sampling and Quantization Demo
colorFrom: blue
colorTo: purple
sdk: streamlit
sdk_version: 1.39.0
app_file: app.py
pinned: false
license: mit

Interactive Image Sampling and Quantization Demo

An educational demonstration showing how sampling and quantization impact image visualization and storage.

What You'll Learn

This interactive demo teaches fundamental concepts in digital image processing:

1. Spatial Sampling

  • How reducing sampling grid size makes images more pixelated
  • The direct relationship between pixel count and file size
  • Visual impact of resolution reduction

2. Quantization (Bit Depth)

  • How bit depth controls the number of colors/gray levels
  • The trade-off between image quality and storage
  • Visual degradation as bits per pixel decrease

3. Image Compression

  • Differences between JPEG and PNG compression
  • How JPEG's lossy compression creates blocking artifacts
  • Comparison of file sizes across different compression methods

Features

  • Interactive Sliders: Real-time adjustment of sampling rate and bit depth
  • Live File Size Estimates: See how changes affect storage requirements
  • Side-by-Side Comparisons: Original vs. processed images
  • Compression Artifacts: Visualize JPEG blocking effects
  • Educational Insights: Learn the theory behind each concept

Local Development

Setup

# Clone the repository
git clone <your-repo-url>
cd sampling-quantization

# Install dependencies
pip install -r requirements.txt

Run Locally

# Simple run
streamlit run app.py

# Or use the provided script
chmod +x run_simple.sh
./run_simple.sh

The app will be available at http://localhost:8501

Deployment to Hugging Face Spaces

This app is designed to be deployed to Hugging Face Spaces:

  1. Create a new Space on Hugging Face
  2. Choose "Docker" as the SDK
  3. Push this repository to your Space

Or use the deployment script:

chmod +x deploy.sh
./deploy.sh

Educational Use

This demo is designed for:

  • Graduate image analysis courses
  • Computer vision fundamentals
  • Digital image processing tutorials
  • Self-paced learning about image storage

Key Concepts Covered

  • Nyquist Sampling Theorem: Understanding sampling limits
  • Bit Depth: Relationship between bits and color/gray levels
  • File Size Calculation: Width x Height x Bits per pixel / 8
  • Lossy vs. Lossless Compression: JPEG vs. PNG trade-offs
  • Blocking Artifacts: DCT-based compression effects

Project Structure

sampling-quantization/
β”œβ”€β”€ app.py                  # Main Streamlit application
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ README.md              # This file
β”œβ”€β”€ packages.txt           # System dependencies for HF Spaces
β”œβ”€β”€ .python-version        # Python version specification
β”œβ”€β”€ pyproject.toml         # Project metadata
β”œβ”€β”€ run_simple.sh          # Local development script
β”œβ”€β”€ deploy.sh              # Deployment helper script
└── sample_images/         # Example images (optional)

License

MIT License - feel free to use for educational purposes.

Credits

Inspired by interactive teaching tools for computer vision education.