[Insight-users] Working with RescaleIntensityImageFilter in XCode

Rupinder Singh rupinder.singh123 at yahoo.com
Tue Nov 1 12:34:03 EDT 2011


Hello,

Thank you for your assistance. Sorry for failing to mention the error in the previous post. I'm getting "Thread 1: Program received signal: "EXC_BAD_ACCESS" ." I was using Xcode 4.2, compiling on a 64 bit intel architecture, and using Apple LLVM compiler 3.0. 

After changing my compiler to LLVM GCC 4.2, everything worked perfectly. Does anyone know why that would be?

Thanks again for everyones help.

Sincerely,
Rupinder

On Nov 1, 2011, at 11:15 AM, Bill Lorensen wrote:

> This should give you more info:
> 
>   try
>     {
>     writer->Update();
>     }
>   catch( itk::ExceptionObject & exc )
>     {
>     std::cout << "Caught unexpected exception: "
>               << exc;
>     return EXIT_FAILURE;
>     }
> 
> 
> On Tue, Nov 1, 2011 at 1:53 AM, cagatay bilgin <bilgincc at gmail.com> wrote:
> Hello Rupinder, 
> 
> Could it be that your CastFilter's output is of OutputImageType 
> and your Writer's input is of InputImageType and you connect
> the cast filter's output to the writer filter ? Templating the ImageFileWriter
> over the OutputImageType might solve your problem. That is instead of
> 
> typedef  itk::ImageFileWriter< InputImageType >  WriterType;
> try 
> typedef  itk::ImageFileWriter< OutputImageType >  WriterType;
> 
> PS. You can attach the error to the email for a better diagnosis.
> 
> Regards, 
> Cagatay
> 
> On Mon, Oct 31, 2011 at 10:03 PM, Rupinder Singh <rupinder.singh123 at yahoo.com> wrote:
> I'm having difficulty understanding why the following function throws an
> exception at 'writer->Update()' whenever it's called.
> 
> const     unsigned int    Dimension = 2;
> typedef   unsigned char   InputPixelType;
> typedef   unsigned char   OutputPixelType;
> 
> typedef itk::Image< InputPixelType,    Dimension >   InputImageType;
> typedef itk::Image< OutputPixelType,   Dimension >   OutputImageType;
> 
> void saveITKImage(InputImageType *image)
> {
>    typedef  itk::RescaleIntensityImageFilter< InputImageType,
> OutputImageType > CastFilterType;
>    typedef  itk::ImageFileWriter< InputImageType >                                         
> WriterType;
> 
>    WriterType::Pointer      writer = WriterType::New();
>    CastFilterType::Pointer  caster = CastFilterType::New();
> 
>    writer->SetFileName("/Users/usr/Desktop/test.jpg");
>    caster->SetOutputMinimum(   0 );
>    caster->SetOutputMaximum( 255 );
> 
>    // Define Pipeline
>    caster->SetInput( image );
>    writer->SetInput( caster->GetOutput() );
>    writer->Update();
> 
>    return;
> }
> 
> I know I'm doing something right because the following bit of code works perfectly when called.
> 
> void saveITKImage(InputImageType *image)
> {
>    typedef  itk::ImageFileWriter< InputImageType > WriterType;
> 
>    WriterType::Pointer  writer = WriterType::New();
> 
>    writer->SetFileName("/Users/usr/Desktop/test.jpg");
> 
>    // Define Pipeline
>    writer->SetInput( image);
>    writer->Update();
> 
>    return;
> }
> 
> Does anyone know what I'm doing wrong?
> 
> Thank you in advance for your help!
> 
> _____________________________________
> 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
> 
> 
> 
> _____________________________________
> 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
> 
> 
> 
> 
> -- 
> Unpaid intern in BillsBasement at noware dot com
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111101/ff15e01c/attachment.htm>


More information about the Insight-users mailing list