[Insight-users] Get the number of components per pixel without reading image

Bill Lorensen bill.lorensen at gmail.com
Wed Nov 28 17:09:41 EST 2012


Something like this:
      typedef itk::Image<unsigned char, 3> ImageType;
      itk::ImageFileReader<ImageType>::Pointer imageReader =
        itk::ImageFileReader<ImageType>::New();
      imageReader->SetFileName(fileName.c_str());
      imageReader->UpdateOutputInformation();

      pixelType = imageReader->GetImageIO()->GetPixelType();
      componentType = imageReader->GetImageIO()->GetComponentType();


On Wed, Nov 28, 2012 at 5:00 PM, David Doria <daviddoria at gmail.com> wrote:
> Without reading the image, it is possible to determine some
> information about the image:
>
> e.g. the number of dimensions:
>
>   itk::ImageIOBase::Pointer imageIO =
>         itk::ImageIOFactory::CreateImageIO(
>             filename.c_str(), itk::ImageIOFactory::ReadMode);
>   return imageIO->GetNumberOfDimensions();
>
> I want to determine the number of components per pixel in the same
> manner (i.e. a normal RGB image would return 3). Is that possible? I
> didn't see any function name in ImageIOBase that indicated such a
> functionality.
>
> Thanks,
>
> David
> _____________________________________
> 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.php
>
> 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



-- 
Unpaid intern in BillsBasement at noware dot com


More information about the Insight-users mailing list