[Insight-users] Problem with curvature flow filter

pieter Mollemans pmolle at gmail.com
Mon Oct 15 07:45:27 EDT 2007


Hello,

I try to use a itk curvature flow filter on a 3D image volume. I load 
this image into a (3 dimensional) buffer with  itk::ImportImageFilter, 
then i apply the filter and eventually write everything back to a 
buffer. When i run my program to test my code (no compile errors) , the 
program throws a breakpoint when the buffer gets applied,

The code stops at :  
this->GetMultiThreader()->SetNumberOfThreads(this->GetNumberOfThreads());
in file:  itkDenseFiniteDifferenceImageFilter.txx
the output says : "Access violation reading location"

i tried to set the number of threads manually but the error stays.

Anyone has any idea what could be the error or where to look for a 
solution? I added my code at the bottom , i use VS2005 and itk 3.4.0

thx

------------------------------           CODE      
----------------------------------------------------------

 typedef short InputPixelType;
 const unsigned int Dimension = 3;
 typedef itk::Image< InputPixelType, Dimension > ImageType;

 typedef itk::ImportImageFilter< InputPixelType, Dimension >   
ImportFilterType;

ImportFilterType::Pointer importFilter = ImportFilterType::New();     

ImportFilterType::SizeType size = {{ image->imageSize()[0], 
image->imageSize()[1], image->imageSize()[2] }};
ImportFilterType::IndexType index = {{ 0, 0, 0 }};

ImportFilterType::RegionType region;
region.SetSize(  size  );
region.SetIndex( index );
importFilter->SetRegion( region );

double origin[ Dimension ];
origin[0] = 0;    // X coordinate 
origin[1] = 0;    // Y coordinate
origin[2] = 0;    // Z coordinate
importFilter->SetOrigin( origin );

double spacing[ Dimension ];
spacing[0] = 0;    // along X direction
spacing[1] = 0;    // along Y direction
spacing[2] = 0;    // along Z direction
importFilter->SetSpacing( spacing );

const unsigned int numberOfPixels =  size[0] * size[1] * size[2];
InputPixelType * localBuffer = new InputPixelType[ numberOfPixels ];
image->loadSlices(0,160, (char *) localBuffer);

const bool importImageFilterWillOwnTheBuffer = true;
importFilter->SetImportPointer( localBuffer, numberOfPixels, 
importImageFilterWillOwnTheBuffer );

typedef  float OutputPixelType;
typedef itk::Image< InputPixelType,  Dimension >   InputImageType;
typedef itk::Image< OutputPixelType, Dimension >   OutputImageType;

typedef itk::CurvatureFlowImageFilter< InputImageType, OutputImageType 
 >  FilterType;
FilterType::Pointer filter = FilterType::New();

filter->SetInput( importFilter->GetOutput() );

const unsigned int numberOfIterations = 10;
const double       timeStep = 0.065 ;

filter->SetNumberOfIterations( numberOfIterations );
filter->SetTimeStep( timeStep );
   
try
{
      filter->Update();   //here the breakpoint occurs
}
catch( itk::ExceptionObject & err )
    {
        std::cerr << "ExceptionObject caught !" << std::endl;
        std::cerr << err << std::endl;
}

 // ... then i write the image back to a buffer



More information about the Insight-users mailing list