<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">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 class="" style="white-space:pre">        </span>typedef itk::AdditiveGaussianNoiseImageFilter<ImageType3D, ImageType3D> GaussianNoiseFilterType;</div><div style="font-size:small"><br></div>
</div><div class="gmail_default"><div class="gmail_default">for(int i = 2; i < 4; i++){</div><div class="gmail_default"><span class="" style="white-space:pre">        </span></div><div class="gmail_default"><span class="" style="white-space:pre">                </span>GaussianNoiseFilterType::Pointer gaussian_noise_filter = GaussianNoiseFilterType::New();<span class="" style="white-space:pre">        </span><br>
</div><div class="gmail_default"><span class="" style="white-space:pre">                </span>gaussian_noise_filter->SetInput(this->PaddedCurvImage);<span class="" style="white-space:pre">        </span></div><div class="gmail_default">
<span class="" style="white-space:pre">                </span>gaussian_noise_filter->SetMean(mean);</div><div class="gmail_default"><span class="" style="white-space:pre">                </span>gaussian_noise_filter->SetStandardDeviation(sigmas[i]);</div>
<div class="gmail_default"><span class="" style="white-space:pre">                </span>std::cout << "sigma: " << sigmas[i] << std::endl;</div><div class="gmail_default"><br></div><div class="gmail_default">
<span class="" style="white-space:pre">                </span>std::cout << "crash" << std::endl;</div><div class="gmail_default"><span class="" style="white-space:pre">                </span>try{</div><div class="gmail_default">
<span class="" style="white-space:pre">                        </span>gaussian_noise_filter->Update();</div><div class="gmail_default"><span class="" style="white-space:pre">                </span>}</div><div class="gmail_default"><span class="" style="white-space:pre">                </span>catch (itk::ExceptionObject &err)</div>
<div class="gmail_default"><span class="" style="white-space:pre">                </span>{</div><div class="gmail_default"><span class="" style="white-space:pre">                        </span>std::cerr << "Error in gaussian_noise_filter: " << err << std::endl;</div>
<div class="gmail_default"><span class="" style="white-space:pre">                </span>}</div><div class="gmail_default"><br></div><div class="gmail_default"><span class="" style="white-space:pre">                </span>ImageType3D::Pointer noisy_img = gaussian_noise_filter->GetOutput();<span class="" style="white-space:pre">        </span></div>
<div class="gmail_default"><br></div><div class="gmail_default"><span class="" style="white-space:pre">                </span>std::string noisy_out = this->filename;</div><div class="gmail_default"><span class="" style="white-space:pre">                this-></span>WriteImage3D(noisy_out, noisy_img);</div>
<div class="gmail_default"><span class="" style="white-space:pre">        </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: "unknown"</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>