Skip to main content

roi_rectangle

A Python module for handling rectangular regions of interest (ROI) in images.

Features

  • Define a rectangular ROI with coordinates.
  • Get the center of the ROI.
  • Move the ROI to a new center.
  • Resize the ROI.
  • Get the coordinates and area of the ROI.
  • Slice the ROI region from an image.

Installation

To install the roi_rectangle module, use:

pip install roi_rectangle

Usage

Here's an example of how to use the RoiRectangle module:

from roi_rect import RoiRectangle
import numpy as np
import matplotlib.pyplot as plt

# Create a test image
test_image = np.random.random((100, 100))

# Create an instance of RoiRectangle
roi = RoiRectangle(y1=30, y2=80, x1=20, x2=70)

# Print ROI information
print("Initial ROI:")
print(roi)

# Get the center coordinate of the ROI
print("Center Coordinate:", roi.center)

# Get the width and height of the ROI
print("Width:", roi.width)
print("Height:", roi.height)

# Move the ROI to a new center
new_center = (50, 50)
roi.move_to_center(new_center)
print("\nAfter Moving to Center:")
print(roi)

# Resize the ROI
new_width, new_height = 30, 40
roi.resize(new_width, new_height)
print("\nAfter Resizing:")
print(roi)

# Slice the ROI region from the test image
roi_slice = roi.slice(test_image)
print("\nROI Slice:")
print(roi_slice)

# Visualize the original image and the sliced ROI
plt.figure(figsize=(8, 4))
plt.subplot(1, 2, 1)
plt.title('Original Image')
plt.imshow(test_image, cmap='gray')

plt.subplot(1, 2, 2)
plt.title('ROI Slice')
plt.imshow(roi_slice, cmap='gray')

plt.gca().add_patch(plt.Rectangle((roi.x1, roi.y1), roi.width, roi.height, linewidth=2, edgecolor='r', facecolor='none'))
plt.show()

License

This project is licensed under the MIT License.

Metadata

Release files for roi-rectangle 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for roi-rectangle 1.0.1
File Size Uploaded
roi_rectangle-1.0.1.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for roi-rectangle 1.0.1
File Interpreter ABI Platform
roi_rectangle-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / roi_rectangle-1.0.1.tar.gz

Download URL roi_rectangle-1.0.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b3611ed0df2f3fc31ac83fecb8fcff52f3214a0d031d5dee23cb14859c5badd2
BLAKE2b-256 checksum
How to use checksums
4b50de7b8e49fad42141442942f1ff0c29b4ef95b736f3132ed74dac20307b41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / roi_rectangle-1.0.1-py3-none-any.whl

Download URL roi_rectangle-1.0.1-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29b53c3ea02df3a12919a319427a16292dcdf98e66ab7921171b442d84ed61fd
BLAKE2b-256 checksum
How to use checksums
37bbc7a1a50d051f892975501a589dc4148b0fbdcc54f01f9b411492c60e1930
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.0

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page