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

Sah Rayman sahrayman at yahoo.com
Thu, 5 Feb 2004 18:48:15 -0800 (PST)


Sorry, this update is wrong. I messed up with my two
builds: renamed at one folder and ran at another.

So, when the raw file isn't there, it does return
error messages. 

But it still output (-4.31602e+008,-4.31602e+008) when
it should be (0,0)


--- Sah Rayman <sahrayman at yahoo.com> wrote:
> An update:
> 
> Seems my vectreader doesn't read the raw file at
> all.
> I just renamed my raw file and it just exit as
> normal
> with the same wrong output.
> 
> On the other hand, if I rename the mhd file, it will
> generate an exception error. 
> 
> --- Sah Rayman <sahrayman at yahoo.com> wrote:
> > 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
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Finance: Get your refund fast by filing
> online.
> http://taxes.yahoo.com/filing.html
> 


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