Skip to content

SkyServe-AI/tile-bbox-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Image Tile Selector & BBox Annotator

A professional desktop application for image annotation, tile selection, and object detection labeling. Built with Python and Tkinter.

Features

Image Tile Selector

  • πŸ“ Load multiple images (PNG, JPG, JPEG, TIFF)
  • 🎯 Drag & drop images or folders directly onto canvas
  • πŸ”² Automatic tile grid generation with customizable size
  • βœ… Interactive tile selection/deselection
  • πŸ–±οΈ Drag selection for multiple tiles (free-style painting)
  • 🎯 Classification mode for labeled exports
  • πŸ” LULC Classification with automated tile categorization
  • 🎨 Image preprocessing with CLAHE and color correction
  • 🌈 Color-coded overlay for 10 LULC categories
  • πŸ–οΈ Hand tool for transparent overlay on hover
  • πŸ‘οΈ Toggle overlay visibility
  • πŸ“Š Batch category assignment for multiple tiles
  • πŸ’Ύ Export tiles to category-specific directories
  • πŸ” Zoom and pan controls
  • πŸ“Š Real-time selection and classification statistics

BBox Selector & Polygon Annotator

  • πŸ“ Load single or multiple images
  • 🎯 Drag & drop images or folders directly onto canvas
  • πŸ“¦ Create rectangular bounding boxes
  • πŸ”Ί Draw custom polygon selections
  • 🏷️ Multi-class annotation system with color-coded labels
  • 🎨 Image augmentation (rotation, flip, brightness, contrast, blur, noise, etc.)
  • πŸ“€ Export formats: JSON, COCO, Pascal VOC, YOLO
  • ✏️ Resize bboxes with drag handles
  • 🎨 Visual feedback (hover, selection states)
  • πŸ—‘οΈ Delete and clear operations
  • πŸ’Ύ Export annotations with augmentation support
  • ⌨️ Keyboard shortcuts for efficiency
  • πŸ” Preserve zoom/pan during annotation

Screenshots

Image Tile Selector

Image Tile Selector

Image BBox Selector

Image BBox Selector

Installation

Prerequisites

  • Python 3.7 or higher
  • pip package manager

Setup

  1. Clone the repository
git clone https://github.com/SkyServe-AI/tile-bbox-exporter.git                      
cd tile-bbox-exporter
  1. Create a virtual environment (recommended)
# Windows
python -m venv venv
venv\Scripts\activate

# Linux/Mac
python3 -m venv venv
source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt

Usage

Running the Application

Image Tile Selector:

python run_tile_selector.py

BBox Selector:

python run_bbox_selector.py

Image Tile Selector Workflow

  1. Load Images

    • Click "πŸ“ Images" to select one or more images
    • Or click "πŸ“‚ Folder" to load all images from a directory
    • Or drag & drop images/folders directly onto canvas
    • Images will be displayed with automatic tile grid overlay
  2. Configure Tiles

    • Adjust "Tile Size" (default: 100 pixels)
    • Click "βœ“ Apply" to regenerate grid
  3. Enable Preprocessing (Optional)

    • Check "Preprocess" to apply CLAHE and color correction
    • Canvas will display the preprocessed image
    • Uncheck to revert to original image
  4. Classify Tiles (LULC Mode)

    • Click "πŸ” Classify LULC" to automatically categorize tiles
    • 10 LULC categories: AnnualCrop, Forest, HerbaceousVegetation, Highway, Industrial, Pasture, PermanentCrop, Residential, River, SeaLake
    • Tiles are color-coded by category
    • Category legend shows distribution counts
    • Single tile adjustment: Right-click any tile to change its category
    • Batch assignment:
      • Click and drag to select multiple tiles (green checkmarks)
      • Right-click to assign category to all selected tiles
    • Hand Tool (βœ‹): Click to enable hover transparency mode
    • Toggle Overlay (πŸ‘): Click to hide/show all category overlays
  5. Export

    • Standard Mode: Click "πŸ’Ύ Export" to save selected tiles
    • LULC Mode: Exports tiles to category-specific folders
    • Choose output folder
    • Files saved as: {image_name}_tile_r{row}_c{col}.png
    • LULC mode creates: {category}/{image_name}_tile_r{row}_c{col}.png

