<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am currently working on a Java project that uses the OpenSlide library to visualize large tiled pyramidal TIFF files. However, the image files that we are currently working with are single-layered full resolution TIFF images, which is
not a compatible format with OpenSlide. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">We are able to successfully convert these single-layered TIFF images into tiled pyramidal TIFF images that are compatible with OpenSlide by using ImageMagick’s “convert” command line tool.
<o:p></o:p></p>
<p class="MsoNormal">i.e.)<o:p></o:p></p>
<pre style="mso-margin-top-alt:12.0pt;margin-right:12.0pt;margin-bottom:12.0pt;margin-left:0in;background:#EEEEEE"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""> </span><span style="font-size:10.5pt;color:#02171D">convert image.tif -define tiff:tile-geometry=256x256 -compress jpeg 'ptif:newimage.tif'<o:p></o:p></span></pre>
<p class="MsoNormal">After using this command to convert our single layerd TIFF into a pyramidal TIFF, OpenSlide works perfectly with the resulting image.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">A problem arises because we wish to have everything implemented in Java without having to explicitly use the command line to convert these images into tiled pyramidal TIFFs. ImageMagick has a Java API called Im4java that acts as a Java
interface to the ImageMagick command-line. Theoretically, running a convert operation through im4Java should mimic the “convert” command line utility of ImageMagick. Unfortunately this is not the case.<span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none">Here is the sample code from the project that converts an image to a tiled pyramidal tiff using the im4java library:<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black"> IMOperation convert =
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">new</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black"> IMOperation();
</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black"> ConvertCmd cmd =
</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">new</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black"> ConvertCmd(</span><b><span style="font-size:10.0pt;font-family:Consolas;color:#7F0055">true</span></b><span style="font-size:10.0pt;font-family:Consolas;color:black">);
</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black"> convert.addImage(tempFile.getAbsolutePath());</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black"> convert.define(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"tiff:tile-geometry=256x256"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black"> convert.define(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"tiff:rows-per-strip=16"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black"> convert.compress(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"jpeg"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black"> convert.addImage(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"'ptif:"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">+result.getAbsolutePath()+</span><span style="font-size:10.0pt;font-family:Consolas;color:#2A00FF">"'"</span><span style="font-size:10.0pt;font-family:Consolas;color:black">);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black"> cmd.run(convert);</span><span style="font-size:10.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Consolas;color:black">
</span><b><span style="color:#1F497D"><o:p></o:p></span></b></p>
<p class="MsoNormal">When we convert an image into a pyramidal TIFF using the im4java API, OpenSlide only recognizes the full-resolution layer of the image (Layer 0). OpenSlide can still open and visualize the image, but it is very laggy when scrolling and
zooming because the pyramid functionality is lost. But if we use ImageMagick’s “identify” tool, it reveals that other layers do exist within the image:<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">$ identify JavaResult.tif<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[0] TIFF 17314x22842 17314x22842+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.002<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[1] TIFF 8657x11421 8657x11421+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.006<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[2] TIFF 4328x5710 4328x5710+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.006<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[3] TIFF 2164x2855 2164x2855+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.006<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[4] TIFF 1082x1427 1082x1427+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.007<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[5] TIFF 541x713 541x713+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.007<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[6] TIFF 270x356 270x356+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.007<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[7] TIFF 135x178 135x178+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.007<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[8] TIFF 67x89 67x89+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.007<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">JavaResult.tif[9] TIFF 33x44 33x44+0+0 8-bit Grayscale DirectClass 8.988MB 0.000u 0:00.007<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><i><span style="font-size:9.0pt;font-family:"Lucida Console""><o:p> </o:p></span></i></p>
<p class="MsoNormal" style="text-autospace:none"><i>*JavaResult.tif is the image created using im4java’s convert operation through java<o:p></o:p></i></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none">As you can see, the layers that are created are very similar to the layers created in the image converted through ImageMagick’s “convert” command line utility:<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">$ identify ImageMagickResult.tif<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[0] TIFF 17314x22842 17314x22842+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.003<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[1] TIFF 8657x11421 8657x11421+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.003<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[2] TIFF 4328x5710 4328x5710+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.003<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[3] TIFF 2164x2855 2164x2855+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.004<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[4] TIFF 1082x1427 1082x1427+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.004<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[5] TIFF 541x713 541x713+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.004<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[6] TIFF 270x356 270x356+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.003<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[7] TIFF 135x178 135x178+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.004<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[8] TIFF 67x89 67x89+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.004<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console"">ImageMagickResult.tif[9] TIFF 33x44 33x44+0+0 8-bit Grayscale DirectClass 9.013MB 0.000u 0:00.004<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><i><o:p> </o:p></i></p>
<p class="MsoNormal" style="text-autospace:none"><i>*ImageMagickResult.tif is the image created through the convert command line tool<o:p></o:p></i></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none">Identify also has a –verbose flag that displays detailed information about an image file. When using diff to compare the 2 text files created from “identify –verbose” we found a few differences between the formatting
of the 2 images. For example, “tiff:rows-per-strip:16” exists in ImageMagickResult.tif but not in JavaResult.tif. There are also discrepancies between the resolution and print size between each layer of the images.
<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none">If possible, could someone take a deeper look into the attached files that I copied over from the “Identify –verbose” command for each of the images? I would like to know specifically why OpenSlide has trouble
recognizing the rest of the layers of an image created through im4java’s convert operation<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none">You could download the initial TIFF image that I used for testing as well as the TIFF files created through both conversions over here:<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span style="color:#1F497D"><a href="http://bluegrit.cs.umbc.edu/~tblatt1/tiff_images.tar.gz">http://bluegrit.cs.umbc.edu/~tblatt1/tiff_images.tar.gz</a><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><b>Disclaimer: Please do not distribute the TIFF files or the attached text files.
<o:p></o:p></b></p>
<p class="MsoNormal" style="text-autospace:none"><b><o:p> </o:p></b></p>
<p class="MsoNormal" style="text-autospace:none"><b><o:p> </o:p></b></p>
<p class="MsoNormal" style="text-autospace:none">Regards,<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none">Timothy Kim<i><o:p></o:p></i></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt;font-family:"Lucida Console""><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>