[ITK-users] error executing in median filter for nifty(nii) file

neela avcneela at gmail.com
Tue Apr 22 06:54:27 EDT 2014


hi

i am new to itk programming.  I want to just simple filter(say median 
filter) for nii file.  I changed the MedianImageFilter.cxx program available 
with ITK as follows: (change size from 2 to 3) and include radius along z 
direction. 

#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

#include "itkMedianImageFilter.h"

int main( int argc, char * argv[] )
{
  if( argc < 3 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << "  inputImageFile   outputImageFile" << 
std::endl;
    return EXIT_FAILURE;
    }


  typedef   unsigned char  InputPixelType;
  typedef   unsigned  char  OutputPixelType;

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

  typedef itk::ImageFileReader< InputImageType  >  ReaderType;
  typedef itk::ImageFileWriter< OutputImageType >  WriterType;

  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();

  reader->SetFileName( argv[1] );
  writer->SetFileName( argv[2] );

  typedef itk::MedianImageFilter<
               InputImageType, OutputImageType >  FilterType;

  FilterType::Pointer filter = FilterType::New();
  InputImageType::SizeType indexRadius;

  indexRadius[0] = 1; // radius along x
  indexRadius[1] = 1; // radius along y
indexRadius[2] = 1; // radius along z

  filter->SetRadius( indexRadius );

  filter->SetInput( reader->GetOutput() );
  writer->SetInput( filter->GetOutput() );
  writer->Update();
  


  return EXIT_SUCCESS;
}

But it works well for JPG images, when i tried for DCM images i got only 
partial output (only one slice) where as for nii image system hangs. 
Anybody please help me.

thanks




More information about the Insight-users mailing list