<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>I modified the VectorImageToImageAdaptor example to get this:</p>
<p><br>
</p>
<p>    typedef itk::RGBPixel<unsigned short> PixelType;<br>
    typedef itk::VectorImage<PixelType,2> ImageType_u16;<br>
    ImageType_u16::Pointer image;<br>
<br>
    typedef itk::ImageFileReader<ImageType_u16> ReaderType;<br>
    ReaderType::Pointer reader = ReaderType::New();<br>
    reader->SetFileName(filename);<br>
    reader->Update();<br>
    image = reader->GetOutput();<br>
<br>
    int width = image->GetLargestPossibleRegion().GetSize()[0];<br>
    int height = image->GetLargestPossibleRegion().GetSize()[1];<br>
    int depth = image->GetLargestPossibleRegion().GetSize()[2];<br>
    printf("Image dimensions: width, height: %d %d\n",width,height);<br>
    printf("NumberOfComponentsPerPixel: %d\n", image->GetNumberOfComponentsPerPixel());<br>
<br>
    typedef itk::VectorImageToImageAdaptor<PixelType, 2> ImageAdaptorType;<br>
    ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();<br>
    adaptor->SetExtractComponentIndex(0);<br>
    adaptor->SetImage(image);<br>
<br>
    itk::Index<2> index;<br>
    index[0] = 3084;<br>
    index[1] = 3072;<br>
  <br>
    std::cout << adaptor->GetPixel(index) << std::endl;<br>
</p>
<p><br>
</p>
<p>The size of the image is reported correctly (4656x4656) but although the number of components is shown as 4, GetPixel returns three values (2 0 0), at a location where I know (from ImageJ) that the green channel has a pixel value of more than 2000.<br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Richard Beare <richard.beare@gmail.com><br>
<b>Sent:</b> Wednesday, 13 December 2017 7:57 p.m.<br>
<b>To:</b> Gib Bogle<br>
<b>Cc:</b> Dženan Zukić; insight-users@itk.org<br>
<b>Subject:</b> Re: [ITK-users] [ITK] Getting info from a very big image file</font>
<div> </div>
</div>
<div>
<div dir="ltr">I guess there are a number of things you might want to check out.
<div>1) Viewers that can handle 16 bit colour channels in tiffs - my guesses would be itksnap, imageJ. Looks like you've succeeded with imageJ </div>
<div><br>
</div>
<div>2) Extracting a single channel - VectorImageToImageAdaptor</div>
<div><br>
</div>
<div>Can't see what is wrong with your code, but check the minimum as well, and also confirm the pixel type with tiffinfo - perhaps it is signed?</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Dec 13, 2017 at 4:46 PM, Gib Bogle <span dir="ltr">
<<a href="mailto:g.bogle@auckland.ac.nz" target="_blank">g.bogle@auckland.ac.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>I just needed to put "itk::" before RGBPixel.  I still don't know how to get the R, G and B channels.  Are they in separate buffers?<br>
</p>
<div dir="ltr" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<hr style="display:inline-block; width:98%">
<div id="m_-1997224593401290152divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Insight-users <<a href="mailto:insight-users-bounces@itk.org" target="_blank">insight-users-bounces@itk.org</a><wbr>>
 on behalf of Gib Bogle <<a href="mailto:g.bogle@auckland.ac.nz" target="_blank">g.bogle@auckland.ac.nz</a>><br>
