A jupyter widget for manual image segmantation
Project description
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
pip install jupyter_paint_segment
requires: python >= 3.9
Usage
Demo notebook: ./examples/main.ipynb
- Load image into numpy array:
# 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)
- Define labels and colors (optionally) and create widget:
from jupyter_paint_segment import SegmentWidget
widget = SegmentWidget(
image=image,
labels=["sheep", "dog"],
colors=["red", "blue"],
image_scale=1,
)
widget
- Get segmentation results:
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]])
import matplotlib.pyplot as plt
plt.imshow(labels_array)
Related projects
This project was highly inspired by jupyter-bbox-widget.
License
This project is licensed under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyter_paint_segment-0.1.0.tar.gz.
File metadata
- Download URL: jupyter_paint_segment-0.1.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.8.10 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a9dcc9774f848b301eeaafb122c8aaf4a90a5cabb3f6ab1d6a0933b3571109f
|
|
| MD5 |
258bf89a227892269a407b933b22ccd3
|
|
| BLAKE2b-256 |
6032118a465e110f58aaa8c34c920d76f52ae176ca2bbe0a216688e2883a9163
|
File details
Details for the file jupyter_paint_segment-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jupyter_paint_segment-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.8.10 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0f768adf48e758e18b0100cb6eae648af0ba203b90a66eb93dd07cc3b8ec21a
|
|
| MD5 |
0b7de788680dc769b6ddcbc44c8462c4
|
|
| BLAKE2b-256 |
989cada534246e07734ae2eac97335f54305aea4ac6c38bbf3bc346a3cf2955f
|