[Insight-users] Dimensions of an image

Luis Ibanez luis . ibanez at kitware . com
Wed, 07 Aug 2002 10:36:25 -0400


Hi Samuel,

I missed a point in my previos message,

As Julien pointed out, the Region has
two components:  Index and Size.

So instead of the code:
 >
 > RegionType  region1 = image->GetLargestPossibleRegion();
 > RegionType  region2 = image->GetBufferedRegion();
 > RegionType  region3 = image->GetRequestedRegion();
 >
 > const int width  = region2[0]; // first dimension
 > const int height = region2[1]; // second dimension
 > const int dept   = region2[2]; // third dimension
 >

you should do:

   typedef RegionType::SizeType  SizeType
   SizeType size1 = image->GetLargestPossibleRegion().GetSize();
   SizeType size2 = image->GetBufferedRegion().GetSize();
   SizeType size3 = image->GetRequestedRegion().GetSize();

   const int width  = size2[0]; // first dimension
   const int height = size2[1]; // second dimension
   const int dept   = size2[2]; // third dimension


GetIndex() returns a N-D array containing the position where
the region starts in the image. GetSize() returns a N-D array
containing the extension of the region on the image.

My apologies for the confusion,


    Luis


=======================================

Luis Ibanez wrote:
> 
> Hi Samuel,
> 
> ITK images use three types of regions that are size related.
> 
> This is done in order to support streaming (processing very
> large image by passing small pieces through the pipeline).
> 
> Please keep in mind also that ITK images are N-Dimensional,
> so sizes and positions are managed in generic N-D arrays.
> 
> The three regions in question are:
> 
> 1) LargestPossibleRegion (the actual total size of the image)
> 2) BufferedRegion (the size of the image currently in memory)
> 3) RequestedRegion (the size of the image to be processed by
>            a filter - this represent one of the small pieces)
> 
> 
> Regions are a class in itself that holds the size of an image
> region in N-D:
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageRegion.html
> 
> 
> For example, you can do for a 3D image:
> 
> typedef  itk::Image<char,3>   myImagerType;
> 
> myImageType::Pointer image = GetImageSomeHow();
> 
> typedef myImageType::RegionType  RegionType;
> 
> RegionType  region1 = image->GetLargestPossibleRegion();
> RegionType  region2 = image->GetBufferedRegion();
> RegionType  region3 = image->GetRequestedRegion();
> 
> const int width  = region2[0]; // first dimension
> const int height = region2[1]; // second dimension
> const int dept   = region2[2]; // third dimension
> 
> For small images, the values of region1, region2 and region3
> will probably be the same.
> 
> This is mostly a matter of concern if you are writing an
> ImageFilter but if you are just using an image that you
> instantiated and allocated by yourself, GetBufferedRegion()
> is probably the safest way to go.
> 
> A nice description of the Streaming concepts can be seen in:
> http://www.itk.org/Insight/Doxygen/html/StreamingPage.html
> 
> Further description of the ImageRegions is available in the
> InsightDocuments checkout under:
> 
>      InsightDocuments/Developer/General/itkImage.ppt
> 
> 
> 
> Please let us know if this helps to answer your question.
> 
> 
>   Thanks
> 
>     Luis
> 
> 
> 
> =================================================================
> 
> 
> Samuel Rodríguez Bescos wrote:
> 
>> Hello everybody,
>>
>>  
>>
>> does anybody know a way to get the size of  an image (width,height, 
>> etc..)?
>>
>>  
>>
>> Thanks in advance,
>>
>>  
>>
>> Samuel
>>
>>  
>>
> 
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>