<div dir="ltr">Try<br>gaussian_noise_filter-&gt;UpdateLargestPossibleRegion(); rather than Update().<br><div class="gmail_default"></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 30, 2013 at 11:09 AM, Prathamesh Kulkarni <span dir="ltr">&lt;<a href="mailto:prathameshmkulkarni@gmail.com" target="_blank">prathameshmkulkarni@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">
Hello,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">
I am trying to create images with varing SNRs using the itk::AdditiveGaussianNoiseImageFilter which I downloaded from <a href="http://www.insight-journal.org/browse/publication/721" target="_blank">http://www.insight-journal.org/browse/publication/721</a>. However, when I create multiple instances of this filter inside a for loop, it crashes.</div>

<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Here is how I do it:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default">

<div class="gmail_default"><span style="white-space:pre-wrap">        </span>typedef itk::AdditiveGaussianNoiseImageFilter&lt;ImageType3D, ImageType3D&gt; GaussianNoiseFilterType;</div><div style="font-size:small"><br></div>
</div><div class="gmail_default"><div class="gmail_default">for(int i = 2; i &lt; 4; i++){</div><div class="gmail_default"><span style="white-space:pre-wrap">        </span></div><div class="gmail_default"><span style="white-space:pre-wrap">                </span>GaussianNoiseFilterType::Pointer gaussian_noise_filter =             GaussianNoiseFilterType::New();<span style="white-space:pre-wrap">        </span><br>

</div><div class="gmail_default"><span style="white-space:pre-wrap">                </span>gaussian_noise_filter-&gt;SetInput(this-&gt;PaddedCurvImage);<span style="white-space:pre-wrap">        </span></div><div class="gmail_default">
<span style="white-space:pre-wrap">                </span>gaussian_noise_filter-&gt;SetMean(mean);</div><div class="gmail_default"><span style="white-space:pre-wrap">                </span>gaussian_noise_filter-&gt;SetStandardDeviation(sigmas[i]);</div>

<div class="gmail_default"><span style="white-space:pre-wrap">                </span>std::cout &lt;&lt; &quot;sigma: &quot; &lt;&lt; sigmas[i] &lt;&lt; std::endl;</div><div class="gmail_default"><br></div><div class="gmail_default">
<span style="white-space:pre-wrap">                </span>std::cout &lt;&lt; &quot;crash&quot; &lt;&lt; std::endl;</div><div class="gmail_default"><span style="white-space:pre-wrap">                </span>try{</div><div class="gmail_default">
<span style="white-space:pre-wrap">                        </span>gaussian_noise_filter-&gt;Update();</div><div class="gmail_default"><span style="white-space:pre-wrap">                </span>}</div><div class="gmail_default"><span style="white-space:pre-wrap">                </span>catch (itk::ExceptionObject &amp;err)</div>

<div class="gmail_default"><span style="white-space:pre-wrap">                </span>{</div><div class="gmail_default"><span style="white-space:pre-wrap">                        </span>std::cerr &lt;&lt; &quot;Error in gaussian_noise_filter: &quot; &lt;&lt; err &lt;&lt; std::endl;</div>

<div class="gmail_default"><span style="white-space:pre-wrap">                </span>}</div><div class="gmail_default"><br></div><div class="gmail_default"><span style="white-space:pre-wrap">                </span>ImageType3D::Pointer noisy_img = gaussian_noise_filter-&gt;GetOutput();<span style="white-space:pre-wrap">        </span></div>

<div class="gmail_default"><br></div><div class="gmail_default"><span style="white-space:pre-wrap">                </span>std::string noisy_out = this-&gt;filename;</div><div class="gmail_default"><span style="white-space:pre-wrap">                this-&gt;</span>WriteImage3D(noisy_out, noisy_img);</div>

<div class="gmail_default"><span style="white-space:pre-wrap">        </span>}<br></div><div class="gmail_default"><br></div><div class="gmail_default">Here is the error it shows:</div><div class="gmail_default"><br></div><div class="gmail_default">

<div class="gmail_default">Writing output file ..\test_1_5_noisy_3_noisy.nrrd</div><div class="gmail_default">Error in writing file.</div><div class="gmail_default">itk::ExceptionObject (0000000000B6EDC0)</div><div class="gmail_default">

Location: &quot;unknown&quot;</div><div class="gmail_default">File: ..\..\..\..\..\..\src\ITK_git\ITK\Modules\Core\Common\src\itkMultiThreader</div><div class="gmail_default">.cxx</div><div class="gmail_default">Line: 359</div>

<div class="gmail_default">Description: itk::ERROR: MultiThreader(000000003017C080): Exception occurred during SingleMethodExecute</div><div class="gmail_default">..\src\itk_git\itk\modules\core\common\include\itkImageConstIterator.h:206:</div>

<div class="gmail_default">itk::ERROR: Region ImageRegion (0000000000B6EA40)</div><div class="gmail_default">  Dimension: 3</div><div class="gmail_default">  Index: [0, 0, 0]</div><div class="gmail_default">  Size: [606, 474, 24]</div>

<div class="gmail_default"> is outside of buffered region ImageRegion (0000000002FCA0D0)</div><div class="gmail_default">  Dimension: 3</div><div class="gmail_default">  Index: [0, 0, 0]</div><div class="gmail_default">  Size: [0, 0, 0]</div>

<div class="gmail_default"><br></div><div class="gmail_default">I could not make out anything from this error. I have changed the variable <i>threadId</i> from <i>int</i> to <i>ThreadIdType </i>due to another error I was getting.</div>

<div class="gmail_default"><br></div><div class="gmail_default">Please guide me on how to fix this error. I need to generate a large number of images using this filter.</div><div class="gmail_default"><br></div><div class="gmail_default">

<br></div><div class="gmail_default">Thanks,</div><div class="gmail_default">Prathamesh</div></div></div></div>
<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.php" target="_blank">http://www.kitware.com/products/protraining.php</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>
</div>