[ome-users] Matlab JPEG2000 comments
Melissa Linkert
melissa at glencoesoftware.com
Mon Apr 27 21:44:39 BST 2015
Hi Mario,
> I'm coming back to a bit older thread here: reading JPEG2000 comments.
> Your solution implemented in 2012 works very nicely for me! However
> I've just found that in the code there is something that seems not
> 100% clean to me, and I have a small proposed fix. Here is the issue:
> JPEG2000MetadataParser.java invokes parseContiguousCodestream() twice,
> seemingly for the same position in the file. How that happens is beyond
> my understanding, but it will lead to a duplication of all comments in
> the internal list JPEG2000MetadataParser::ArrayList<String> comments.
> When feeding this list later into addGlobalMeta(key, value), it becomes
> unique, so the issue is never observed (and actually its not really an
> issue). But I think its not 100% clean to construct the non-unique list
> of comments in the first place, so I propose attached tiny fix. Its not
> as good as avoiding the double-reading in the first place, but I was
> unable to achieve that :-)
Thanks for bringing this up. Your patch certainly fixes the symptom,
but the underlying problem is that the parser state is not correctly set
after parseBoxes() returns. This causes most of the file to be parsed
twice, and should be fixed by:
http://github.com/openmicroscopy/bioformats/pull/1763
Regards,
-Melissa
On Sat, Apr 25, 2015 at 10:53:52AM +0200, Mario Emmenlauer wrote:
>
> Dear Melissa and all,
>
> I'm coming back to a bit older thread here: reading JPEG2000 comments.
> Your solution implemented in 2012 works very nicely for me! However
> I've just found that in the code there is something that seems not
> 100% clean to me, and I have a small proposed fix. Here is the issue:
> JPEG2000MetadataParser.java invokes parseContiguousCodestream() twice,
> seemingly for the same position in the file. How that happens is beyond
> my understanding, but it will lead to a duplication of all comments in
> the internal list JPEG2000MetadataParser::ArrayList<String> comments.
> When feeding this list later into addGlobalMeta(key, value), it becomes
> unique, so the issue is never observed (and actually its not really an
> issue). But I think its not 100% clean to construct the non-unique list
> of comments in the first place, so I propose attached tiny fix. Its not
> as good as avoiding the double-reading in the first place, but I was
> unable to achieve that :-)
>
> Let me know what you think?
>
> All the best,
>
> Mario
>
>
>
>
>
>
> On 13.09.2012 08:20, Mario Emmenlauer wrote:
> > On 08/28/2012 08:39 AM, Mario Emmenlauer wrote:
> >>
> >> Dear Melissa,
> >>
> >> thanks a lot for the very very quick and helpful response!
> >> I'll test the development build ASAP.
> >>
> >> Cheers,
> >>
> >> Mario
> >>
> >>
> >>
> >> On 08/27/2012 04:55 PM, Melissa Linkert wrote:
> >>> Hi Mario,
> >>>
> >>>> I'm trying to read comment fields from a lossless compressed JPEG200
> >>>> file, created with Matlab (R2011b, in case it matters). Matlab supports
> >>>> setting a list of arbitrary comments in the file, by specifying a cell
> >>>> array of strings as a parameter to imwrite().
> >>>> See http://www.mathworks.ch/help/techdoc/ref/imwrite.html#bsfqp3l-1.
> >>>>
> >>>> I'll send a corresponding image in a separate email. Is it possible
> >>>> to read the comment fields with BioFormats?
> >>>
> >>> Thank you for mentioning this, and for sending a file privately.
> >>>
> >>> This commit allows the comments to be read and stored in Bio-Formats'
> >>> original metadata hashtable:
> >>>
> >>> https://github.com/melissalinkert/bioformats/commit/eed5a864fb928511a84f9ec48376639b4431b49e
> >>>
> >>>
> >>>
> >>> A new development build with that fix should be available within a few
> >>> days, otherwise the upcoming 4.4.3 version of Bio-Formats will include
> >>> this fix.
> >>>
> >>> Regards,
> >>> -Melissa
> >>>
> >>> On Mon, Aug 27, 2012 at 01:54:09PM +0200, Mario Emmenlauer wrote:
> >>>>
> >>>> Dear OME Developers,
> >>>>
> >>>> I'm trying to read comment fields from a lossless compressed JPEG200
> >>>> file, created with Matlab (R2011b, in case it matters). Matlab supports
> >>>> setting a list of arbitrary comments in the file, by specifying a cell
> >>>> array of strings as a parameter to imwrite().
> >>>> See http://www.mathworks.ch/help/techdoc/ref/imwrite.html#bsfqp3l-1.
> >>>>
> >>>> I'll send a corresponding image in a separate email. Is it possible
> >>>> to read the comment fields with BioFormats?
> >>>>
> >>>> Thanks and all the best,
> >>>>
> >>>> Mario
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Mario Emmenlauer, Dipl.Inf. Office: +41-(0)61-26-72200
> >>>> Biozentrum Basel
> >>>> Klingelbergstrasse 50/70 mailto: mario.emmenlauer * unibas.ch
> >>>> CH-4056 Basel http://infectx.org/about_us/emmenlau/
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> ome-users mailing list
> >>>> ome-users at lists.openmicroscopy.org.uk
> >>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
> >>>
> >> _______________________________________________
> >> ome-users mailing list
> >> ome-users at lists.openmicroscopy.org.uk
> >> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
> >>
> > _______________________________________________
> > ome-users mailing list
> > ome-users at lists.openmicroscopy.org.uk
> > http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
> >
>
> --
> A: Yes.
> > Q: Are you sure?
> >> A: Because it reverses the logical flow of conversation.
> >>> Q: Why is top posting annoying in email?
>
> Mario Emmenlauer BioDataAnalysis Mobil: +49-(0)151-68108489
> Balanstrasse 43 mailto: mario.emmenlauer * unibas.ch
> D-81669 München http://www.biodataanalysis.de/
> diff --git a/components/formats-bsd/src/loci/formats/in/JPEG2000MetadataParser.java b/components/formats-bsd/src/loci/formats/in/JPEG2000MetadataParser.java
> index 232699b..8e17110 100644
> --- a/components/formats-bsd/src/loci/formats/in/JPEG2000MetadataParser.java
> +++ b/components/formats-bsd/src/loci/formats/in/JPEG2000MetadataParser.java
> @@ -34,6 +34,8 @@ package loci.formats.in;
>
> import java.io.IOException;
> import java.util.ArrayList;
> +import java.util.Set;
> +import java.util.LinkedHashSet;
>
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> @@ -362,6 +364,9 @@ public class JPEG2000MetadataParser {
> LOGGER.trace("Seeking to next segment marker at {}", nextPos);
> in.seek(nextPos);
> }
> + // remove duplicates from comments:
> + Set<String> commentset = new LinkedHashSet<String>(comments);
> + comments = new ArrayList(commentset);
> }
>
> /**
More information about the ome-users
mailing list