[Insight-users] GradientAnisotropicDiffusionImageFilter

Oleksandr Dzyubak adzyubak at gmail.com
Wed Oct 8 10:22:23 EDT 2008


You are trying to use 2D filter on 3D MRI data.
Change your dimension from 2D to 3D.

//  typedef itk::Image< InputPixelType,  2 >   InputImageType;
//  typedef itk::Image< OutputPixelType, 2 >   OutputImageType;


typedef itk::Image< InputPixelType, 3 > InputImageType;

typedef itk::Image< OutputPixelType, 3 >   OutputImageType;

Good luck,
Alex

mariangelalucente at inwind.it wrote:
> Hi,
> I test GradientAnisotropicDiffusionImageFilter from ITK .cxx on 3D MRI data, but occurs the error "Segmentation Fault".
> Could you help me?
> I list the code that I have used.
> Thank you
> Mari
>
>
>
>
>
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #endif
>
> #ifdef __BORLANDC__
> #define ITK_LEAN_AND_MEAN
> #endif
>
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkRescaleIntensityImageFilter.h"
>
> #include "itkGradientAnisotropicDiffusionImageFilter.h"
> int main( int argc, char * argv[] )
> {
>   if( argc < 6 ) 
>     { 
>     std::cerr << "Usage: " << std::endl;
>     std::cerr << argv[0] << "  inputImageFile  outputImageFile ";
>     std::cerr << "numberOfIterations  timeStep  conductance" << std::endl;
>     return EXIT_FAILURE;
>     }
>
> typedef    float    InputPixelType;
>   typedef    float    OutputPixelType;
>
>   typedef itk::Image< InputPixelType,  2 >   InputImageType;
>   typedef itk::Image< OutputPixelType, 2 >   OutputImageType;
>
> typedef itk::ImageFileReader< InputImageType >  ReaderType;
>
> typedef itk::GradientAnisotropicDiffusionImageFilter<
>                InputImageType, OutputImageType >  FilterType;
>   FilterType::Pointer filter = FilterType::New();
> ReaderType::Pointer reader = ReaderType::New();
>   reader->SetFileName( argv[1] );
>
> filter->SetInput( reader->GetOutput() );
> const unsigned int numberOfIterations = atoi( argv[3] );
>
>   const double       timeStep = atof( argv[4] );
>
>   const double       conductance = atof( argv[5] );
>
> filter->SetNumberOfIterations( numberOfIterations );
>   filter->SetTimeStep( timeStep );
>   filter->SetConductanceParameter( conductance );
>   
>   filter->Update();
> typedef unsigned char WritePixelType;
>   typedef itk::Image< WritePixelType, 2 > WriteImageType;
>   typedef itk::RescaleIntensityImageFilter< 
>                OutputImageType, WriteImageType > RescaleFilterType;
>
>   RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
>   rescaler->SetOutputMinimum(   0 );
>   rescaler->SetOutputMaximum( 255 );
>
>   typedef itk::ImageFileWriter< WriteImageType >  WriterType;
>
>   WriterType::Pointer writer = WriterType::New();
>   writer->SetFileName( argv[2] );
>  
>
>   rescaler->SetInput( filter->GetOutput() );
>   writer->SetInput( rescaler->GetOutput() );
>   writer->Update();
>
>   return EXIT_SUCCESS;
> }
>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>   



More information about the Insight-users mailing list