imagej / imagej-server

A RESTful web server for ImageJ [EXPERIMENTAL]
Apache License 2.0
39 stars 17 forks source link

Conversion between image classes not working #15

Open PetrBainar opened 6 years ago

PetrBainar commented 6 years ago

Converting between various image classes like Dataset, ImageDisplay or DatasetView during module execution is not working properly. For example, when a Dataset object is provided, it is expected to be converted into an ImageDisplay or a DatasetView instance when needed.

However, this is not happening at the moment as ConvertService.convert(...) returns null.

ctrueden commented 6 years ago

@PetrBainar Did you have time to track this down? If not, I am happy to investigate it. Can you post a quick set of steps here to reproduce the issue?

PetrBainar commented 6 years ago

@ctrueden For example, the net.imagej.plugins.commands.rotate.FlipHorizontally Command requires an ImageDisplay object as an input, however the images are stored on the server as Dataset objects.

We did some investigation on this issue and it can easily be resolved by adding appropriate converters (e.g. from Dataset to ImageDisplay) to the project. However, the outputs resulting from the Command execution are not converted back so you might end up with multiple independent objects (e.g. Dataset and numerous DatasetView objects) corresponding to a single image.

We tried to store images as DatasetView objects immediately after upload and had better experience with this approach. Nevertheless, there might be some constrains we are not aware. What was the rationale for choosing Dataset as the type for storing images?

Wuyou98 commented 5 years ago

I had the same probelm, but I don't know where to add the converters, do you have any suggestions?

PetrBainar commented 5 years ago

I had the same probelm, but I don't know where to add the converters, do you have any suggestions?

A Converter should be discoverable by SciJava's ConvertService as long as it is decorated as the org.scijava.convert.Converter plugin. See a custom Converter added within this project here.

Wuyou98 commented 5 years ago

Thanks for your advice, it works!