[Insight-users] Change output file type
Luis Ibanez
luis.ibanez at kitware.com
Thu Apr 1 19:30:38 EDT 2010
Hi Stephen,
The image that this example is trying to save
are of pixel type "float".
PNG does not support this pixel type.
It was my mistake to suggest you to use PNG
without having checked first on the pixel type.
Please use MetaImage (extension .mhd).
Note also that by adding a try/catch block around the
Update() call of the writers, the error message becomes
a lot more informative.
We have committed those changes to the CVS version
of this example.
Regards,
Luis
---------------------------------------------
On Thu, Apr 1, 2010 at 11:30 AM, Stephen Yip <stephen.fyip1 at gmail.com> wrote:
> Hi Dan,
>
> After changing hdr to png, the following is the feedback I get.
>
> "This application has requested the Runtime to terminate it in an unusual
> way. Please contact the application's support team for more information."
>
> My inputs are png files. I have no idea how to change the file type of the
> outputs since I am following the examples (DeformableRegistration1.cxx).
>
> Thanks,
> Stephen
>
> On Wed, Mar 31, 2010 at 10:53 PM, Dan Mueller <dan.muel at gmail.com> wrote:
>>
>> 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
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list