<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>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.&nbsp;</div><div><br></div><div>After changing my compiler to LLVM GCC 4.2, everything worked perfectly. Does anyone know why that would be?</div><div><br></div><div>Thanks again for everyones help.</div><div><br></div><div>Sincerely,</div><div>Rupinder</div><div><br><div><div>On Nov 1, 2011, at 11:15 AM, Bill Lorensen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">This should give you more info:<br><br>&nbsp; try<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; writer-&gt;Update();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; catch( itk::ExceptionObject &amp; exc )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "Caught unexpected exception: "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; exc;<br>
&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; }<br><br><br><div class="gmail_quote">On Tue, Nov 1, 2011 at 1:53 AM, cagatay bilgin <span dir="ltr">&lt;<a href="mailto:bilgincc@gmail.com">bilgincc@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello Rupinder, <br><br>Could it be that your CastFilter's output is of OutputImageType <br>and your Writer's input is of InputImageType and you connect<br>the cast filter's output to the writer filter ? Templating the ImageFileWriter<br>

over the OutputImageType might solve your problem. That is instead of<div class="im"><br><font style="font-size: 11px;" color="#2d2cfa"> typedef &nbsp;itk::ImageFileWriter&lt; InputImageType &gt;&nbsp; WriterType;<br></font></div>
try <br><font style="font-size: 11px;" color="#2d2cfa">typedef &nbsp;itk::ImageFileWriter&lt; OutputImageType &gt;&nbsp; WriterType;<br>
</font><br>PS. You can attach the error to the email for a better diagnosis.<br><br>Regards, <br>Cagatay<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Mon, Oct 31, 2011 at 10:03 PM, Rupinder Singh <span dir="ltr">&lt;<a href="mailto:rupinder.singh123@yahoo.com" target="_blank">rupinder.singh123@yahoo.com</a>&gt;</span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5"><div style="word-wrap: break-word;">I'm having difficulty understanding why the following function throws an<br>

exception at 'writer-&gt;Update()' whenever it's called.<br><br><font style="font-size: 11px;" color="#2d2cfa">const &nbsp;&nbsp;&nbsp;&nbsp;unsigned int &nbsp;&nbsp;&nbsp;Dimension = 2;<br>typedef &nbsp;&nbsp;unsigned char &nbsp;&nbsp;InputPixelType;<br>typedef &nbsp;&nbsp;unsigned char &nbsp;&nbsp;OutputPixelType;<br>

<br>typedef itk::Image&lt; InputPixelType, &nbsp;&nbsp;&nbsp;Dimension &gt; &nbsp;&nbsp;InputImageType;<br>typedef itk::Image&lt; OutputPixelType, &nbsp;&nbsp;Dimension &gt; &nbsp;&nbsp;OutputImageType;<br><br>void saveITKImage(InputImageType *image)<br>{<br>&nbsp;&nbsp;&nbsp;typedef &nbsp;itk::RescaleIntensityImageFilter&lt; InputImageType,<br>

OutputImageType &gt; CastFilterType;<br>&nbsp;&nbsp;&nbsp;typedef &nbsp;itk::ImageFileWriter&lt; InputImageType &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>WriterType;<br><br>&nbsp;&nbsp;&nbsp;WriterType::Pointer &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer = WriterType::New();<br>&nbsp;&nbsp;&nbsp;CastFilterType::Pointer &nbsp;caster = CastFilterType::New();<br>

<br>&nbsp;&nbsp;&nbsp;writer-&gt;SetFileName("/Users/usr/Desktop/test.jpg");<br>&nbsp;&nbsp;&nbsp;caster-&gt;SetOutputMinimum( &nbsp;&nbsp;0 );<br>&nbsp;&nbsp;&nbsp;caster-&gt;SetOutputMaximum( 255 );<br><br>&nbsp;&nbsp;&nbsp;// Define Pipeline<br>&nbsp;&nbsp;&nbsp;caster-&gt;SetInput( image );<br>

&nbsp;&nbsp;&nbsp;writer-&gt;SetInput( caster-&gt;GetOutput() );<br>&nbsp;&nbsp;&nbsp;writer-&gt;Update();<br><br>&nbsp;&nbsp;&nbsp;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 style="font-size: 11px;"><font color="#2d2cfa">void saveITKImage(InputImageType *image)<br>{<br>&nbsp;&nbsp;&nbsp;typedef &nbsp;itk::ImageFileWriter&lt; InputImageType &gt; WriterType;<br><br>&nbsp;&nbsp;&nbsp;WriterType::Pointer &nbsp;writer = WriterType::New();<br>

<br>&nbsp;&nbsp;&nbsp;writer-&gt;SetFileName("/Users/usr/Desktop/test.jpg");<br><br>&nbsp;&nbsp;&nbsp;// Define Pipeline<br>&nbsp;&nbsp;&nbsp;writer-&gt;SetInput( image);<br>&nbsp;&nbsp;&nbsp;writer-&gt;Update();<br><br>&nbsp;&nbsp;&nbsp;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></div><br></div></div>_____________________________________<br>
Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>
</blockquote></div><br></div></body></html>