[Insight-users] Size
Luis Ibanez
luis . ibanez at kitware . com
Wed, 17 Dec 2003 14:37:18 -0500
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.
>