[Insight-users] Simple file reader problem

Luis Ibanez luis.ibanez at kitware.com
Thu Sep 8 19:33:05 EDT 2005



Hi Chirs

If you want to process color images you should instantiate
the itk::Image over the pixel type RGBPixel.

You will find multiple examples on how to do this in the
ITK Software Guide


      http://www.itk.org/ItkSoftwareGuide.pdf


In particular in Section 4.1.5, in pdf-page 76, in the
"Data Representation" Chapter.

You will also find examples on how to read and write color
images in section 7.4 in pdf-page 295.



Otherwise, if you declare an ITK image of scalar type, your
color image will be converted to luminance when it is loaded
into the buffer of the scalar image.


Regards


     Luis


--------------------
Chris Farmer wrote:
> Ah, perfect!  
> 
> Thanks for the quick response.  This works nicely.  I've now lost the
> color information in my image, but that's just something else for me to
> discover how to control in itk.
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
> Sent: Thursday, September 08, 2005 4:10 PM
> To: Chris Farmer
> Cc: insight-users at itk.org
> Subject: Re: [Insight-users] Simple file reader problem
> 
> 
> Hi Chris,
> 
> Since you are not using CMake, you are probaly forgetting
> to enable the user of RTTI in your Visual C++ project.
> 
> Without RTTI enabled, the operations of dynamic_cast will fail.
> 
> 
> 
>     Regards,
> 
> 
>        Luis
> 
> 
> -------------------
> Chris Farmer wrote:
> 
>>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
>>
>>
>>
>>
>>
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
>>
>>
> 
> 
> 
> 



More information about the Insight-users mailing list