<div>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.</div>
<div><div><br></div><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><br><div class="gmail_quote">On Thu, Aug 4, 2011 at 2:18 PM, qi yang <span dir="ltr"><<a href="mailto:tinaqiyang@gmail.com">tinaqiyang@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><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>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div></div>