[Insight-users] Change output file type

Dan Mueller dan.muel at gmail.com
Wed Mar 31 23:53:00 EDT 2010


Hi Stephen,

The error may be caused because the PNG file format does not support
your image type. What is the pixel type of your output image?

As can be seen here
    http://www.itk.org/Wiki/ITK_File_Formats
PNG supports unsigned char, unsigned short, RGB, and RGBA.

If your image type is float or signed short, you will need to cast/rescale.

In the future, consider posting the exact error message you receive.
Statements like "the program won't run" are not very helpful for
diagnosing the issue :P As shown in many of the ITK examples, you can
print exception messages like this:

  try
    {
    myFilter->Update();
    }
  catch( itk::ExceptionObject & err )
    {
    std::cout << "ExceptionObject caught !" << std::endl;
    std::cout << err << std::endl;
    return EXIT_FAILURE;
    }

HTH

Cheers, Dan

On 31 March 2010 22:46, Stephen Yip <stephen.fyip1 at gmail.com> wrote:
> Hi,
>
> I know I have asked the similar question before.
>
> I tried to change "hdr" to "png" or some other file type. But the program
> wouldn't run at all. I am not an expert of c++. I wonder how I may change
> the output file in the DeformableRegistration1.cxx code.
>
> I did change "hdr" to "png"...the program wouldn't run...
>
>   writer = itk::ImageFileWriter<ImageType>::New();
>   std::string ofn="fixed.hdr";
>   writer->SetFileName(ofn.c_str());
>   writer->SetInput(registrationFilter->GetFixedImage() );
>   writer->Write();
>
>   ofn="moving.hdr";
>   itk::ImageFileWriter<ImageType>::Pointer writer2;
>   writer2 =  itk::ImageFileWriter<ImageType>::New();
>
> Thank you,
> stephen


More information about the Insight-users mailing list