[Insight-users] reading a 2D series and writing it as a 3D image in TIFF

Luis Ibanez luis.ibanez at kitware.com
Mon Sep 15 17:44:59 EDT 2008


Hi Nadia,

Thanks for the clarification.

Yes, this means that the TIFFImageIO class is being used for
writing the file.


We checked on this today and the itk::TIFFImageIO class
can indeed write a 3D image in a single file by using the
multi-frame feature of the TIFF library.


At this point, the filenames generator will be the suspect.
Is there a chance that you can send me the three images
that you are trying to read as input ?


BTW: What are you using for looking at the output TIFF image ?


   Please let us know,


     Thanks


        Luis


-----------------
Nadia Alvi wrote:
> Hi,
>  
> Thanks again.
>  
> I tried that, and the console output is:
>  
> RTTI typeinfo : class itk:TIFFImageIO
>  
> That means it IS using the TIFFImageIO, right? but when i explicitly 
> specify the ImageIO, it writes the same slice multiple times.
>  
> do you have any clue of what can be wrong?
>  
> Thanks
>  
> Nadia
> 
> 
> --- On *Tue, 9/9/08, Luis Ibanez /<luis.ibanez at kitware.com>/* wrote:
> 
>     From: Luis Ibanez <luis.ibanez at kitware.com>
>     Subject: Re: [Insight-users] need help with my Code
>     To: nadiaalvi at yahoo.com
>     Date: Tuesday, September 9, 2008, 5:13 PM
> 
> Hi Nadia,
> 
> My mistake,
> 
> the line:
> 
>     writer->GetImageIO->Print( std::cout );
> 
> in my email, should have been:
> 
>     writer->GetImageIO()->Print( std::cout );
> 
> 
> My apologies for the mishap.
> 
> 
>     Luis
> 
> 
> ------------------
> Nadia Alvi wrote:
>> Thanks a lot Luis,
>>  
>> Sorry for replying you late.
>>  
>> By TIFF I mean sequence of 2d Image slices grouped togather as TIFF 
>> image. Is this what u meant by multiframe TIFF?
>>  
>> I tried the code to see what ImageIO it is using, but it is giving the 
>> compilation error as
>> (204): error C2227: left of '->Print' must point to
> class/struct/union
>>  
>> Could u please tell me what i am doing wrong?
>>  
>> many thanks
>>  
>> Nadia
>>  
>> 
>> --- On *Mon, 9/1/08, Luis Ibanez /<luis.ibanez at kitware.com>/* wrote:
>> 
>>     From: Luis Ibanez <luis.ibanez at kitware.com>
>>     Subject: Re: [Insight-users] need help with my Code
>>     To: nadiaalvi at yahoo.com
>>     Cc: insight-users at itk.org
>>     Date: Monday, September 1, 2008, 11:15 AM
>> 
>> Hi Nadia,
>> 
>> As far as I know, TIFF can't store 3D images.
>> 
>> I don't quite understand how the code can
>> generate a 3D TIFF image for you...
>> 
>> Are you talking about a multi-frame TIFF,... maybe ?
>> 
>> 
>> To figure out what ImageIO was used you can do the
>> following (of course, first remove the SetImageIO),
>> 
>> then,
>> 
>> after the call to
>> 
>>                writer->Update()
>> 
>> add the following call
>> 
>>     writer->GetImageIO->Print( std::cout );
>> 
>> The text that you will get in the console should
>> include the class name of he ImageIO that was
>> selected during the search of ImageIOFactories.
>> 
>> 
>> Please post that output to the list,
>> 
>> 
>>     Thanks
>> 
>> 
>>        Luis
>> 
>> 
>> 
>> -----------------
>> Nadia Alvi wrote:
>>> Hi Luis,
>>>  
>>> Thanks for your reply.
>>>  
>>> I am trying to read a sequence of three 2d tif images and write them
> as 
>>> one tiff file (with three slices). So that the output image would be
> one 
>>> tiff image with 3 slices.
>>>  
>>> This is the exactly the same thing that is explained in section 7.11.1
> 
>>> of ITKSoftwareGuide(i.e. Reading Image Series).
>>> I want to mention one interesting thing. While experimenting with the 
>>> code, when I removed the code line, reader1->SetImageIO( 
>>> itk::TIFFImageIO::New() ); , the code worked perfectly fine. Is this 
>>> because it is now using some other ImageIO?
>>>  
>>> I am really very thankful for any help.
>>>  
>>> Kind regards
>>> Nadia
>>> 
>>> 
>>> --- On *Sun, 8/31/08, Luis Ibanez /<luis.ibanez at kitware.com>/*
>> wrote:
>>> 
>>>     From: Luis Ibanez <luis.ibanez at kitware.com>
>>>     Subject: Re: [Insight-users] need help with my Code
>>>     To: nadiaalvi at yahoo.com
>>>     Cc: insight-users at itk.org
>>>     Date: Sunday, August 31, 2008, 10:04 AM
>>> 
>>> Hi Nadia,
>>> 
>>> 
>>>     The TIFF format doesn't support 3D images.
>>> 
>>> 
>>> Are you trying to write a 3D TIFF image ?
>>> 
>>> or
>>> 
>>> Are you trying to write 3 TIFF files each one with a 2D image ?
>>> 
>>> 
>>> Please let us know,
>>> 
>>> 
>>>     Thanks
>>> 
>>> 
>>>        Luis
>>> 
>>> 
>>> -----------------
>>> Nadia Alvi wrote:
>>>> 
>>>>     Hi All,
>>>>      
>>>>     Please see the code attached.
>>>>     It should read the 3 slices and write them as a tiff file but
> it
>>>>     only reads the 2nd slice and write it 3 times in a tiff file.
>>>>     Apparently it is incrementing the start index by 1 and reading
>> that
>>>>     slice 3 times.
>>>>     Can some body please help me in finding what i m doing wrong?
>>>>     Many many thanks
>>>>     Nadia
>>>>      
>>>>    
>>>
>>
> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>>>> 
>>>>     typedef unsigned char                       PixelType;
>>>>       const unsigned int Dimension = 3;
>>>>      
>>>>       typedef itk::Image< PixelType, Dimension >  ImageType;
>>>>      
>>>>       typedef itk::ImageSeriesReader< ImageType > 
> ReaderType;
>>>>       typedef itk::ImageFileWriter<ImageType> WriterType;
>>>> 
>>>>       WriterType::Pointer writer = WriterType::New();
>>>>       ReaderType::Pointer reader1 = ReaderType::New();
>>>>       typedef itk::NumericSeriesFileNames    NameGeneratorType;
>>>>       NameGeneratorType::Pointer nameGenerator =
>> NameGeneratorType::New();
>>>>       nameGenerator->SetSeriesFormat(
>>>>     "clint_binary_080320_noDescription%04d.tiff" );
>>>>       nameGenerator->SetStartIndex(1);
>>>>       nameGenerator->SetEndIndex(3);
>>>>       nameGenerator->SetIncrementIndex(1);
>>>> 
>>>>       reader1->SetImageIO( itk::TIFFImageIO::New() );
>>>>       reader1->SetFileNames( nameGenerator->GetFileNames() 
> );
>>>> 
>>>>       writer->SetFileName("labeledImage.tif");
>>>>       writer->SetInput(reader1->GetOutput());
>>>>       try
>>>>         {
>>>>       
>>>>       writer->Update();
>>>>         }
>>>> 
>>>> 
>>>> 
>>>> 
>>>>
>> ------------------------------------------------------------------------
>>>> 
>>>> _______________________________________________
>>>> Insight-users mailing list
>>>> Insight-users at itk.org
>>>> http://www.itk.org/mailman/listinfo/insight-users
>>> 
>>> 
>> 
>> 
> 
> 


More information about the Insight-users mailing list