BBox Selector Workflow

  1. Load Image

    • Click "πŸ“ Load Image" or "πŸ“‚ Load Folder" to select images
  2. Select Class (Multi-Class Annotation)

    • Use class dropdown to select annotation class
    • Click "βš™οΈ Manage Classes" to add/edit/delete classes
    • Each class has a unique color for visual distinction
  3. Create Bounding Boxes

    • Set desired width/height in pixels
    • Click anywhere on image to create bbox
    • Click on bbox to select it (turns golden)
    • Drag corner/edge handles to resize
    • Bboxes are color-coded by class
  4. Create Polygons

    • Check "✏️ Polygon Mode" checkbox
    • Click to add points (3+ required)
    • Press Enter or Right-click to complete
    • Press Escape to cancel
    • Polygons are color-coded by class
  5. Configure Augmentation (Optional)

    • Click "🎨 Augment" to open settings
    • Enable desired augmentations:
      • Rotation (90Β°, 180Β°, 270Β°)
      • Horizontal/Vertical flip
      • Brightness, Contrast, Blur
      • Noise, Saturation, Sharpness
    • See live count of augmented images per bbox
    • Click "πŸ’Ύ Save Settings"
  6. Select Export Format

    • Choose format from dropdown: JSON / COCO / VOC / YOLO
    • JSON: Individual files per image
    • COCO: Single annotations_coco.json
    • VOC: XML files in Annotations/ folder
    • YOLO: TXT files in labels/ folder + classes.txt
  7. Save Annotations

    • Click "πŸ’Ύ Save All"
    • Choose whether to apply augmentation
    • Choose output folder
    • Exports:
      • Individual PNG images for each shape
      • Annotations in selected format
      • Augmented versions if enabled

Keyboard Shortcuts

BBox Selector:

  • Delete / Backspace - Delete selected shape
  • Enter - Complete polygon (in polygon mode)
  • Escape - Cancel polygon (in polygon mode)
  • Ctrl + Mouse Wheel - Zoom in/out
  • Shift + Mouse Wheel - Scroll horizontally
  • Mouse Wheel - Scroll vertically
  • Middle Mouse Drag - Pan canvas

