[Insight-users] Question about itkReconstructionByDilationImageFilter

qi yang tinaqiyang at gmail.com
Thu Aug 4 14:18:29 EDT 2011


Hi there,

I am new to ITK. I have a question about
using itkReconstructionByDilationImageFilter. Can anyone help me out?
I have implemented a portion of simple code to input marker and mask images
to itkReconstructionByDilationImageFilter and get output.
But the output image I got is always the same as the mask image.
At the same time, I used MeVisLab itkReconstructionByDilationImageFilter
module to find out what's the ouput image using the same marker and mask
images.
I got the different output which I expected.
So I think there must be something wrong with my code. The following is the
code:

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkReconstructionByDilationImageFilter.h"
int main()
{
 typedef unsigned char   PixelType;
 const unsigned int Dimension = 2;
 typedef itk::Image< PixelType, Dimension > ImageType;
 typedef itk::ImageFileReader< ImageType >  ReaderType;
 typedef itk::ImageFileWriter< ImageType >  WriterType;

 const char  *inputFilenameMarker  = "C:\\marker.tif";
 const char  *inputFilenameMask  = "C:\\mask.tif";
 const char  *outputFilename = "C:\\ITKresult.tif";

 // Get marker image
 ReaderType::Pointer reader = ReaderType::New();
 reader->SetFileName( inputFilenameMarker  );
 reader->Update();
 ImageType::Pointer markerImage = ImageType::New();
 markerImage = reader->GetOutput();

 // Get mask image
 reader->SetFileName( inputFilenameMask  );
 reader->Update();
 ImageType::Pointer maskImage = ImageType::New();
 maskImage = reader->GetOutput();

 // dilation
 typedef itk::ReconstructionByDilationImageFilter<ImageType, ImageType>
FilterType;
 FilterType::Pointer filter = FilterType::New();
 filter->SetMarkerImage(markerImage);
 filter->SetMaskImage(maskImage);
 filter->Update();

 // write results
 WriterType::Pointer writer = WriterType::New();
 writer->SetFileName( outputFilename );
 writer->SetInput( filter->GetOutput());
 try
    {
    writer->Update();
    }
    catch( itk::ExceptionObject & err )
    {
    std::cerr << "ExceptionObject caught !" << std::endl;
    std::cerr << err << std::endl;
    return EXIT_FAILURE;
    }
}


Thank you very much!

Thanks,
Tina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110804/1eb4565e/attachment.htm>


More information about the Insight-users mailing list