[Insight-users] Question about itkReconstructionByDilationImageFilter

qi yang tinaqiyang at gmail.com
Thu Aug 4 14:46:25 EDT 2011


Hi Robert,

Thank you very much!
It works!

Thanks,
Tina

On Thu, Aug 4, 2011 at 2:35 PM, robert tamburo <robert.tamburo at gmail.com>wrote:

> markerImage is being set to maskImage on the second Update() call.  Try
> removing markerImage from the filter pipeline by calling
> markerImage->DisconnectPipeline() after setting it to the reader output.
> Since you are reusing the reader, you should also use
> UpdateLargestPossibleRegion() instead of Update(). This updates the size
> information.
>
>  // 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();
>
> On Thu, Aug 4, 2011 at 2:18 PM, qi yang <tinaqiyang at gmail.com> wrote:
>
>> 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
>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110804/813e8067/attachment.htm>


More information about the Insight-users mailing list