InsightSoftwareConsortium / InsightSoftwareConsortium/itkwidgets

Unable to display "large" RGB cube

Open
#395 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
624
Forks
83
PR merge metrics
No merged PRs in 30d

Description

I am unable to display RGB image cubes with reasonable size. The following shows a small snippet of code that works ok:

```
import itk
import numpy as np
from itkwidgets import view
from tifffile import imsave

arr = np.ones((10, 100, 100, 3), "uint8")
imsave("test.tif", arr)
image = itk.imread("test.tif", itk.RGBPixel[itk.UC])
view(image)
```

However changing to a larger size produces an error, e.g. using instead

```
arr = np.ones((10, 200, 200, 3), "uint8")
```

I get

```
---------------------------------------------------------------------------
TemplateTypeError Traceback (most recent call last)
in
7 imsave("test.tif", arr)
8 image = itk.imread("test.tif", itk.RGBPixel[itk.UC])
----> 9 view(image)

/opt/conda/lib/python3.7/site-packages/itkwidgets/widget_viewer.py in view(image, label_image, label_image_names, label_image_weights, label_image_blend, cmap, lut, select_roi, interpolation, gradient_opacity, opacity_gaussians, channels, slicing_planes, shadow, blend_mode, point_sets, point_set_colors, point_set_opacities, point_set_representations, point_set_sizes, geometries, geometry_colors, geometry_opacities, ui_collapsed, rotate, annotations, axes, mode, **kwargs)
1084 rotate=rotate, ui_collapsed=ui_collapsed,
1085 annotations=annotations, axes=axes, mode=mode,
-> 1086 **kwargs)
1087 return viewer

/opt/conda/lib/python3.7/site-packages/itkwidgets/widget_viewer.py in __init__(self, **kwargs)
408 if size[dim] > self.size_limit_3d[dim]:
409 self._downsampling = True
--> 410 self._update_rendered_image()
411 if self._downsampling:
412 self.observe(self._on_roi_changed, ['roi'])

/opt/conda/lib/python3.7/site-packages/itkwidgets/widget_viewer.py in _update_rendered_image(self)
488 if self.image:
489 self.extractor = itk.ExtractImageFilter.New(self.image)
--> 490 self.shrinker = itk.ShrinkImageFilter.New(self.extractor)
491 self.shrinker.SetShrinkFactors(scale_factors[:dimension])
492 if self.label_image:

/opt/conda/lib/python3.7/site-packages/itkTemplate.py in New(self, *args, **kwargs)
522 or via one of the following keyword arguments: %s""" % ", ".join(primary_input_methods))
523 else:
--> 524 raise TemplateTypeError(self, input_type)
525 return self[list(keys)[0]].New(*args, **kwargs)
526

TemplateTypeError: itk.ShrinkImageFilter is not wrapped for input type `None`.

To limit the size of the package, only a limited number of
types are available in ITK Python. To print the supported
types, run the following command in your python environment:

itk.ShrinkImageFilter.GetTypes()

Possible solutions:
* If you are an application user:
** Convert your input image into a supported format (see below).
** Contact developer to report the issue.
* If you are an application developer, force input images to be
loaded in a supported pixel type.

e.g.: instance = itk.ShrinkImageFilter[itk.Image[itk.SS,2], itk.Image[itk.SS,2]].New(my_input)

* (Advanced) If you are an application developer, build ITK Python yourself and
turned to `ON` the corresponding CMake option to wrap the pixel type or image
dimension you need. When configuring ITK with CMake, you can set
`ITK_WRAP_${type}` (replace ${type} with appropriate pixel type such as
`double`). If you need to support images with 4 or 5 dimensions, you can add
these dimensions to the list of dimensions in the CMake variable
`ITK_WRAP_IMAGE_DIMS`.

Supported input types:

itk.Image[itk.SS,2]
itk.Image[itk.SS,3]
itk.Image[itk.UC,2]
itk.Image[itk.UC,3]
itk.Image[itk.US,2]
itk.Image[itk.US,3]
itk.Image[itk.F,2]
itk.Image[itk.F,3]
itk.Image[itk.D,2]
itk.Image[itk.D,3]
```

Either I am doing something very wrong or there is an issue displaying RGB cubes.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.