Image Tile Selector:

  • Ctrl + Mouse Wheel - Zoom in/out
  • Shift + Mouse Wheel - Scroll horizontally
  • Mouse Wheel - Scroll vertically
  • Right Click - Change tile category (LULC mode)
  • Middle Mouse Drag - Pan canvas
    • On macOS trackpads use Control + Click or two-finger click (Control tap triggers Tk's right-click handler)

Project Structure

tile-bbox-exporter/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ tile_selector/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ app.py              # Main application entry point
β”‚   β”‚   β”œβ”€β”€ ui_components.py    # GUI setup and styling
β”‚   β”‚   β”œβ”€β”€ image_handler.py    # Image loading and navigation
β”‚   β”‚   β”œβ”€β”€ tile_manager.py     # Tile generation and export
β”‚   β”‚   β”œβ”€β”€ canvas_handler.py   # Canvas display and zoom
β”‚   β”‚   └── lulc_classifier.py  # LULC classification engine
β”‚   └── bbox_selector/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ app.py              # Main application entry point
β”‚       β”œβ”€β”€ ui_components.py    # GUI setup and styling
β”‚       β”œβ”€β”€ image_handler.py    # Image loading and navigation
β”‚       β”œβ”€β”€ shape_manager.py    # BBox/polygon operations
β”‚       β”œβ”€β”€ canvas_handler.py   # Canvas display and zoom
β”‚       β”œβ”€β”€ mouse_handler.py    # Mouse event handling
β”‚       β”œβ”€β”€ augmentation.py     # Image augmentation system
β”‚       └── export_formats.py   # COCO/VOC/YOLO exporters
β”œβ”€β”€ run_tile_selector.py        # Entry point for Tile Selector
β”œβ”€β”€ run_bbox_selector.py        # Entry point for BBox Selector
β”œβ”€β”€ lulc_dataset.py             # LULC dataset generation script
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ README.md                   # This file
β”œβ”€β”€ .gitignore                  # Git ignore rules
└── LICENSE                     # License file

Export Formats

JSON Format

Individual JSON file per image with bbox and polygon annotations:

{
  "image": "example.png",
  "image_width": 1920,
  "image_height": 1080,
  "bboxes": [
    {
      "id": 1,
      "x": 100,
      "y": 200,
      "width": 64,
      "height": 64,
      "class": "Class 1",
      "class_color": "#00ff00"
    }
  ],
  "polygons": [
    {
      "id": 1,
      "points": [[x1, y1], [x2, y2], [x3, y3], ...],
      "class": "Class 1",
      "class_color": "#00ff00"
    }
  ]
}

COCO Format

Single annotations_coco.json file compatible with Detectron2, MMDetection:

{
  "images": [{"id": 1, "file_name": "image.jpg", "width": 1920, "height": 1080}],
  "annotations": [
    {
      "id": 1,
      "image_id": 1,
      "category_id": 1,
      "bbox": [100, 200, 64, 64],
      "area": 4096,
      "iscrowd": 0
    }
  ],
  "categories": [{"id": 1, "name": "Class 1", "supercategory": "object"}]
}

Pascal VOC Format

XML files in Annotations/ folder, compatible with classic object detection models:

<annotation>
  <filename>image.jpg</filename>
  <size>
    <width>1920</width>
    <height>1080</height>
  </size>
  <object>
    <name>Class 1</name>
    <bndbox>
      <xmin>100</xmin>
      <ymin>200</ymin>
      <xmax>164</xmax>
      <ymax>264</ymax>
    </bndbox>
  </object>
</annotation>

YOLO Format

TXT files in labels/ folder + classes.txt, ready for YOLOv5/v8 training:

# Format: <class_id> <x_center> <y_center> <width> <height> (normalized 0-1)
0 0.085417 0.212963 0.033333 0.059259

classes.txt:

Class 1
Class 2
Class 3

Dependencies

  • Pillow (PIL) - Image processing
  • tkinter - GUI framework (included with Python)
  • numpy - Numerical operations for LULC classification
  • opencv-python - Image preprocessing (CLAHE, color correction)
  • tkinterdnd2 - Drag & drop support (optional)

See requirements.txt for specific versions.

Troubleshooting

Issue: "No module named 'PIL'"

Solution: Install Pillow

pip install Pillow

Issue: "tkinter not found"

Solution: Install tkinter (Linux)

# Ubuntu/Debian
sudo apt-get install python3-tk

# Fedora
sudo dnf install python3-tkinter

Issue: "No module named '_tkinter'"

Solution: macOS Python must be linked against Tcl/Tk. Install the missing frameworks and recreate the virtual environment before reinstalling dependencies.

# Install the Tcl/Tk runtime (Homebrew example)
brew install tcl-tk

# Point Python to Homebrew's Tcl/Tk when it is rebuilt or installed
# (the python.org installer already bundles Tcl/Tk, so reinstalling from python.org also works)
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Confirm tkinter loads
python3 -m tkinter

If you use pyenv/asdf, make sure the build picks up tcl-tk headers by exporting CPPFLAGS/LDFLAGS before compiling.

Issue: Images not loading

Solution: Ensure images are in supported formats (PNG, JPG, JPEG, TIFF)

Issue: Keyboard shortcuts not working

Solution: Click on the canvas to give it focus

Architecture

Modular Design

Both applications follow a clean, modular architecture with separation of concerns:

Design Principles:

  • Single Responsibility: Each module handles one specific aspect
  • Separation of Concerns: UI, business logic, and event handling are separated
  • Maintainability: Small, focused files (~150-300 lines each)
  • Testability: Easy to unit test individual components
  • Scalability: Simple to add new features without affecting existing code

Module Responsibilities:

Module Purpose
app.py Application initialization and coordination
ui_components.py GUI layout, buttons, and styling
image_handler.py Image loading, navigation, and management
shape_manager.py / tile_manager.py Business logic for annotations/tiles
canvas_handler.py Canvas rendering, zoom, and display
mouse_handler.py Mouse events and user interactions (BBox only)

Development

Running Tests

# Add when tests are implemented
python -m pytest tests/

Code Style

  • Follow PEP 8 guidelines
  • Use meaningful variable names
  • Add docstrings to functions
  • Keep modules focused and under 300 lines

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with Python and Tkinter
  • Image processing powered by Pillow
  • Designed for satellite imagery and object detection workflows

Support

For issues, questions, or contributions, please open an issue on the GitHub repository.


Version: 2.2.0
Last Updated: November 2025
Author: Vijay Purohit
Email: [email protected] or [email protected]

About

Image tile selector and exporter tool to break image into desired tile size

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages