[Insight-users] CannyEdgeDetectionImageFilter: Failed to allocate memory for image

Lassi Paavolainen lassi.paavolainen at jyu.fi
Fri Mar 11 09:00:33 EST 2011


Hi Melanie,

That error comes from the fact that you are running out of memory, either 
that 2GB allocated for process in 32-bit Windows or actual memory (not 
so likely). Try to free as much memory as possible before using 
CannyEdgeDetectionImageFilter. For instance take results of previous 
filters and disconnect it from pipeline using DisconnectPipeline() method. 
If you just can't get enough free memory to run it on your current system, 
then the easiest solution is to use 64-bit OS that I'm guessing you are 
not using at the moment.

Cheers,
Lassi

On Fri, 11 Mar 2011, Melanie Uks wrote:

> Hi all,
> 
> I am using the CannyEdgeDetectionImageFilter and for small 3D images it
> works fine. For a bigger image (300x300x512) the following error appears:
>   itk::ExceptionObject (0153C7B4)
>   Location: "double *__thiscall itk::ImportImageContainer<unsigned
> long,double>::A
>   llocateElements(unsigned long) const"
>   File: h:\itk\insighttoolkit-3.16.0\code\common\itkImportImageContainer.txx
>   Line: 188
>   Description: Failed to allocate memory for image.
> 
> The source code for the filter is:
> 
> typedef double RealPixelType;
> typedef itk::Image<RealPixelType, Dimension> RealImageType;
> 
> typedef itk::CastImageFilter<ImageType, RealImageType> CastToRealFilterType;
> typedef itk::RescaleIntensityImageFilter<RealImageType, ImageType>
> RescaleFilterType;
>        
> typedef itk::CannyEdgeDetectionImageFilter<RealImageType, RealImageType>
> CannyFilterType;
> CastToRealFilterType::Pointer toReal = CastToRealFilterType::New();
> RescaleFilterType::Pointer rescale = RescaleFilterType::New();
> CannyFilterType::Pointer cannyFilter = CannyFilterType::New();
> 
> rescale->SetOutputMinimum(0.0);
> rescale->SetOutputMaximum(255.0);
> toReal->SetInput(image);
> cannyFilter->SetInput(toReal->GetOutput());
> cannyFilter->SetVariance(var);
> cannyFilter->SetUpperThreshold(up*1.0);
> cannyFilter->SetLowerThreshold(low*1.0);
> rescale->SetInput(cannyFilter->GetOutput());
> 
> try
> {
>     rescale->Update(); //Filterung
> 
>     image = rescale->GetOutput();
> }
> catch(itk::ExceptionObject & err)
> {
>      std::cout<< "ExceptionObject caught!"<<std::endl;
>      std::cout<< err << std::endl;
> }
> 
> 
> Does someone know how to avoid this error?
> 
> Thanks a lot and have a nice weekend!
> Melanie
> 
>


More information about the Insight-users mailing list