labelroi
A Qt-based application for drawing and labeling polygon/polyline ROIs (Regions of Interest) on images and videos.
Features
- Image and Video Support: Load images (PNG, JPG, JPEG, BMP, TIFF) or MP4 videos (displays first frame)
- ROI Drawing: Draw polygon ROIs by clicking vertices, or polylines for open shapes
- ROI Naming: Double-click on any ROI to add or edit its name
- Smooth Navigation: Pan and zoom with mouse/trackpad gestures
- ROI Management: View ROI properties, delete individual ROIs, or clear all
- YAML Export/Import: Save ROIs to YAML files for later use or sharing
- Geometry Analysis: Automatic calculation of area, perimeter, and vertex count using Shapely
Installation
Prerequisites
Install uv if you haven't already:
# On macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or with pip
pip install uv
Install from Source
- Clone the repository:
git clone https://github.com/talmolab/labelroi.git
cd labelroi
- Install the package using uv:
uv pip install -e .
This will install labelroi and all its dependencies in editable mode.
Usage
Command Line Interface
Launch the application with:
labelroi
Or open with a specific image/video:
labelroi path/to/image.png
labelroi path/to/video.mp4
Drawing ROIs
- Click "Start Drawing ROI" button
- Left-click to add vertices to your polygon
- Either:
- Click on the first vertex (green dot) to close the polygon
- Right-click to finish as a polyline (open shape)
- Repeat to draw multiple ROIs (each gets a unique color)
ROI Naming
- Double-click on any ROI to add or edit its name
- Names appear as white labels on the ROI
- Clear the name to remove the label
Navigation Controls
Mouse/Trackpad:
- Scroll wheel: Zoom in/out
- Pinch gesture: Zoom in/out
- Middle-click + drag: Pan around
- Ctrl + Left-click + drag: Pan around
- Alt + Double-click: Reset zoom
Keyboard:
- Arrow keys or WASD: Pan
- +/=: Zoom in
- -: Zoom out
- 0 or Home: Reset zoom
- F1 or H: Show help
Saving and Loading ROIs
ROIs are automatically saved with the same name as your image/video file with a .rois.yml suffix:
- Image:
my_image.png→ ROIs:my_image.rois.yml - Video:
my_video.mp4→ ROIs:my_video.rois.yml
Click "Save ROIs to YAML" to save your ROIs. They will automatically load when you open the same image/video again.
YAML Format
The ROIs are saved in a human-readable YAML format:
image_file: /path/to/image.png
roi_count: 2
rois:
- id: 1
name: "Region A"
type: polygon
coordinates:
- [100.5, 200.3]
- [150.2, 250.7]
- [100.8, 300.1]
color: "#1f77b4"
properties:
vertex_count: 3
perimeter: 172.5
area: 1250.3
- id: 2
name: "Line B"
type: polyline
coordinates:
- [200.0, 100.0]
- [300.0, 150.0]
color: "#ff7f0e"
properties:
vertex_count: 2
perimeter: 111.8
Development
Running from Source
# Clone and enter directory
git clone https://github.com/talmolab/labelroi.git
cd labelroi
# Install in development mode
uv pip install -e .
# Run the application
python src/labelroi/labelroi.py
Dependencies
- numpy: Array operations
- matplotlib: Visualization and plotting
- shapely: Geometry operations
- qtpy: Qt compatibility layer
- PyQt5: Qt backend (can also use PyQt6, PySide2, or PySide6)
- sleap-io: Video file loading
- PyYAML: YAML file I/O
License
See LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Issues
If you encounter any problems, please file an issue at https://github.com/talmolab/labelroi/issues
Metadata
Release files for labelroi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| labelroi-0.1.0.tar.gz | 14.2 kB | Without provenance | Details for labelroi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| labelroi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for labelroi-0.1.0-py3-none-any.whl |
Total release size: 29.6 kB
Release files / labelroi-0.1.0.tar.gz
| Download URL | labelroi-0.1.0.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de537cd8af29894c61bb9fb07c8ebf109610e2535a8f865e9ce8382e9712688c
|
|
BLAKE2b-256 checksum How to use checksums |
0671e8542f5140e31a29d6765b075b47e5ddb18f8fd1df788f5874d1197fea32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.5.14
|
Release files / labelroi-0.1.0-py3-none-any.whl
| Download URL | labelroi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a0b548888cc71be29ffc4bafc772b60e99b67b97580b800746bd34aa34952bbd
|
|
BLAKE2b-256 checksum How to use checksums |
f2602a951a8b00f8260c654e43702a92724f95a1d5b8f5fe9a7eaf6f5abbcf07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.5.14
|
Security for labelroi 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.