Gets the bounding boxes from a mask file.
Project description
mask2bbox
For a given mask, gets the coordinates of bounding box of each element of the mask. It will also allow for more operations in the future.
Installation
pip install mask2bbox
CLI
isolate-cells -h
isolate-cells-from-file -h
get-average-iou -h
Usage
import numpy as np
from mask2bbox import BBoxes
# Create a BBoxes object
all_boxes = BBoxes.from_mask("path/to/mask.png")
# Expand the bounding boxes
all_boxes = all_boxes.expand(n=10)
# Remove the bounding boxes that are located on the edge of the image
all_boxes = all_boxes.remove_from_edge()
# Get the sides of all the bounding boxes
sides = all_boxes.get("sides")
# Filter the bounding boxes by the sides
filtered_boxes = all_boxes.filter("sides", np.greater_equal, (35, 35))
# Get the IoU matrix of all the bounding boxes
iou = filtered_boxes.iou_matrix()
# Save the overlapping pairs to
filtered_boxes.save_overlapping_pairs("path/to/save/overlapping_pairs.csv")
# Save the IOU matrix to a csv file
filtered_boxes.save_iou_matrix("path/to/save/iou_matrix.csv")
# Plot the bounding boxes on the mask image
filtered_boxes.draw(to="image", method="matplotlib", show="False", save="path/to/save/image.png")
# Save your bounding boxes
filtered_boxes.save_csv("path/to/bounding_boxes.csv")
# Get resize factors to resize the bounding boxes to a given size
resize_factors = filtered_boxes.de(desired_ratio=0.7, size=(256, 256))
# Extract the bounding boxes as images
filtered_boxes.extract(resize_factors, size=(256, 256), output="path/to/save/images")
License
mask2bbox offers a dual licensing mode the GNU Affero General Public License v3.0 - see LICENSE and ESSENTIAL_LICENSE_CONDITIONS.txt
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
mask2bbox-0.0.21.tar.gz
(26.9 kB
view details)
Built Distribution
File details
Details for the file mask2bbox-0.0.21.tar.gz
.
File metadata
- Download URL: mask2bbox-0.0.21.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 954ff84ee3da821a8fb643d6293f6e9a0d3440f72661b8f98aed6c9fbab9e2a5 |
|
MD5 | 5abcfed56f2fa321306d99ca57ce0c19 |
|
BLAKE2b-256 | 7c20f97a6b922283c22112acc73a3b3a38b7f981ea76253d23c8b4ca453ab724 |
File details
Details for the file mask2bbox-0.0.21-py3-none-any.whl
.
File metadata
- Download URL: mask2bbox-0.0.21-py3-none-any.whl
- Upload date:
- Size: 29.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30111b8f1883aee84135f91ffc1bf51d5227407446679c5c9c32bfe6f41e36ce |
|
MD5 | 0dadc32e020ea7160f5ce0be41ebde85 |
|
BLAKE2b-256 | 6d59d900af4d9b185085f3730674b96c597053c0e0789fb1057d79ed61c86d96 |