[Insight-users] discrete gaussian filter

Syrine Sahmim syrine.sahmim at yahoo.fr
Mon Jul 27 09:19:18 EDT 2009


Hi,
I try to apply the discrete gaussian filter on a 3D dicom image. So i tried the code below. there's no errors on building step but the problem is after debugging. i don't have result.so i want to know where's the error or even i must do or add some codes to succeed execution.
the code is:
#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 "itkDiscreteGaussianImageFilter.h"

int main( int argc, char * argv[] )
{argc = 2;
    argv[1] = "003F87DA.png";
    argv[2] = "DA.png"; 
  /*if( argc < 3 ) 
    { 
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << "  inputImageFile  outputImageFile  variance  maxKernelWidth " << std::endl;
    return EXIT_FAILURE;
    }*/

 
  typedef    float    InputPixelType;
  typedef    float    OutputPixelType;

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


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

  FilterType::Pointer filter = FilterType::New();
  
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( argv[1] );
 
  filter->SetInput( reader->GetOutput() );
 
  const double gaussianVariance = atof( argv[3] );
  const unsigned int maxKernelWidth = atoi( argv[4] );

  filter->SetVariance( gaussianVariance );
  filter->SetMaximumKernelWidth( maxKernelWidth );
 
  
  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] );
 
  // Software Guide : BeginCodeSnippet
  rescaler->SetInput( filter->GetOutput() );
  writer->SetInput( rescaler->GetOutput() );
  writer->Update();
  
  return EXIT_SUCCESS;
}

Thanks


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090727/9079bc7d/attachment.htm>


More information about the Insight-users mailing list