[Insight-users] itk::AdditiveGaussianNoiseImageFilter crashes on creating multiple instances

Prathamesh Kulkarni prathameshmkulkarni at gmail.com
Tue Jul 30 11:09:52 EDT 2013


Hello,

I am trying to create images with varing SNRs using
the itk::AdditiveGaussianNoiseImageFilter which I downloaded from
http://www.insight-journal.org/browse/publication/721. However, when I
create multiple instances of this filter inside a for loop, it crashes.

Here is how I do it:

typedef itk::AdditiveGaussianNoiseImageFilter<ImageType3D, ImageType3D>
GaussianNoiseFilterType;

for(int i = 2; i < 4; i++){
 GaussianNoiseFilterType::Pointer gaussian_noise_filter =
GaussianNoiseFilterType::New();
gaussian_noise_filter->SetInput(this->PaddedCurvImage);
gaussian_noise_filter->SetMean(mean);
gaussian_noise_filter->SetStandardDeviation(sigmas[i]);
std::cout << "sigma: " << sigmas[i] << std::endl;

std::cout << "crash" << std::endl;
try{
gaussian_noise_filter->Update();
}
catch (itk::ExceptionObject &err)
{
std::cerr << "Error in gaussian_noise_filter: " << err << std::endl;
}

ImageType3D::Pointer noisy_img = gaussian_noise_filter->GetOutput();

std::string noisy_out = this->filename;
this->WriteImage3D(noisy_out, noisy_img);
}

Here is the error it shows:

Writing output file ..\test_1_5_noisy_3_noisy.nrrd
Error in writing file.
itk::ExceptionObject (0000000000B6EDC0)
Location: "unknown"
File:
..\..\..\..\..\..\src\ITK_git\ITK\Modules\Core\Common\src\itkMultiThreader
.cxx
Line: 359
Description: itk::ERROR: MultiThreader(000000003017C080): Exception
occurred during SingleMethodExecute
..\src\itk_git\itk\modules\core\common\include\itkImageConstIterator.h:206:
itk::ERROR: Region ImageRegion (0000000000B6EA40)
  Dimension: 3
  Index: [0, 0, 0]
  Size: [606, 474, 24]
 is outside of buffered region ImageRegion (0000000002FCA0D0)
  Dimension: 3
  Index: [0, 0, 0]
  Size: [0, 0, 0]

I could not make out anything from this error. I have changed the variable *
threadId* from *int* to *ThreadIdType *due to another error I was getting.

Please guide me on how to fix this error. I need to generate a large number
of images using this filter.


Thanks,
Prathamesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130730/9b15d799/attachment.htm>


More information about the Insight-users mailing list