Metadata-Version: 2.4
Name: scribble-from-segmentation
Version: 0.2.1
Summary: Generate scribble annotations from segmentation masks
Author: Alex Senden
Maintainer: Alex Senden
License: MIT
Keywords: computer-vision,image-annotation,image-processing,machine-learning,segmentation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.8
Requires-Dist: numpy
Requires-Dist: opencv-python
Requires-Dist: pillow
Requires-Dist: scikit-image
Description-Content-Type: text/markdown

# Scribble From Segmentation

Generate scribble annotations or filled bounding boxes from segmentation masks using image processing techniques.

## Overview

This tool converts segmentation masks into scribble annotations by applying morphological operations. It's useful for creating weak supervision labels or simplifying segmentation annotations for training purposes.

The tool:

- Processes segmentation masks and extracts individual classes
- Automatically detects and skips background classes
- Applies morphological operations to refine class boundaries
- Skeletonizes regions to create scribble-like annotations
- Can generate filled bounding boxes for each object
- Preserves the original color information for each class

## Installation

Install from PyPI:

```bash
pip install scribble-from-segmentation
```

Or install from source:

```bash
pip install -e .
```

## Usage

Use the command-line interface to process segmentation masks:

```bash
scribble-from-segmentation --input_dir /path/to/segmentation/masks --output_dir /path/to/output/scribbles
```

### Arguments

- `--input_dir` (required): Path to directory containing segmentation mask images
- `--output_dir` (required): Path to directory where scribble annotations will be saved
- `--mode` (optional): Annotation mode, `scribbles` (default) or `bounding_boxes`

### Supported Image Formats

- PNG
- JPG/JPEG
- GIF
- BMP
- TIF

## Python API

You can also use the tool directly in your Python code:

```python
from scribble_from_segmentation import generate_annotations_from_segmentations

# Generate scribbles from segmentation masks
generate_annotations_from_segmentations(
    input_dir="/path/to/segmentation/masks",
    output_dir="/path/to/output/scribbles"
)

# Generate bounding boxes from segmentation masks
generate_annotations_from_segmentations(
    input_dir="/path/to/segmentation/masks",
    output_dir="/path/to/output/bboxes",
    mode="bounding_boxes"
)
```

## Requirements

- Python >= 3.8
- numpy
- opencv-python
- Pillow
- scikit-image

## License

MIT License

## Author

Alex Senden
