<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I'm having difficulty understanding why the following function throws an<br>exception at 'writer->Update()' whenever it's called.<br><br><font class="Apple-style-span" color="#2d2cfa" style="font-size: 11px;">const unsigned int Dimension = 2;<br>typedef unsigned char InputPixelType;<br>typedef unsigned char OutputPixelType;<br><br>typedef itk::Image< InputPixelType, Dimension > InputImageType;<br>typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br><br>void saveITKImage(InputImageType *image)<br>{<br> typedef itk::RescaleIntensityImageFilter< InputImageType,<br>OutputImageType > CastFilterType;<br> typedef itk::ImageFileWriter< InputImageType > <br>WriterType;<br><br> WriterType::Pointer writer = WriterType::New();<br> CastFilterType::Pointer caster = CastFilterType::New();<br><br> writer->SetFileName("/Users/usr/Desktop/test.jpg");<br> caster->SetOutputMinimum( 0 );<br> caster->SetOutputMaximum( 255 );<br><br> // Define Pipeline<br> caster->SetInput( image );<br> writer->SetInput( caster->GetOutput() );<br> writer->Update();<br><br> return;<br>}</font><br><br>I know I'm doing something right because the following bit of code works perfectly when called.<br><br><span class="Apple-style-span" style="font-size: 11px;"><font class="Apple-style-span" color="#2d2cfa">void saveITKImage(InputImageType *image)<br>{<br> typedef itk::ImageFileWriter< InputImageType > WriterType;<br><br> WriterType::Pointer writer = WriterType::New();<br><br> writer->SetFileName("/Users/usr/Desktop/test.jpg");<br><br> // Define Pipeline<br> writer->SetInput( image);<br> writer->Update();<br><br> return;<br>}</font></span><br><br>Does anyone know what I'm doing wrong?<div><br></div><div>Thank you in advance for your help!</div></body></html>