[Insight-users] Size : Errata
Luis Ibanez
luis . ibanez at kitware . com
Wed, 17 Dec 2003 14:41:39 -0500
Hi David,
The previous email has an error in the example code.
The line:
const SizeType size =
image->GetLargestPossibleRegion();
should be:
const SizeType size =
image->GetLargestPossibleRegion().GetSize();
Sorry,
Luis
---------------------------------------
Luis Ibanez wrote:
>
> Hi David,
>
> The size of an image is an array of numbers.
> A 3D image need an array of three numbers
> for describing its size.
>
> You should use the "SizeType" defined as
> part of the itk::Image type.
>
> Something like:
>
> typedef itk::RGBPixel< char > PixelType;
> typedef itk::Image< PixelType, 3 > ImageType;
> typedef ImageType::SizeType SizeType;
>
> typedef itk::ImageFileReader<
> ImageType > ReaderType;
>
> ReaderType::Pointer reader = ReaderType::New();
>
> reader->SetFileName("image.hdr");
> reader->Update();
>
> ImageType::ConstPointer image = reader->GetOutput();
>
> const SizeType size = image->GetLargestPossibleRegion();
>
>
> // At this point you can access the element of the
> // size array.
>
>
> std::cout << "Pixels in X = " << size[0] << std::enl;
> std::cout << "Pixels in Y = " << size[1] << std::enl;
> std::cout << "Pixels in Z = " << size[2] << std::enl;
>
>
>
> Regards,
>
>
> Luis
>
>
> ----------------------------------
> David Llanos wrote:
>
>> hi all,
>>
>> In the first place I request you help in this simple problem: I want
>> to get the size of a 2D RGB image, already read with ImageFileReader
>> and kept in the pointer "reader", for later to keep it in a constant
>> variable.
>>
>> I attempted something like that, but I don't know the classes of
>> ImageFileReader exactly
>>
>> const unsigned long tam=0;
>> tam=reader->GetOutput()->GetRequestedRegion().GetSize();
>>
>>
>
> ...
>
>> thanks in advange.
>>
>
>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>