Skip to content

Repository files navigation

ArtifySketch 🎨

Digital Image Processing Project — Automatic colorization of black-and-white sketches using Python, OpenCV, and Streamlit.


📂 Project Structure

DIP/
├── app.py                  ← Streamlit Web UI (main entry point)
├── cli.py                  ← Command-line interface
├── pipeline.py             ← Orchestrates the full DIP pipeline
├── generate_sample.py      ← Generates test B&W sketches
├── requirements.txt
├── core/
│   ├── preprocessor.py     ← Grayscale, normalization, denoising, threshold
│   ├── segmentor.py        ← Contour & flood-fill region detection
│   ├── palette.py          ← 6 artistic palettes + colour assignment
│   └── colorizer.py        ← Region-wise colour filling & compositing
└── samples/                ← Auto-generated test sketches

🚀 Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Generate Sample Sketches

python generate_sample.py

3. Run the Streamlit App

streamlit run app.py

4. (Optional) Command-Line Usage

# Basic usage
python cli.py samples/house_sketch.png --palette Cartoon

# With all options
python cli.py samples/flower_sketch.png \
  --palette Fantasy \
  --segmentation floodfill \
  --threshold adaptive \
  --min-area 200 \
  --blend 0.85 \
  --texture \
  --output result.png \
  --show

🎨 Available Palettes

Palette Description
Pastel Soft, gentle tones — great for illustrations
Cartoon Bold, saturated — ideal for comic-style art
Natural Earthy greens and blues — landscapes & nature
Fantasy Vibrant purples and magentas — magical themes
Sunset Warm reds, oranges and golds
Monochrome Greyscale shading effect

🔬 DIP Pipeline Steps

Input Image
    │
    ▼
① Preprocessing
   • Grayscale conversion
   • Histogram normalization
   • Gaussian denoising (configurable kernel)
   • Adaptive / Otsu / Simple thresholding
   • Morphological closing (fill stroke gaps)
    │
    ▼
② Edge & Contour Detection
   • Canny edge map
   • Contour finding (RETR_EXTERNAL)
    │
    ▼
③ Region Segmentation
   • Flood-fill (connected components) — default
   • OR contour-based mask generation
    │
    ▼
④ Palette Selection & Colour Assignment
   • Choose from 6 artistic palettes
   • Randomised or seeded assignment
    │
    ▼
⑤ Colorization & Compositing
   • Region-wise BGR fill
   • Configurable blend with original grayscale
   • Sketch lines re-drawn on top
   • Optional paint texture overlay
    │
    ▼
Output Image (PNG)

🛠 Technologies

  • Python 3.10+
  • OpenCV — image processing core
  • NumPy — numerical arrays
  • Streamlit — interactive web UI
  • Pillow — image I/O
  • Matplotlib — visualization support

📋 CLI Reference

usage: cli.py [-h] [-o OUTPUT] [-p PALETTE] [-s {floodfill,contour}]
              [-t {adaptive,otsu,simple}] [--min-area MIN_AREA]
              [--blend BLEND] [--texture] [--seed SEED] [--show]
              input

positional arguments:
  input                 Path to input sketch image

optional arguments:
  -o OUTPUT             Output file path (default: output.png)
  -p PALETTE            Colour palette
  -s {floodfill,contour}
                        Segmentation method
  -t {adaptive,otsu,simple}
                        Thresholding method
  --min-area MIN_AREA   Minimum region area in pixels (default: 300)
  --blend BLEND         Colour blend strength 0–1 (default: 0.90)
  --texture             Apply subtle paint texture
  --seed SEED           Random seed for colour assignments
  --show                Display result window after saving

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages