[Insight-users] problem with discrete gaussian filter

Syrine Sahmim syrine.sahmim at yahoo.fr
Tue Jul 28 05:26:36 EDT 2009


Hello every body,
Yesterday i sent an email to the group to know what is the problem with my code and i did not receive answer.
I want to understand some things at the begining:
1. when i try the examples programs, i must give to the program the images as input. the problem is that i can't do that , i don't know how and where i must gives the input image and the out put one. if someone can explain more this issue to me.
2. i send again my previous program to try to find errors.
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;
}

BEST REGARDS


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


More information about the Insight-users mailing list