Re: ImagePlus Serializable

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: ImagePlus Serializable

Václav Uher
Hi,
I wonder if support for serialization can be added to ImagePlus class and
ImageProcessor interface and other included classes? ROI is already
serializable. If yes, in which version could I expect that. If no, can you
write me reason who?

Best
Vaclav Uher

>
Reply | Threaded
Open this post in threaded view
|

Re: ImagePlus Serializable

Rasband, Wayne (NIH/NIMH) [E]
On Jan 17, 2012, at 8:04 AM, Václav Uher wrote:

> Hi,
> I wonder if support for serialization can be added to ImagePlus class and
> ImageProcessor interface and other included classes? ROI is already
> serializable. If yes, in which version could I expect that. If no, can you
> write me reason who?

Use the FileSaver.serialize() and Opener.deserialize() methods for serialization of ImagePlus classes. Here is a JavaScript example:

   imp = IJ.getImage();
   bytes = new FileSaver(imp).serialize();
   imp2 = new Opener().deserialize(bytes);
   imp2.show();

These methods are available in ImageJ 1.45m or later.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: ImagePlus Serializable

Václav Uher
Hi Wayne,
thank you for your quick answer.
Problem is that I use ImageJ in plug-in for RapidMiner for image
processing<http://spl.utko.feec.vutbr.cz/en/component/content/article/21-zpracovani-medicinskych-signalu/46-image-processing-extension-for-rapidminer-5>.
So much easer will be, if ImagePlus support serializable. And I think I'm
not the only one who will appreciate it.

Best,
Vaclav

2012/1/17 Rasband, Wayne (NIH/NIMH) [E] <[hidden email]>

> On Jan 17, 2012, at 8:04 AM, Václav Uher wrote:
>
> > Hi,
> > I wonder if support for serialization can be added to ImagePlus class and
> > ImageProcessor interface and other included classes? ROI is already
> > serializable. If yes, in which version could I expect that. If no, can
> you
> > write me reason who?
>
> Use the FileSaver.serialize() and Opener.deserialize() methods for
> serialization of ImagePlus classes. Here is a JavaScript example:
>
>   imp = IJ.getImage();
>   bytes = new FileSaver(imp).serialize();
>   imp2 = new Opener().deserialize(bytes);
>   imp2.show();
>
> These methods are available in ImageJ 1.45m or later.
>
> -wayne
>
Reply | Threaded
Open this post in threaded view
|

Re: ImagePlus Serializable

dscho
Hi Václav,

On Tue, 17 Jan 2012, Václav Uher wrote:

> Problem is that I use ImageJ in plug-in for RapidMiner for image
> processing<http://spl.utko.feec.vutbr.cz/en/component/content/article/21-zpracovani-medicinskych-signalu/46-image-processing-extension-for-rapidminer-5>.
> So much easer will be, if ImagePlus support serializable. And I think I'm
> not the only one who will appreciate it.

The ImagePlus instances have much more information in them than just the
pixels and (some) metadata. For example, they know fully well in which
ImageWindow they are displayed. Likewise, the image _ID_ is also part of
the ImagePlus class. To serialize this properly would involve a lot more
work, and it is highly doubtful that you actually want that.

Instead, if you want to save an image for later retrieval, use image I/O
as suggested before. It is not much effort, and it is the correct thing to
do anyway since you really do not want to reinstantiate the same object
but only the same image.

Hth,
Johannes
Reply | Threaded
Open this post in threaded view
|

Re: ImagePlus Serializable

dscho
Hi,

[Cc:ing the list again, since I don't think that Open Source should be
discussed privately.]

On Wed, 18 Jan 2012, Václav Uher wrote:

> thank you for answer. I think add "implements java.io.Serializable" to each
> interface and superclass is not much work. Or miss I something? I can do it
> for you, if you want.

Unfortunately, the ease of doing it does not outweigh the problem I
detailed in my answer: it would be conceptually wrong unless you do much
more than label the classes Serializable.

Hth,
Johannes