<b>Sent:</b> Wednesday, 13 December 2017 5:57 p.m.<br>
<b>To:</b> Dženan Zukić<br>
<b>Cc:</b> <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br>
<b>Subject:</b> [FORGED] Re: [ITK-users] [ITK] Getting info from a very big image file</font>
<div> </div>
</div>
<div>
<p>Hi Dzenan,</p>
<p><br>
</p>
<p>I did:</p>
<p>#include "itkRGBPixel.h"</p>
<p>typedef RGBPixel<unsigned short> PixelType;<br>
<br>
but VS2010 tells me "Error: RGBPixel is not a template"</p>
<p><br>
</p>
<p>Cheers, Gib<br>
</p>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block; width:98%">
<div id="m_-1997224593401290152divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Dženan Zukić <<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>><br>
<b>Sent:</b> Wednesday, 13 December 2017 4:22 p.m.<br>
<b>To:</b> Gib Bogle<br>
<b>Cc:</b> Lowekamp, Bradley (NIH/NLM/LHC) [C]; Matt McCormick; <a href="mailto:insight-users@itk.org" target="_blank">
insight-users@itk.org</a><br>
<b>Subject:</b> Re: [ITK-users] [ITK] Getting info from a very big image file</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div class="gmail_default" style="font-family:verdana,sans-serif; font-size:small">
Why don't you try reading it with:</div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace">tyepdef RGBPixel<unsigned short> PixelType;</font></div>
<div class="gmail_default" style="font-family:verdana,sans-serif; font-size:small">
<br>
</div>
<div class="gmail_default" style="font-family:verdana,sans-serif; font-size:small">
Embedded thumbnails might be ignored by the reader, it is definitely worth a shot trying Brad's suggestion.</div>
<div class="gmail_default" style="font-family:verdana,sans-serif; font-size:small">
<br>
</div>
<div class="gmail_default" style="font-family:verdana,sans-serif; font-size:small">
Regards,</div>
<div class="gmail_default" style="font-family:verdana,sans-serif; font-size:small">
Dženan</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Dec 12, 2017 at 6:36 PM, Gib Bogle <span dir="ltr">
<<a href="mailto:g.bogle@auckland.ac.nz" target="_blank">g.bogle@auckland.ac.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
Thanks Brad.  The situation is complicated by the fact that there are 3 channels (three colours).  Tiffsplit is able to split the file into 396 127 MB TIFFs and 396 thumbnail TIFFs.  Irfanview can open one of the TIFFs, and it tells me that it is 4656x4656
 and 48 bitsperpixel.  That is, it contains 3 16-bit images of that size.  Nothing is displayed in Irfanview - I'm rather surprised that it could open it at all.<br>
 I'll try using that example, but the double complication of the included thumbnails and the 3 colours might stymie it.<br>
<br>
Cheers, Gib<br>
______________________________<wbr>__________<br>
From: Lowekamp, Bradley (NIH/NLM/LHC) [C] <<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>><br>
Sent: Wednesday, 13 December 2017 3:51 a.m.<br>
To: Matt McCormick; Gib Bogle<br>
Cc: <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br>
Subject: Re: [ITK] [ITK-users] Getting info from a very big image file<br>
<div class="m_-1997224593401290152m_-1055614905507965127m_7408767851529523760HOEnZb">
<div class="m_-1997224593401290152m_-1055614905507965127m_7408767851529523760h5">
<br>
Gib,<br>
<br>
I have not tested this, but the LSMImageIO is derived from the TIFFImageIO,  and LSMImageIO::Read does just call TIFFImageIO. So the chances are very good that it supports streamed reading.<br>
<br>
I updated the TIFFImageIO to support stream reading of the individual pages in the TIFF stack some time ago.<br>
<br>
You may find the following example useful to determining if the functionality is there:<br>
<a href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/IO/ImageReadExtractWrite.cxx" rel="noreferrer" target="_blank">https://github.com/InsightSoft<wbr>wareConsortium/ITK/blob/master<wbr>/Examples/IO/ImageReadExtractW<wbr>rite.cxx</a><br>
<br>
<br>
You can see the usage of “UpdateOutputInformation” followed by the ExtractImageFilter, this can be a very powerful and efficient pattern for working with large images. The ExtractImageFilter can be used to create a 3D to 2D image from it’s input volume.<br>
<br>
Brad<br>
<br>
<br>
On 12/11/17, 10:56 PM, "Matt McCormick" <<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>> wrote:<br>
<br>
    Hi Gib,<br>
<br>
    Call<br>
<br>
     reader->UpdateOutputInformati<wbr>on();<br>
<br>
    instead of<br>
<br>
      reader->Update();<br>
<br>
    to get the LargestPossibleRegion populated without loading the pixel buffer.<br>
<br>
<br>
    The image IO has to support streaming to read in only a<br>
    RequestedRegion -- unfortunately, I do not think the LSMImageIO<br>
    supports this at this time.<br>
<br>
    HTH,<br>
    Matt<br>
