imagej / imagej-legacy

ImageJ+ImageJ2 compatibility layer
https://imagej.net/libs/imagej-legacy
BSD 2-Clause "Simplified" License
16 stars 25 forks source link

ImagePlusToDatasetConverter does not preserve pixel changes in ImagePluses originating from a Dataset #286

Open gselzer opened 1 year ago

gselzer commented 1 year ago

In napari-imagej, we have use cases where you might transfer a Image layer to a Dataset, and then into an ImagePlus for use within the legacy ImageJ UI. This conversion will make use of ImagePlusToDatasetConverter to get that ImagePlus, registering the linking between the created ImagePlus and the original Dataset in the LegacyImageMap.

If you then process that ImagePlus, and attempt to convert it back into a Dataset, the original Dataset in the map gets returned without the changes made in the ImagePlus. The underlying data should be wrapped, but it is not updated before being returned. This results in the need for this HACK in napari-imagej. Ideally, the equivalent of ij.py.sync_image (imp.getStack().setPixels(imp.getProcessor().getPixels(), imp.getCurrentSlice())) would be placed within the ImagePlusToDatasetConverter.