<br>Hi Baoyun,<br><br>Yes ITK 3.10 is the release where this bug sneaked in. :-(<br><br>You can fix it by yourself by applying the following change:<br><br><a href="http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/BasicFilters/itkGradientMagnitudeRecursiveGaussianImageFilter.txx?root=Insight&r1=1.20&r2=1.21&sortby=date">http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/BasicFilters/itkGradientMagnitudeRecursiveGaussianImageFilter.txx?root=Insight&r1=1.20&r2=1.21&sortby=date</a><br>
<br><br>Simply add:<br><br>
cumulativeImage->CopyInformation(this->GetInput());<br><br>to line 216 of the file<br><br> Insight/Code/BasicFilters/<br> itkGradientMagnitudeRecursiveGaussianImageFilter.txx<br><br>and rebuild your application.<br>
<br>--<br><br>The great advantage of Open Source software is indeed<br>that you *can* help yourself and help others by fixing <br>things on your own. :-)<br><br><br>Please let us know if you find any problem,<br><br> Thanks<br>
<br> Luis<br><br><br>------------------------------------------------------------------------<br><div class="gmail_quote">On Wed, Feb 25, 2009 at 11:52 AM, Baoyun Li <span dir="ltr"><<a href="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Dear Luis:</div>
<div> </div>
<div>The ITK version I used 3.10.0. I begin to used it at the end of 2008. Do you think that will be a problem?</div>
<div> </div>
<div>I will try CVS version or the new relase, and let you know the result.</div>
<div> </div>
<div>Is it possible for myself to fix the problem? Or I have to be very familiar with ITK to solve the problem by myself. You know the later work can not be continues once this kind of thing happend.</div>
<div> </div>
<div>Thanks and my best regards</div>
<div> </div><font color="#888888">
<div>Baoyun</div>
</font><div><br><div class="WgoR0d"> </div></div><div class="WgoR0d">
</div><div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><div class="WgoR0d"><br>
</div><div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><div class="WgoR0d"><font size="2" face="Tahoma">
<hr size="1">
<b><span style="font-weight: bold;">From:</span></b> Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>><br><b><span style="font-weight: bold;">To:</span></b> Baoyun Li <<a href="mailto:baoyun_li123@yahoo.com" target="_blank">baoyun_li123@yahoo.com</a>><br>
<b><span style="font-weight: bold;">Cc:</span></b> <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br><b><span style="font-weight: bold;">Sent:</span></b> Wednesday, February 25, 2009 10:43:43 AM<br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: ITK FastMarching example--help!!!--the resultion of output images are changed to [1 1 1]<br></font></div><div><div></div><div class="Wj3C7c"><br><br>Hi Baoyun,<br>
<br>What version of ITK are you using ?<br><br>In a recent release a bug went into the RecursiveGaussianImageFilter, <br>that resulted in the spacing information being reset to trivial values.<br><br>This has now been fixed in the CVS repository.<br>
<br>Could you please try a CVS checkout of ITK ?<br><br>FYI: We will be releasing ITK 3.12 by Monday.<br><br>Please let us know what you
find,<br><br><br> Thanks<br><br><br> Luis<br><br><br>-----------------------------------------<br>
<div class="gmail_quote">On Wed, Feb 25, 2009 at 11:39 AM, Baoyun Li <span dir="ltr"><<a href="mailto:baoyun_li123@yahoo.com" rel="nofollow" target="_blank">baoyun_li123@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font face="Arial">
<div>Dear All:</div>
<div> </div>
<div>When I run ITK example for fastmarching (see the attached code below), the output image resolution are changed to [1 1 1] begining at sigmoid filter output [writer3->SetFileName("../data/FastMarchingFilterOutput3.hdr")]. But my input resolution is [0.7 0.7 2.5]. The first two output files kept the origianl resolution.</div>
<div> </div>
<div>I only changed some arguments of the expmale code and the Dimension to 3. My command aruguments are: FastMarchingImageFilter SE1.hdr out.hdr 1000 1001.</div>
<div> </div>
<div>ITK deals images on Physical space, now the spacial resolution of images are changed, so I do not how I can trust the results and cannot continue some works, eg mutiple resoltion processing</div>
<div> </div>
<div>Can somebody help me to figure out this problem? Thanks a lot.</div>
<div> </div>
<div> </div>
<div>Best regards</div>
<div> </div>
<div>Baoyun</div>
<div><br><br>#if defined(_MSC_VER)<br>#pragma warning ( disable : 4786 )<br>#endif</div>
<div>#ifdef __BORLANDC__<br>#define ITK_LEAN_AND_MEAN<br>#endif</div>
<div> </div>
<div><br>#include "itkCurvatureAnisotropicDiffusionImageFilter.h"</div>
<div>#include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"<br>#include "itkSigmoidImageFilter.h"</div>
<div>#include "itkImage.h"<br>#include "itkFastMarchingImageFilter.h"</div>
<div><br>// Software Guide : BeginCodeSnippet<br>#include "itkBinaryThresholdImageFilter.h"</div>
<div><br>// Software Guide : BeginCodeSnippet<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"</div>
<div>// <br>#include "itkRescaleIntensityImageFilter.h"</div>
<div><br>int main( int argc, char *argv[] )<br>{<br> if( argc < 3 )<br> {<br> std::cerr << "Missing Parameters " << std::endl;<br> std::cerr << "Usage: " << argv[0];<br>
std::cerr << " inputImage outputImage seedX seedY";<br> std::cerr << " Sigma SigmoidAlpha SigmoidBeta TimeThreshold StoppingValue" << std::endl;<br> return 1;<br> }</div>
<div><br> </div>
<div> // Software Guide : BeginCodeSnippet<br> typedef float InternalPixelType;<br> const unsigned int Dimension = 3;<br> typedef itk::Image< InternalPixelType, Dimension > InternalImageType;<br>
// Software Guide : EndCodeSnippet</div>
<div> typedef unsigned char OutputPixelType;<br> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br> // Software Guide : EndCodeSnippet</div>
<div> typedef itk::BinaryThresholdImageFilter< InternalImageType, <br> OutputImageType > ThresholdingFilterType;<br> ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();<br>
</div>
<div> const InternalPixelType timeThreshold = atof( argv[3] );<br> <br> // Software Guide : BeginCodeSnippet<br> thresholder->SetLowerThreshold( 0.0 );<br> thresholder->SetUpperThreshold( timeThreshold );</div>
<div> thresholder->SetOutsideValue( 0 );<br> thresholder->SetInsideValue( 255 );<br> <br> // Software Guide : BeginCodeSnippet<br> typedef itk::ImageFileReader< InternalImageType > ReaderType;<br> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br>
// Software Guide : EndCodeSnippet</div>
<div><br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();</div>
<div> reader->SetFileName( argv[1] );<br> writer->SetFileName( argv[2] );</div>
<div><br> // The RescaleIntensityImageFilter type is declared below. This filter will<br> // renormalize image before sending them to writers.<br> //<br> typedef itk::RescaleIntensityImageFilter< <br> InternalImageType, <br>
OutputImageType > CastFilterType;</div>
<div> typedef itk::CurvatureAnisotropicDiffusionImageFilter< <br> InternalImageType, <br> InternalImageType > SmoothingFilterType;<br> <br> // Software Guide : BeginCodeSnippet<br>
SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();<br> </div>
<div> // Software Guide : BeginCodeSnippet<br> typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< <br> InternalImageType, <br> InternalImageType > GradientFilterType;</div>
<div> typedef itk::SigmoidImageFilter< <br> InternalImageType, <br> InternalImageType > SigmoidFilterType;<br> <br> GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();<br>
SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();<br> // Software Guide : EndCodeSnippet</div>
<div> </div>
<div> // Software Guide : BeginCodeSnippet<br> sigmoid->SetOutputMinimum( 0.0 );<br> sigmoid->SetOutputMaximum( 1.0 );<br> </div>
<div> // Software Guide : BeginCodeSnippet<br> typedef itk::FastMarchingImageFilter< InternalImageType, <br> InternalImageType > FastMarchingFilterType;<br> </div>
<div> // Software Guide : BeginCodeSnippet<br> FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();<br> <br> // Software Guide : BeginCodeSnippet<br> smoothing->SetInput( reader->GetOutput() );<br>
gradientMagnitude->SetInput( smoothing->GetOutput() );<br> sigmoid->SetInput( gradientMagnitude->GetOutput() );<br> fastMarching->SetInput( sigmoid->GetOutput() );<br> thresholder->SetInput( fastMarching->GetOutput() );<br>
writer->SetInput( thresholder->GetOutput() );<br> // Software Guide : EndCodeSnippet</div>
<div><br> </div>
<div> // Software Guide : BeginCodeSnippet<br> smoothing->SetTimeStep( 0.05 );<br> smoothing->SetNumberOfIterations( 10 );<br> smoothing->SetConductanceParameter( 9.0 );<br> // Software Guide : EndCodeSnippet</div>
<div><br> </div>
<div> const double sigma = (float) 2.5;//atof( argv[5] );</div>
<div> // Software Guide : BeginCodeSnippet<br> gradientMagnitude->SetSigma( sigma );<br> // Software Guide : EndCodeSnippet</div>
<div> </div>
<div> const double alpha = (float)-0.33;//atof( argv[6] );<br> const double beta = (float) 0.5;//atof( argv[7] );</div>
<div><br> // Software Guide : BeginCodeSnippet<br> sigmoid->SetAlpha( alpha );<br> sigmoid->SetBeta( beta );<br> <br> <br> typedef FastMarchingFilterType::NodeContainer NodeContainer;<br> typedef FastMarchingFilterType::NodeType NodeType;<br>
NodeContainer::Pointer seeds = NodeContainer::New();<br> // Software Guide : EndCodeSnippet <br> </div>
<div> InternalImageType::IndexType seedPosition;<br> <br> seedPosition[0] = 131;//atoi( argv[3] );<br> seedPosition[1] = 273;//atoi( argv[4] );<br> seedPosition[2] = 36;//atoi( argv[4] );</div>
<div><br> <br> NodeType node;<br> const double seedValue = 0.0;<br> <br> node.SetValue( seedValue );<br> node.SetIndex( seedPosition );<br> <br> seeds->Initialize();<br> seeds->InsertElement( 0, node );<br>
// Software Guide : EndCodeSnippet </div>
<div> // Software Guide : BeginCodeSnippet<br> fastMarching->SetTrialPoints( seeds );<br> // Software Guide : EndCodeSnippet</div>
<div><br> // Here we configure all the writers required to see the intermediate<br> // outputs of the pipeline. This is added here only for<br> // pedagogical/debugging purposes. These intermediate output are normaly not<br>
// required. Only the output of the final thresholding filter should be<br> // relevant. Observing intermediate output is helpful in the process of<br> // fine tuning the parameters of filters in the pipeline. <br>
//<br> CastFilterType::Pointer caster1 = CastFilterType::New();<br> CastFilterType::Pointer caster2 = CastFilterType::New();<br> CastFilterType::Pointer caster3 = CastFilterType::New();<br> CastFilterType::Pointer caster4 = CastFilterType::New();</div>
<div> WriterType::Pointer writer1 = WriterType::New();<br> WriterType::Pointer writer2 = WriterType::New();<br> WriterType::Pointer writer3 = WriterType::New();<br> WriterType::Pointer writer4 = WriterType::New();</div>
<div> caster1->SetInput( smoothing->GetOutput() );<br> writer1->SetInput( caster1->GetOutput() );<br> writer1->SetFileName("../data/FastMarchingFilterOutput1..hdr");<br> caster1->SetOutputMinimum( 0 );<br>
caster1->SetOutputMaximum( 255 );<br> writer1->Update();</div>
<div> caster2->SetInput( gradientMagnitude->GetOutput() );<br> writer2->SetInput( caster2->GetOutput() );<br> writer2->SetFileName(".../data/FastMarchingFilterOutput2.hdr");<br> caster2->SetOutputMinimum( 0 );<br>
caster2->SetOutputMaximum( 255 );<br> writer2->Update();</div>
<div> caster3->SetInput( sigmoid->GetOutput() );<br> writer3->SetInput( caster3->GetOutput() );<br> writer3->SetFileName("../data/FastMarchingFilterOutput3.hdr");<br> caster3->SetOutputMinimum( 0 );<br>
caster3->SetOutputMaximum( 255 );<br> writer3->Update();</div>
<div> caster4->SetInput( fastMarching->GetOutput() );<br> writer4->SetInput( caster4->GetOutput() );<br> writer4->SetFileName("../data/FastMarchingFilterOutput4.hdr");<br> caster4->SetOutputMinimum( 0 );<br>
caster4->SetOutputMaximum( 255 );</div>
<div><br> // Software Guide : BeginLatex<br> <br> //<br> // Software Guide : EndLatex </div>
<div> // Software Guide : BeginCodeSnippet<br> fastMarching->SetOutputSize( <br> reader->GetOutput()->GetBufferedRegion().GetSize() );<br> // Software Guide : EndCodeSnippet</div>
<div><br> <br> //<br> // Software Guide : EndLatex </div>
<div> const double stoppingTime = atof( argv[4] );</div>
<div> // Software Guide : BeginCodeSnippet<br> fastMarching->SetStoppingValue( stoppingTime );<br> // Software Guide : EndCodeSnippet</div>
<div><br> </div>
<div> // Software Guide : BeginCodeSnippet<br> try<br> {<br> writer->Update();<br> }<br> catch( itk::ExceptionObject & excep )<br> {<br> std::cerr << "Exception caught !" << std::endl;<br>
std::cerr << excep << std::endl;<br> }<br> // Software Guide : EndCodeSnippet</div>
<div><br> writer4->Update();</div>
<div><br> // The following writer type is used to save the output of the<br> // time-crossing map in a file with appropiate pixel representation. The<br> // advantage of saving this image in native format is that it can be used<br>
// with a viewer to help determine an appropriate threshold to be used on<br> // the output of the \code{fastmarching} filter.<br> //<br> typedef itk::ImageFileWriter< InternalImageType > InternalWriterType;</div>
<div> InternalWriterType::Pointer mapWriter = InternalWriterType::New();<br> mapWriter->SetInput( fastMarching->GetOutput() );<br> mapWriter->SetFileName("../data/FastMarchingFilterOutput5.hdr");<br>
mapWriter->Update();</div>
<div> InternalWriterType::Pointer speedWriter = InternalWriterType::New();<br> speedWriter->SetInput( sigmoid->GetOutput() );<br> speedWriter->SetFileName("../data/FastMarchingFilterOutput6.hdr");<br>
speedWriter->Update();</div>
<div> InternalWriterType::Pointer gradientWriter = InternalWriterType::New();<br> gradientWriter->SetInput( gradientMagnitude->GetOutput() );<br> gradientWriter->SetFileName("../data/FastMarchingFilterOutput7.hdr");<br>
gradientWriter->Update();</div>
<div><br> return 0;<br>}<br></div></font>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;">
<div style="font-size: 13px; font-family: arial,helvetica,sans-serif;"></div></div></div><br></div></blockquote></div><br></div></div></div></div></div><br>
</div></blockquote></div><br>