<br>
    On Mon, Dec 11, 2017 at 10:44 PM, Gib Bogle <<a href="mailto:g.bogle@auckland.ac.nz" target="_blank">g.bogle@auckland.ac.nz</a>> wrote:<br>
    > Hello,<br>
    ><br>
    ><br>
    > I am wanting to work with a 50 GB LSM file (3D).  The first step is to be<br>
    > able to get the image info: width, height and depth.  I have code that works<br>
    > on a small LSM file<br>
    ><br>
    ><br>
    >     im_u16 = reader->GetOutput();<br>
    >     width = im_u16->GetLargestPossibleRegi<wbr>on().GetSize()[0];<br>
    >     height = im_u16->GetLargestPossibleRegi<wbr>on().GetSize()[1];<br>
    >     depth = im_u16->GetLargestPossibleRegi<wbr>on().GetSize()[2];<br>
    ><br>
    ><br>
    > but I see that to do this the whole image must be loaded into memory.  When<br>
    > I start the program running with the big file I can see that it is going to<br>
    > exceed the host machine's 32 GB.  Is there a way to get the image dimensions<br>
    > without loading the whole image?  What I am hoping to do is split the file<br>
    > into 2D TIFF files - is there any way to extract a 2D slice without reading<br>
    > the whole image?  Or will I be forced to run on a  machine with more than 50<br>
    > GB of RAM?<br>
    ><br>
    ><br>
    > Thanks in advance for any suggestions.<br>
    ><br>
    ><br>
    > Best regards<br>
    ><br>
    > Gib<br>
    ><br>
    ><br>
    > The ITK community is transitioning from this mailing list to<br>
    > <a href="http://discourse.itk.org" rel="noreferrer" target="_blank">discourse.itk.org</a>. Please join us there!<br>
    > ______________________________<wbr>__<br>
    > Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">
www.kitware.com</a><br>
    ><br>
    > Visit other Kitware open-source projects at<br>
    > <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">
http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
    ><br>
    > Kitware offers ITK Training Courses, for more information visit:<br>
    > <a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">
http://www.kitware.com/product<wbr>s/protraining.php</a><br>
    ><br>
    > Please keep messages on-topic and check the ITK FAQ at:<br>
    > <a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">
http://www.itk.org/Wiki/ITK_FA<wbr>Q</a><br>
    ><br>
    > Follow this link to subscribe/unsubscribe:<br>
    > <a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">
http://public.kitware.com/mail<wbr>man/listinfo/insight-users</a><br>
    ><br>
    The ITK community is transitioning from this mailing list to <a href="http://discourse.itk.org" rel="noreferrer" target="_blank">
discourse.itk.org</a>. Please join us there!<br>
    ______________________________<wbr>__<br>
    Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">
www.kitware.com</a><br>
<br>
    Visit other Kitware open-source projects at<br>
    <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">
http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
    Kitware offers ITK Training Courses, for more information visit:<br>
    <a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">
http://www.kitware.com/product<wbr>s/protraining.php</a><br>
<br>
    Please keep messages on-topic and check the ITK FAQ at:<br>
    <a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FA<wbr>Q</a><br>
<br>
    Follow this link to subscribe/unsubscribe:<br>
    <a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">
http://public.kitware.com/mail<wbr>man/listinfo/insight-users</a><br>
    The ITK community is transitioning from this mailing list to <a href="http://discourse.itk.org" rel="noreferrer" target="_blank">
discourse.itk.org</a>. Please join us there!<br>
    ______________________________<wbr>__________<br>
    Community mailing list<br>
    <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
    <a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">
http://public.kitware.com/mail<wbr>man/listinfo/community</a><br>
<br>
<br>
The ITK community is transitioning from this mailing list to <a href="http://discourse.itk.org" rel="noreferrer" target="_blank">
discourse.itk.org</a>. Please join us there!<br>
______________________________<wbr>__<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/product<wbr>s/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FA<wbr>Q</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/insight-users</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
The ITK community is transitioning from this mailing list to <a href="http://discourse.itk.org" rel="noreferrer" target="_blank">
discourse.itk.org</a>. Please join us there!<br>
______________________________<wbr>__<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</body>
</html>