[Insight-users] size of image

Luis Ibanez luis.ibanez at kitware.com
Sun May 29 14:37:28 EDT 2011


Hi John,

Please read the ITK Software Guide

    http://www.itk.org/ItkSoftwareGuide.pdf

In particular you will find the Image class explained
in Section 4.1 "Image" in pdf-page 67-80.


    Luis


-------------------------------------------------------------------------
On Sat, May 28, 2011 at 10:39 AM, john smith <mkitkinsightuser at gmail.com> wrote:
> Well, is  image  a pointer  showing in x,y,z dimension? How could I get the
> value for every dimension separately?
>
> Thanks for your response
>
> 2011/5/28 robert tamburo <robert.tamburo at gmail.com>
>>
>> image->GetLargestPossibleRegion().GetSize();   which is in your code:
>>   InputImageType::RegionType inputRegion =
>>            reader->GetOutput()->GetLargestPossibleRegion();
>>
>>   InputImageType::SizeType size = inputRegion.GetSize();
>>
>>
>> On Sat, May 28, 2011 at 10:30 AM, john smith <mkitkinsightuser at gmail.com>
>> wrote:
>>>
>>> Hello,
>>>
>>> I am using ITK for my project and I have wrote the following code.Could
>>> somebody tell me how can I get the size of my image?
>>>
>>> Thanks in advance
>>>
>>>  typedef unsigned char        InputPixelType;
>>>   typedef unsigned char        OutputPixelType;
>>>
>>>   typedef itk::Image< InputPixelType,  3 >    InputImageType;
>>>   typedef itk::Image< OutputPixelType, 2 >    OutputImageType;
>>>
>>>    typedef itk::ImageFileReader< InputImageType  >  ReaderType;
>>>   typedef itk::ImageFileWriter< OutputImageType >  WriterType;
>>>
>>>   ReaderType::Pointer reader = ReaderType::New();
>>>   WriterType::Pointer writer = WriterType::New();
>>>
>>>   reader->SetFileName( fileName.toStdString()  );
>>>   writer->SetFileName( "2D.png" );
>>>
>>>
>>>   typedef itk::ExtractImageFilter< InputImageType, OutputImageType >
>>> FilterType;
>>>   FilterType::Pointer filter = FilterType::New();
>>>
>>>     reader->Update();
>>>   InputImageType::RegionType inputRegion =
>>>            reader->GetOutput()->GetLargestPossibleRegion();
>>>
>>>   InputImageType::SizeType size = inputRegion.GetSize();
>>>   size[2] = 0;
>>>
>>>   InputImageType::IndexType start = inputRegion.GetIndex();
>>>   const unsigned int sliceNumber = 89;
>>>    start[2] = sliceNumber;
>>>
>>>   InputImageType::RegionType desiredRegion;
>>>   desiredRegion.SetSize( size );
>>>   desiredRegion.SetIndex( start );
>>>
>>>   filter->SetExtractionRegion( desiredRegion );
>>>
>>>   filter->SetInput( reader->GetOutput() );
>>>   writer->SetInput( filter->GetOutput() );
>>>
>>>       try
>>>     {
>>>     writer->Update();
>>>     }
>>>     catch( itk::ExceptionObject & err )
>>>     {
>>>     std::cerr << "ExceptionObject caught !" << std::endl;
>>>     std::cerr << err << std::endl;
>>>     }
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list