Read and write ImageJ ROI format
Project description
Roifile is a Python library to read, write, create, and plot ImageJ ROIs, an undocumented and ImageJ application specific format to store regions of interest, geometric shapes, paths, text, and whatnot for image overlays.
- Author:
- Organization:
Laboratory for Fluorescence Dynamics, University of California, Irvine
- License:
BSD 3-Clause
- Version:
2020.11.28
Requirements
This release has been tested with the following requirements and dependencies (other versions may work):
Tifffile 2020.11.26 (optional)
Matplotlib 3.3 (optional)
Revisions
- 2020.11.28
Support group attribute. Add roiread and roiwrite functions (#3). Use UUID as default name of ROI in ImagejRoi.frompoints (#2).
- 2020.8.13
Support writing to ZIP file. Support os.PathLike file names.
- 2020.5.28
Fix int32 to hex color conversion. Fix coordinates of closing path. Fix reading TIFF files with no overlays.
- 2020.5.1
Split positions from counters.
- 2020.2.12
Initial release.
Notes
The ImageJ ROI format cannot store integer coordinate values outside the range of -32768 to 32767 (16-bit signed).
Other Python packages handling ImageJ ROIs:
Examples
Create a new ImagejRoi instance from an array of x, y coordinates:
>>> roi = ImagejRoi.frompoints([[1.1, 2.2], [3.3, 4.4], [5.4, 6.6]]) >>> roi.coordinates() array([[1.1, 2.2], [3.3, 4.4], [5.4, 6.6]], dtype=float32) >>> roi.left, roi.left, roi.right, roi.bottom (1, 1, 5, 6)
Export the instance to an ImageJ ROI formatted byte string or file:
>>> out = roi.tobytes() >>> out[:4] b'Iout' >>> roi.tofile('_test.roi')
Read the ImageJ ROI from the file:
>>> roi2 = ImagejRoi.fromfile('_test.roi') >>> roi2 == roi True
Plot the ROI using matplotlib:
>>> roi.plot()
To view the overlays stored in a ROI, ZIP, or TIFF file from a command line, run python -m roifile _test.roi.
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
Hashes for roifile-2020.11.28-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | faf1a78c6ea24eea988899459b3e4ada4839a64bcfbb9faa2b294ee15634c487 |
|
MD5 | 8f490a80cc222f87c36c8bc51dc54b59 |
|
BLAKE2b-256 | 1d618563d4109c7014e7e005abaa34aede53230a260bebd632a65c6301e7cb89 |