Hi Roger & everyone,<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>This logic was added to getStripByteCounts() in commit 0599079, but for<br>


all compressed formats, and was switched to LZW-only as above in<br>bf1dcbe9.  I'm not sure what makes LZW special here compared with the<br>other compression formats.</blockquote><div><br></div><div>Actually, the change from "!= UNCOMPRESSED" to "== LZW" was made in commit df21380b:</div>


<div><br></div><div>The commit message is:</div><div><div>"Only double StripByteCounts values if the strips are compressed with LZW.  Fixes #368."</div></div><div><br></div><div>That bug can be viewed here:</div>


<div><a href="http://dev.loci.wisc.edu/trac/software/ticket/368" target="_blank">http://dev.loci.wisc.edu/trac/software/ticket/368</a></div><div><br></div><div>HTH,</div><div>Curtis</div><div><br></div><div><div><br><div class="gmail_quote">


On Mon, Sep 10, 2012 at 7:03 AM, Roger Leigh <span dir="ltr"><<a href="mailto:r.leigh@dundee.ac.uk" target="_blank">r.leigh@dundee.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>On 07/09/2012 16:31, Matthias Baldauf wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
I am using the Bio-Formats Java library (trunk build) to write an<br>
OME-TIFF sequentially strip per strip.<br>
It is basically the same approach I mentioned in a previous post<br>
(<a href="http://lists.openmicroscopy.org.uk/pipermail/ome-users/2012-August/003178.html" target="_blank">http://lists.openmicroscopy.<u></u>org.uk/pipermail/ome-users/<u></u>2012-August/003178.html</a>),<br>
but now I am reading the JPEG in stripes and store them strip per strip<br>
in an OME-TIFF. It works great for striped uncompressed OME-TIFFs.<br>
<br>
However, when using LZW compression, it nearly ever results in an<br>
OME-TIFF which cannot be opened.<br>
To locate the error I analyzed the IFD of the TIFF and observed that the<br></div>
tag 'StripByteCounts' doesn’t contain valid values.<div><br>
In the case when there are just a few stripes in the OME-TIFF, the<br>
values of 'StripByteCounts' are too large, even exceeding the number of<br>
bytes when the strip would be uncompressed.<br>
In the case when there are more stripes in the OME-TIFF, the values of<br>
'StripByteCounts' are zero.<br>
So I had a look at the IFD-class in the loci.formats.tiff package an<br>
encountered the following lines in the getStripByteCounts() method:<br>
<br>
     if (getCompression() == TiffCompression.LZW) {<br>
       for (int i=0; i<byteCounts.length; i++) {<br>
         counts[i] = byteCounts[i] * 2;<br>
       }<br>
     }<br>
<br>
I removed the multiplication (* 2) and it seems to solve the error with<br>
the wrong values of 'StripByteCounts'.<br>
The OME-TIFFs can be opened now (even containing many stripes).<br>
The multiplication increases the values of 'StripByteCounts' every time<br>
a strip gets stored in the OME-TIFF.<br>
This would explain the very large numbers and, when more strips are<br>
added, the zeros because of an overflow.<br>
</div></blockquote>
<br>
Just to add a small additional bit of data:<br>
<br>
This logic was added to getStripByteCounts() in commit 0599079, but for<br>
all compressed formats, and was switched to LZW-only as above in<br>
bf1dcbe9.  I'm not sure what makes LZW special here compared with the<br>
other compression formats.<br>
<br>
<br>
Regards,<br>
Roger<br>
<br>
--<br>
Dr Roger Leigh -- Open Microscopy Environment<br>
Wellcome Trust Centre for Gene Regulation and Expression,<br>
College of Life Sciences, University of Dundee, Dow Street,<br>
Dundee DD1 5EH Scotland UK   Tel: (01382) 386364<br>
<br>
The University of Dundee is a registered Scottish Charity, No: SC015096<br>
<br>
______________________________<u></u>_________________<br>
ome-users mailing list<br>
<a href="mailto:ome-users@lists.openmicroscopy.org.uk" target="_blank">ome-users@lists.<u></u>openmicroscopy.org.uk</a><br>
<a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users" target="_blank">http://lists.openmicroscopy.<u></u>org.uk/mailman/listinfo/ome-<u></u>users</a><br>
</blockquote></div><br></div></div>