https://github.com/adusachev/jupyter-paint-segment
A jupyter widget for manual image segmentation.
https://github.com/adusachev/jupyter-paint-segment
anywidget image-annotation-tool image-segmentation jupyter jupyter-widget jupyter-widgets segmentation
Last synced: 30 days ago
JSON representation
A jupyter widget for manual image segmentation.
- Host: GitHub
- URL: https://github.com/adusachev/jupyter-paint-segment
- Owner: adusachev
- License: mit
- Created: 2025-02-23T18:17:30.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2025-03-27T09:46:45.000Z (about 2 months ago)
- Last Synced: 2025-04-15T07:19:07.887Z (about 1 month ago)
- Topics: anywidget, image-annotation-tool, image-segmentation, jupyter, jupyter-widget, jupyter-widgets, segmentation
- Language: JavaScript
- Homepage:
- Size: 8.4 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jupyter-paint-segment
## Overview
A jupyter widget for interactive drawing segmentation masks.
Brush, rectangle and eraser tools are available.
Size of brush and eraser can be changed using slider.
---
## Installation
```sh
pip install jupyter_paint_segment
```requires: python >= 3.9
---
## Usage
Demo notebook: `./examples/main.ipynb`
1. Load image into numpy array:
```python
# with PIL:
from PIL import Image
import numpy as np
pilImage = Image.open("./examples/images/sheeps.png")
image = np.array(pilImage)# or with opencv:
import cv2 as cv
image_bgr = cv.imread("./examples/images/sheeps.png")
image = cv.cvtColor(image_bgr, cv.COLOR_BGR2RGB)
```2. Define labels and colors (optionally) and create widget:
```python
from jupyter_paint_segment import SegmentWidgetwidget = SegmentWidget(
image=image,
labels=["sheep", "dog"],
colors=["red", "blue"],
image_scale=1,
)
widget
```3. Get segmentation results:
```python
labels_array, labels_map = widget.segmentation_result()labels_map
# {'sheep': 1, 'dog': 2, 'unlabeled_background': 0}
labels_array
# array([[0, 0, 0, ..., 0, 0, 0],
# [0, 0, 0, ..., 0, 0, 0],
# [0, 0, 0, ..., 0, 0, 0],
# ...,
# [0, 0, 0, ..., 0, 0, 0],
# [0, 0, 0, ..., 0, 0, 0],
# [0, 0, 0, ..., 0, 0, 0]])
``````python
import matplotlib.pyplot as pltplt.imshow(labels_array)
```
---
## Related projects
This project was highly inspired by [jupyter-bbox-widget](https://github.com/gereleth/jupyter-bbox-widget).
---
## License
This project is licensed under the [MIT license](https://github.com/adusachev/jupyter-paint-segment/blob/master/LICENSE).
---