Skip to main content

Gets the bounding boxes from a mask file.

Project description

mask2bbox

PyPI PyPI - Python Version PyPI - License PyPI - Downloads

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

python isolate-cells -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")

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.20.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

mask2bbox-0.0.20-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file mask2bbox-0.0.20.tar.gz.

File metadata

  • Download URL: mask2bbox-0.0.20.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for mask2bbox-0.0.20.tar.gz
Algorithm Hash digest
SHA256 beebb9e199ae0f628127e81f07d731a96c576a805a5a7cdb5e6de80635aaa079
MD5 822abe34b448ecd425522fc3a00f59ab
BLAKE2b-256 23851fe071bda0232a916e4c76b23758b1260beeeee99bd3ad26e66ec1d07d35

See more details on using hashes here.

File details

Details for the file mask2bbox-0.0.20-py3-none-any.whl.

File metadata

  • Download URL: mask2bbox-0.0.20-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for mask2bbox-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 647e98421aacaf7e141e0897990bf099073a9918412a103d3d497db96bd9fc3a
MD5 5e11233650abfe77d19ef09352f8fb92
BLAKE2b-256 393046792fdea3804401621dd9297b83e43ed997aa2275395405a3b5ed84b4cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page