Login  Register

Re: roiencoder-decoder issue (different roi hashcode ) or just me?

Posted by feelc on Jul 01, 2015; 10:31pm
URL: http://imagej.273.s1.nabble.com/roiencoder-decoder-issue-different-roi-hashcode-or-just-me-tp5013390p5013392.html

Nice! Thanks a lot for the fast answer!

By the way, it would nice if Roi had a hashCode method  that is based on
the polygon and position.
I may have to implement it myself(as of need). I haven't found it in the
polygon class. Is it worth writing it or am I reinventing the wheel?

Thanks a  lot again!

Felipe

2015-07-02 0:04 GMT+02:00 Curtis Rueden <[hidden email]>:

> Hi Felipe,
>
> > Is the hashcode based only on the polygon and position or maybe also
> > in other variables lost or unrecovered in the encode-decode process?
>
> If you look at the source code [1], the Roi classes do not actually
> implement the hashCode() method (in fact, nothing whatsoever in ImageJ1
> does). So the Object implementation is inherited, which hashes on the
> object reference, meaning it will be different every time you create a new
> one (even if the coordinates etc. of the ROI are identical).
>
> It's true that Roi implements a different method called getHashCode() [2],
> but that does an XOR with hashCode(), so it will also differ every time in
> a similar way.
>
> Regards,
> Curtis
>
> [1]
> https://github.com/imagej/ImageJA/blob/v1.49v/src/main/java/ij/gui/Roi.java
> [2]
>
> https://github.com/imagej/ImageJA/blob/v1.49v/src/main/java/ij/gui/Roi.java#L1947-L1952
>
> On Wed, Jul 1, 2015 at 4:48 PM, Felipe Contreras <[hidden email]>
> wrote:
>
> > Hi!
> >
> > I'm not quite sure if I'm saving and recovering rois properly.
> > When I compare the roi hashcode from before and after saving it seems to
> > change.
> > Is the hashcode based only on the polygon and position or maybe also in
> > other variables lost or unrecovered in the encode-decode process?
> > Am I missing something?
> >
> > To save I use:
> >     RoiEncoder re = new RoiEncoder(roiPath);
> >     re.write(roi);
> >
> > To load I use:
> >     roi = RoiDecoder.open(roiPath);
> >
> >
> > Thanks a lot!
> >
> > Felipe
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html