Images
Image retrieval, stacking, and compositing.
nimbusimage.images.ImageAccessor
Access images for a dataset.
get(xy=0, z=0, time=0, channel=0, crop=None)
Get a single image frame as a 2D numpy array.
Always returns a squeezed 2D array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xy, z, time, channel
|
Coordinates. |
required | |
crop
|
tuple[float, float, float, float] | None
|
Optional (left, top, right, bottom) crop region. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
2D numpy array. |
get_all_channels(xy=0, z=0, time=0)
Get all channels at one location as a list of 2D arrays.
get_stack(xy=0, z=0, time=0, channel=0, axis='z')
Get a stack along one axis as a 3D array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
str
|
'z' or 'time'. The other coordinates are fixed. |
'z'
|
Returns:
| Type | Description |
|---|---|
ndarray
|
3D numpy array: (N, H, W) where N is the axis size. |
get_composite(xy=0, z=0, time=0, mode='lighten', dtype=None)
Get a composite RGB image merging visible channels.
Uses layer settings from ds.collections.layers for contrast and color.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Blend mode ('lighten' default). |
'lighten'
|
dtype
|
str | None
|
Output dtype. None = match source. 'float64' = [0,1]. 'uint8' = [0,255]. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
(H, W, 3) numpy array. |
iter_frames()
Iterate over all frames in the dataset.
Yields:
| Type | Description |
|---|---|
tuple[FrameInfo, ndarray]
|
(FrameInfo, 2D numpy array) tuples. |
new_writer(copy_metadata=True)
Create an ImageWriter for writing processed images.
Requires the [worker] extra (large_image).
nimbusimage.images.ImageWriter
Write processed images back to the dataset.
Requires the [worker] extra (large_image package). Can be used as a context manager or explicitly.
add_frame(image, **kwargs)
Add a frame to the output.
kwargs should include c, z, t, xy for frame positioning.
set_metadata(**kwargs)
Set metadata that will be added to the uploaded item.
write(filename='output.tiff')
Write the TIFF and upload to the dataset folder.