Skip to main content

Generate scribble annotations from segmentation masks

Project description

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:

pip install scribble-from-segmentation

Or install from source:

pip install -e .

Usage

Use the command-line interface to process segmentation masks:

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:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scribble_from_segmentation-0.2.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scribble_from_segmentation-0.2.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file scribble_from_segmentation-0.2.1.tar.gz.

File metadata

File hashes

Hashes for scribble_from_segmentation-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f787301147014c25ba5fad8d366ce1b542ea79cbc514740441f68fb913a461c1
MD5 4a13c8315e4afbb43e840a0b5cae44a5
BLAKE2b-256 3064351bbc616dd97afb8639c58fc7821d27e7f817e4b6aec7614c500fad0fca

See more details on using hashes here.

Provenance

The following attestation bundles were made for scribble_from_segmentation-0.2.1.tar.gz:

Publisher: pypi-publish.yml on alexsenden/scribble-from-segmentation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scribble_from_segmentation-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for scribble_from_segmentation-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a89dd2419bc957ec4840f0bc9a85f50ac3127938bc9dce9ddff97d6143b9d568
MD5 2c36da35502ef3f7ac4b5aea874fc2f5
BLAKE2b-256 458c4e5ff2cab0a818dc0f0d5258cb7fa1c0382fe3065968a71b4b469e49f24e

See more details on using hashes here.

Provenance

The following attestation bundles were made for scribble_from_segmentation-0.2.1-py3-none-any.whl:

Publisher: pypi-publish.yml on alexsenden/scribble-from-segmentation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page