Skip to content

Unable to convert ImgLib2 BooleanType image to numpy/xarray bool #13

@elevans

Description

@elevans

imglyb does not support converting bool type images to numpy. This means that users are unable to convert masks/thresholded images into python numpy/xarray objects.

Here is a minimal example:

import imagej
import scyjava as sj

# initialize
ij = imagej.init()

# load blobs
img = ij.io().open('blobs.tif')

# threshold image w/ ops
CreateNamespace = sj.jimport('net.imagej.ops.create.CreateNamespace')

img_invert = ij.op().namespace(CreateNamespace).img(img)
ij.op().image().invert(img_invert, img)
threshold = ij.op().threshold().otsu(img_invert)

# get threshold from java
py_threshold = ij.py.from_java(threshold)

Returns the traceback:

File "/home/edward/Documents/repos/loci/imglyb/imglyb/util.py", line 149, in _to_imglib
    raise NotImplementedError("Cannot convert dtype to ImgLib2 type yet: {}".format(source.dtype))
NotImplementedError: Cannot convert dtype to ImgLib2 type yet: bool

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions