[Insight-users] Simple file reader problem

Chris Farmer cfarmer at scitegic.com
Thu Sep 8 19:02:59 EDT 2005



Hi again.

I'm trying something which I think should be trivial, but I'm getting an
error that I can't seem to track down.  I'm trying to read an image from
a file using the ImageFileReader, then call Update() on the reader.  The
code is analogous to that in the Image2.cxx example:

typedef unsigned char          PixelType;
const unsigned int             Dimension = 2;
typedef itk::Image< PixelType, Dimension >   ImageType;
typedef itk::ImageFileReader< ImageType >  ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( "c:\\burger.PNG" );
reader->Update();

I added this code into an existing C++ project (Windows, VS.NET 2003)
that we've had around for a while.  I didn't use cmake since it was an
existing project.  I manually added the include file directories and
library files to the project.  I also added the defines that are present
in the Image2.vcproj file.  It builds fine.  This same code works
happily in the Image2 example.

When I try to run this in my application, it enters the Update() code,
then eventually goes down into ImageFileReader<TOutputImage,
ConvertPixelTraits>
::EnlargeOutputRequestedRegion(DataObject *output) in
itkimagefilereader.txx.  The first line in this method (line 257 in my
ITK 2.2 build) does a cast of the "output" DataObject* into a
TOutputImage::Pointer.  This cast fails in my application.  I'm having
trouble figuring out how output is different in my app versus Image2.

Can anyone suggest where I could be screwing this up?


Thanks,
Chris








More information about the Insight-users mailing list