Page 1 of 2

Reading Canon cr2

PostPosted: Thu Mar 15, 2012 2:52 pm
by kinor
Hi all,

i try to read a canon cr2 acquired with a Mark II in Matlab. This is the error i get:
Code: Select all
im = bfopen(aFile);
Reading IFDs

Populating metadata

??? Java exception occurred:
loci.common.enumeration.EnumException: Unable to find TiffCompresssion with code: 6

   at loci.formats.tiff.TiffCompression.get(TiffCompression.java:207)

   at loci.formats.tiff.IFD.getCompression(IFD.java:647)

   at loci.formats.in.MinimalTiffReader.initFile(MinimalTiffReader.java:404)

   at loci.formats.in.BaseTiffReader.initFile(BaseTiffReader.java:501)

   at loci.formats.FormatReader.setId(FormatReader.java:1072)

   at loci.formats.DelegateReader.setId(DelegateReader.java:232)

   at loci.formats.ImageReader.setId(ImageReader.java:677)

   at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:488)

   at loci.formats.ChannelFiller.setId(ChannelFiller.java:249)

   at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:488)

   at loci.formats.ChannelSeparator.setId(ChannelSeparator.java:257)


Error in ==> bfopen at 138
r.setId(id);


just to check i read a jpg which worked fine.

Any idea how to fix it?
Has anyone read cr2 data in Matlab with bio-formats

Thanks for any hint
Best
Norbert

Re: Reading Canon cr2

PostPosted: Fri Mar 16, 2012 1:27 am
by mlinkert
Hi Norbert,


i try to read a canon cr2 acquired with a Mark II in Matlab. This is the error i get:

Code: Select all
im = bfopen(aFile);
Reading IFDs

Populating metadata

??? Java exception occurred:
loci.common.enumeration.EnumException: Unable to find TiffCompresssion with code: 6

   at loci.formats.tiff.TiffCompression.get(TiffCompression.java:207)

   at loci.formats.tiff.IFD.getCompression(IFD.java:647)

   at loci.formats.in.MinimalTiffReader.initFile(MinimalTiffReader.java:404)

   at loci.formats.in.BaseTiffReader.initFile(BaseTiffReader.java:501)

   at loci.formats.FormatReader.setId(FormatReader.java:1072)

   at loci.formats.DelegateReader.setId(DelegateReader.java:232)

   at loci.formats.ImageReader.setId(ImageReader.java:677)

   at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:488)

   at loci.formats.ChannelFiller.setId(ChannelFiller.java:249)

   at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:488)

   at loci.formats.ChannelSeparator.setId(ChannelSeparator.java:257)


Error in ==> bfopen at 138
r.setId(id);


just to check i read a jpg which worked fine.

Any idea how to fix it?
Has anyone read cr2 data in Matlab with bio-formats


If possible, it would be very helpful if you could send one of the files that produces this error. I have a vague idea of how to solve the problem (it is a limitation in Bio-Formats, and will require some fixes), but without seeing the file it will be difficult to say for certain that the fixes are correct.

If you need a place to upload a file, please let me know and I will send you our SFTP server information privately.

Regards,
-Melissa

Re: Reading Canon cr2

PostPosted: Fri Mar 16, 2012 9:23 am
by kinor
Hi Melissa,

thank you very much for your reply,

here is the file:

https://www.yousendit.com/dl?phi_action ... TVZ4Tk1UQw

Best regards
Norbert

Re: Reading Canon cr2

PostPosted: Fri Mar 16, 2012 6:30 pm
by mlinkert
Hi Norbert,

Thank you for providing a file. We have now implemented a fix, as shown here:

https://github.com/melissalinkert/biofo ... 6c3fa1fd1e

A new build containing the fix will be available within a few weeks.

Regards,
-Melissa

Re: Reading Canon cr2

PostPosted: Mon Mar 19, 2012 10:15 am
by kinor
Hi Melissa,

thank you very much for your help and have a nice week.

Best regards
Norbert

Re: Reading Canon cr2

