[Insight-users] Can't see result imae from ImageReadWrite

Gib Bogle g.bogle at auckland.ac.nz
Fri Feb 25 03:51:09 EST 2011


Hi Ella,

I wonder if that could be an issue of file formats supported by ITK, although 
I'd expect to see an ITK error message.  The code works for me, anyway.

Have you tried building it as I did?  Mind you, I'm using Visual Studio 8 2005.

Gib

On 25/02/2011 8:20 p.m., Ella Maria Kadas wrote:
> Hi Gib,
>
> I managed to build ITK, VTK, and run the ImageReadWrite.cxx.
> It seems that the folder structure suggested by John Drescher worked for me.
> I still get a First-chance exception at 0x7c812afb in ImageReadWrite.exe:
> Microsoft C++ exception: itk::ExceptionObject at memory location 0x0137f6b8..
> The program '[3412] ImageReadWrite.exe: Native' has exited with code 1 (0x1).
> I googled it and it seems to be a a notification to the debugger so it can stop
> the program.
> But i still can't see the result image. My image is a gray scale jpeg 164x120
> Here is my code:
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #endif
>
> #ifdef __BORLANDC__
> #define ITK_LEAN_AND_MEAN
> #endif
>
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkImage.h"
>
>
> int main( int argc, char ** argv )
> {
>
>
> typedef short PixelType;
> const unsigned int Dimension = 2;
> typedef itk::Image< PixelType, Dimension > ImageType;
> typedef itk::ImageFileReader< ImageType > ReaderType;
> typedef itk::ImageFileWriter< ImageType > WriterType;
>
> ReaderType::Pointer reader = ReaderType::New();
> WriterType::Pointer writer = WriterType::New();
>
> const char * inputFilename = "bla.jpg";
> const char * outputFilename = "bla2.jpg";
>
> reader->SetFileName( inputFilename );
> writer->SetFileName( outputFilename );
>
> try
> {
> writer->Update();
> }
> catch( itk::ExceptionObject & err )
> {
> std::cerr << "ExceptionObject caught !" << std::endl;
> std::cerr << err << std::endl;
> return EXIT_FAILURE;
> }
>
> return EXIT_SUCCESS;
> }
> Cheers,
> Ella
>
>


More information about the Insight-users mailing list