<div>Hi there,</div><div> </div><div>I am new to ITK. I have a question about using itkReconstructionByDilationImageFilter. Can anyone help me out?</div><div>I have implemented a portion of simple code to input marker and mask images to itkReconstructionByDilationImageFilter and get output.</div>
<div>But the output image I got is always the same as the mask image. </div><div>At the same time, I used MeVisLab itkReconstructionByDilationImageFilter module to find out what's the ouput image using the same marker and mask images.</div>
<div>I got the different output which I expected.</div><div>So I think there must be something wrong with my code. The following is the code:</div><div> </div><div><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas">#include "itkImage.h"<br>
#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkReconstructionByDilationImageFilter.h"</font></font></div><div><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas">int main()<br>
{<br> typedef unsigned char PixelType;<br> const unsigned int Dimension = 2;<br> typedef itk::Image< PixelType, Dimension > ImageType;<br> typedef itk::ImageFileReader< ImageType > ReaderType;<br> typedef itk::ImageFileWriter< ImageType > WriterType;<br>
<br> const char *inputFilenameMarker = "C:\\marker.tif"; <br> const char *inputFilenameMask = "C:\\mask.tif"; <br> const char *outputFilename = "C:\\ITKresult.tif";</font></font></div>
<div>
<font color="#0000ff" face="Consolas"></font> </div><div><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"> // Get marker image<br> ReaderType::Pointer reader = ReaderType::New();<br>
reader->SetFileName( inputFilenameMarker ); <br> reader->Update(); <br> ImageType::Pointer markerImage = ImageType::New();<br> markerImage = reader->GetOutput();</font></font></div><div><font color="#0000ff" face="Consolas"></font> </div>
<div><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"> // Get mask image <br> reader->SetFileName( inputFilenameMask ); <br> reader->Update(); <br> ImageType::Pointer maskImage = ImageType::New();<br>
maskImage = reader->GetOutput();</font></font></div><div><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"> </font></font></div><div><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"> // dilation</font></font></div>
<div><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"> typedef itk::ReconstructionByDilationImageFilter<ImageType, ImageType> FilterType;<br> FilterType::Pointer filter = FilterType::New();<br>
filter->SetMarkerImage(markerImage);<br> filter->SetMaskImage(maskImage);<br> filter->Update();</font></font></div><div><font color="#0000ff" face="Consolas"></font> </div><div><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"> // write results<br>
WriterType::Pointer writer = WriterType::New(); <br> writer->SetFileName( outputFilename );<br> writer->SetInput( filter->GetOutput());<br> try <br> { <br> writer->Update(); <br> } <br> catch( itk::ExceptionObject & err ) <br>
{ <br> std::cerr << "ExceptionObject caught !" << std::endl; <br> std::cerr << err << std::endl; <br> return EXIT_FAILURE;<br> } </font></font></div><div><font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas">}</font></font></div>
<font color="#0000ff" size="2" face="Consolas"><font color="#0000ff" size="2" face="Consolas"><div> </div><div> </div><div>Thank you very much!</div><div> </div><div>Thanks,</div><div>Tina</div></font><div></div></font><div>
<font size="2" face="Consolas"><font size="2" face="Consolas">
</font></font><font size="2" face="Consolas"><font size="2" face="Consolas"> </font></font></div>