PostPosted: Mon Apr 09, 2012 5:08 pm
by mlinkert
Hi Norbert,

The very latest build of Bio-Formats:

http://hudson.openmicroscopy.org.uk/vie ... _tools.jar

should allow this file to open correctly.

If you still see an error after updating, please let us know.

Regards,
-Melissa

Re: Reading Canon cr2

PostPosted: Fri Apr 13, 2012 2:08 pm
by kinor
Hi Melissa,

thank you very much, i tried the new version but i received an out of memory message which is surprising as the file has about 23MB
and the memory command gives me:

>> memory
Maximum possible array: 686 MB (7.192e+008 bytes) *
Memory available for all arrays: 1423 MB (1.492e+009 bytes) **

the error message:

aFile = 'O:\Pouches\Norbert\testbild_TIFF_JPG\2013_03_08_0808.CR2';im = bfopen(aFile);
Reading IFDs

Populating metadata

Populating OME metadata

Reading series #1
.??? Java exception occurred:
java.lang.OutOfMemoryError: Java heap space

at
loci.formats.tiff.TiffParser.getSamples(TiffParser.java:794)

at
loci.formats.tiff.TiffParser.getSamples(TiffParser.java:669)

at
loci.formats.in.MinimalTiffReader.openBytes(MinimalTiffReader.java:275)

at
loci.formats.in.DNGReader.openBytes(DNGReader.java:126)

at
loci.formats.ImageReader.openBytes(ImageReader.java:401)

at
loci.formats.ChannelFiller.openBytes(ChannelFiller.java:184)

at
loci.formats.ChannelFiller.openBytes(ChannelFiller.java:176)

at
loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:184)

at
loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:146)

at
loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:130)


Error in ==> bfopen at 160
plane = r.openBytes(i - 1);


is my usage wrong?

Regards
Norbert

Re: Reading Canon cr2

PostPosted: Fri Apr 13, 2012 5:29 pm
by mlinkert
While the file in question is only 23 MB, storing the uncompressed image in memory requires ~60 MB available (as the image is 5616 x 3744, RGB).

You are likely seeing this message because MATLAB allocates a very small amount of memory to Java by default (often 64 MB). Please try increasing the amount of memory that MATLAB allocates to Java as instructed here:

http://www.mathworks.com/support/soluti ... a/1-18I2C/

I would suggest allowing at least 256 MB, and preferably 512 MB (or higher).

Re: Reading Canon cr2

PostPosted: Mon Apr 16, 2012 11:59 am
by kinor
Hi Melissa,

thank you very much for your help, the reading works fine now. I changed from 128MB to 512..

But unfortunately only 8 Bit data is read. I expected 16 bit data.

im{1}

ans =

[3744x5616 uint8] [1x74 char]
[3744x5616 uint8] [1x74 char]
[3744x5616 uint8] [1x74 char]

This also occurs in other cr2 files from another camera.
Is this usual for the bioformat library or is it capable of reading 16 bit data?
Conversion with Rawtherapy gives 16 bit on the same file.

Best regards
Norbert

Re: Reading Canon cr2

PostPosted: Tue Apr 17, 2012 3:48 pm
by mlinkert
But unfortunately only 8 Bit data is read. I expected 16 bit data.

im{1}

ans =

[3744x5616 uint8] [1x74 char]
[3744x5616 uint8] [1x74 char]
[3744x5616 uint8] [1x74 char]

This also occurs in other cr2 files from another camera.
Is this usual for the bioformat library or is it capable of reading 16 bit data?


As far as I can tell, this file really does contain 8-bit data. If it did contain 16-bit data, then Bio-Formats would handle it as such.

Conversion with Rawtherapy gives 16 bit on the same file.


How exactly are you performing the conversion in Rawtherapee? From what I can tell, you are able to choose the format (JPEG, TIFF, or PNG) and bit depth (8 of 16) of the output file, which is entirely independent of what the input file's bit depth was. In other words, if you had picked a bit depth of 16, then the output file will always have 16 bits per pixel, with 8-bit input data simply rescaled to fill the extra space.