[Insight-users] Why I can't read vector image?

Sah Rayman sahrayman at yahoo.com
Thu, 5 Feb 2004 03:17:14 -0800 (PST)


Seems I could not read a vector image. I will post my
code below. Here is the result after I run the code:

vectread vectors.mhd
>(-4.31602e+008,-4.31602e+008)

The vector I read should be (0,0) but the result is
obviously something else.

Can someone help?

Thanks!

--------DATA FILE----------

The data file: vectors.mhd
ObjectType = Image
NDims = 2
BinaryData = True
BinaryDataByteOrderMSB = False
DimSize = 256 256
ElementNumberOfChannels = 2
ElementType = MET_FLOAT
ElementDataFile = vectors.raw

vectors.raw is a 524,288 byte all 0x00 raw file. 


------SOURCE CODE-----------
#include "itkImage.h"
#include "itkImageFileReader.h"

int main( int argc, char *argv[] ) {

const unsigned int    Dimension = 2;
typedef   float       InternalPixelType;
typedef
itk::Image<itk::CovariantVector<InternalPixelType,
Dimension>, Dimension> VectorImageType;

typedef  itk::ImageFileReader< VectorImageType >
VectorReaderType;

VectorReaderType::Pointer vectorImageReader =
VectorReaderType::New();

vectorImageReader->SetFileName( argv[1] );

try {
    vectorImageReader->Update();
} 
  catch( itk::ExceptionObject & excep )
{
    std::cerr << "Exception caught !" << std::endl;
    std::cerr << excep << std::endl;
}


VectorImageType::IndexType pixelIndex;
itk::CovariantVector<InternalPixelType, Dimension>  
pixelValue;

pixelIndex[0] = 0; pixelIndex[1] = 0;

vectorImageReader->Update();
pixelValue =
    vectorImageReader->GetOutput()->GetPixel(
pixelIndex );


std::cout << "(" << pixelValue[0] << "," <<
pixelValue[1] << ")" << std::endl;

return 0;
}

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html