Plotting the segmentation masks has never been so exciting!
Project description
Segmentation mask overlay
If you ever wonder to overlay your segmentations onto a picture in the smoothiest way, you're in a right place.
Installation
pip install segmentation-mask-overlay
Description
Here you can take your segmentation map, put on an image individually or in a company. If you have a bunch of them, they will blend if touch each other.
You can even name them one by one, providing labels.
That's it! As simple as is. Now you are completely ready to laminate images with your segmentation.
How to use
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
from segmentation_mask_overlay import overlay_masks
# [Example] Load image. If you are sure of you masks
image = Image.open("cat.jpg").convert("L")
image = np.array(image)
# [Example] Mimic list of masks
masks = []
for i in np.linspace(0, image.shape[1], 10, dtype="int"):
mask = np.zeros(image.shape, dtype="bool")
mask[i : i + 100, i : i + 200] = 1
masks.append(mask)
# [Optional] prepare labels
mask_labels = [f"Mask_{i}" for i in range(len(masks))]
# [Optional] prepare colors
cmap = plt.cm.tab20(np.arange(len(mask_labels)))
# Laminate your image!
fig = overlay_masks(image, masks, labels=mask_labels, colors=cmap, mask_alpha=0.5)
# Do with that image whatever you want to do.
fig.savefig("cat_masked.png", bbox_inches="tight", dpi=300)
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
Close
Hashes for segmentation-mask-overlay-0.3.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd95fa41c793b6af16dc886569c68e8274e9158fbd5bd86b2325826dcd8f2a3c |
|
MD5 | 8eed29375bc4efc8ca596ac2b17957bf |
|
BLAKE2b-256 | ef28cc1dd0f5b6a1cf1b7b5e501dec764c15cdeef5a38368e1428dea871bf00f |
Close
Hashes for segmentation_mask_overlay-0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c8a154abc32b1d91ac5bd20ba95c5f325046ff4a7308b5330bdcb0661c640db |
|
MD5 | acfd68c52f832de0ef8bf8dbb215c1fa |
|
BLAKE2b-256 | a7a34a65a8f4fe0103c4252d306a32755cc706796adacaa01aade1cf7cdf8856 |