[Insight-users] Reading an mhd file with unknown pixel type

David Doria daviddoria at gmail.com
Wed Dec 1 12:05:14 EST 2010


On Wed, Dec 1, 2010 at 9:20 AM, Sergio Vera <sergio.vera at alma3d.com> wrote:
>> David
>> Based on some message on this mailing list that now I'm unable to find, we
>> use something like this.
>> I suppose it can be improved, but the code accomplishes the task of
>> determining the type of data before actually reading the data.
>> HTH

Looking into Sergio's suggestion, I am making an example here:
http://www.itk.org/Wiki/ITK/Examples/IO/ReadUnknownImageType

I am trying to read image4.mhd (Created with CreateImages.cxx at the
same link). It contains a

itk::Image< itk::CovariantVector<double, 4> , 2>

All of the below seems correct:

 const ScalarPixelType pixelType = imageIO->GetComponentType();
 std::cout << "Pixel Type is " <<
imageIO->GetComponentTypeAsString(pixelType) // 'double'
           << std::endl;
 const size_t numDimensions =  imageIO->GetNumberOfDimensions();
 std::cout << "numDimensions: " << numDimensions << std::endl; // '2'

 std::cout << "component size: " << imageIO->GetComponentSize() <<
std::endl; // '8'
 std::cout << "pixel type (string): " <<
imageIO->GetPixelTypeAsString(imageIO->GetPixelType()) << std::endl;
// 'vector'
 std::cout << "pixel type: " << imageIO->GetPixelType() << std::endl; // '5'

but I don't see any functions to tell me that the CovariantVectors
were length 4.

Any ideas how to discover that the type is

itk::Image<itk::CovariantVector<double, 4>, 2>

?

Thanks,

David


More information about the Insight-users mailing list