<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">&lt;<a href="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</a>&gt;</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;"><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-&gt;SetFileName(&quot;../data/FastMarchingFilterOutput3.hdr&quot;)]. 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 &quot;itkCurvatureAnisotropicDiffusionImageFilter.h&quot;</div>
<div>#include &quot;itkGradientMagnitudeRecursiveGaussianImageFilter.h&quot;<br>#include &quot;itkSigmoidImageFilter.h&quot;</div>
<div>#include &quot;itkImage.h&quot;<br>#include &quot;itkFastMarchingImageFilter.h&quot;</div>
<div><br>// Software Guide : BeginCodeSnippet<br>#include &quot;itkBinaryThresholdImageFilter.h&quot;</div>
<div><br>// Software Guide : BeginCodeSnippet<br>#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;</div>
<div>// <br>#include &quot;itkRescaleIntensityImageFilter.h&quot;</div>
<div><br>int main( int argc, char *argv[] )<br>{<br>  if( argc &lt; 3 )<br>    {<br>    std::cerr &lt;&lt; &quot;Missing Parameters &quot; &lt;&lt; std::endl;<br>    std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0];<br>
    std::cerr &lt;&lt; &quot; inputImage  outputImage seedX seedY&quot;;<br>    std::cerr &lt;&lt; &quot; Sigma SigmoidAlpha SigmoidBeta TimeThreshold StoppingValue&quot; &lt;&lt; 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&lt; InternalPixelType, Dimension &gt;  InternalImageType;<br>
  // Software Guide : EndCodeSnippet</div>
<div>  typedef unsigned char OutputPixelType;<br>  typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;<br>  // Software Guide : EndCodeSnippet</div>
<div>  typedef itk::BinaryThresholdImageFilter&lt; InternalImageType, <br>                        OutputImageType    &gt;    ThresholdingFilterType;<br>  ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();<br>
  </div>
<div>  const InternalPixelType  timeThreshold = atof( argv[3] );<br>  <br>  // Software Guide : BeginCodeSnippet<br>  thresholder-&gt;SetLowerThreshold(           0.0  );<br>  thresholder-&gt;SetUpperThreshold( timeThreshold  );</div>

<div>  thresholder-&gt;SetOutsideValue(  0  );<br>  thresholder-&gt;SetInsideValue(  255 );<br>  <br>  // Software Guide : BeginCodeSnippet<br>  typedef  itk::ImageFileReader&lt; InternalImageType &gt; ReaderType;<br>  typedef  itk::ImageFileWriter&lt;  OutputImageType  &gt; WriterType;<br>
  // Software Guide : EndCodeSnippet</div>
<div><br>  ReaderType::Pointer reader = ReaderType::New();<br>  WriterType::Pointer writer = WriterType::New();</div>
<div>  reader-&gt;SetFileName( argv[1] );<br>  writer-&gt;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&lt; <br>                               InternalImageType, <br>
                               OutputImageType &gt;   CastFilterType;</div>
<div>  typedef   itk::CurvatureAnisotropicDiffusionImageFilter&lt; <br>                               InternalImageType, <br>                               InternalImageType &gt;  SmoothingFilterType;<br>  <br>  // Software Guide : BeginCodeSnippet<br>
  SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();<br> </div>
<div>  // Software Guide : BeginCodeSnippet<br>  typedef   itk::GradientMagnitudeRecursiveGaussianImageFilter&lt; <br>                               InternalImageType, <br>                               InternalImageType &gt;  GradientFilterType;</div>

<div>  typedef   itk::SigmoidImageFilter&lt;                               <br>                               InternalImageType, <br>                               InternalImageType &gt;  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-&gt;SetOutputMinimum(  0.0  );<br>  sigmoid-&gt;SetOutputMaximum(  1.0  );<br>  </div>
<div>  // Software Guide : BeginCodeSnippet<br>  typedef  itk::FastMarchingImageFilter&lt; InternalImageType, <br>                              InternalImageType &gt;    FastMarchingFilterType;<br>  </div>
<div>  // Software Guide : BeginCodeSnippet<br>  FastMarchingFilterType::Pointer  fastMarching = FastMarchingFilterType::New();<br> <br>  // Software Guide : BeginCodeSnippet<br>  smoothing-&gt;SetInput( reader-&gt;GetOutput() );<br>
  gradientMagnitude-&gt;SetInput( smoothing-&gt;GetOutput() );<br>  sigmoid-&gt;SetInput( gradientMagnitude-&gt;GetOutput() );<br>  fastMarching-&gt;SetInput( sigmoid-&gt;GetOutput() );<br>  thresholder-&gt;SetInput( fastMarching-&gt;GetOutput() );<br>
  writer-&gt;SetInput( thresholder-&gt;GetOutput() );<br>  // Software Guide : EndCodeSnippet</div>
<div><br>  </div>
<div>  // Software Guide : BeginCodeSnippet<br>  smoothing-&gt;SetTimeStep( 0.05 );<br>  smoothing-&gt;SetNumberOfIterations(  10 );<br>  smoothing-&gt;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-&gt;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-&gt;SetAlpha( alpha );<br>  sigmoid-&gt;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-&gt;Initialize();<br>  seeds-&gt;InsertElement( 0, node );<br>
  //  Software Guide : EndCodeSnippet </div>
<div>  // Software Guide : BeginCodeSnippet<br>  fastMarching-&gt;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-&gt;SetInput( smoothing-&gt;GetOutput() );<br>  writer1-&gt;SetInput( caster1-&gt;GetOutput() );<br>  writer1-&gt;SetFileName(&quot;../data/FastMarchingFilterOutput1..hdr&quot;);<br>  caster1-&gt;SetOutputMinimum(   0 );<br>
  caster1-&gt;SetOutputMaximum( 255 );<br>  writer1-&gt;Update();</div>
<div>  caster2-&gt;SetInput( gradientMagnitude-&gt;GetOutput() );<br>  writer2-&gt;SetInput( caster2-&gt;GetOutput() );<br>  writer2-&gt;SetFileName(&quot;../data/FastMarchingFilterOutput2.hdr&quot;);<br>  caster2-&gt;SetOutputMinimum(   0 );<br>
  caster2-&gt;SetOutputMaximum( 255 );<br>  writer2-&gt;Update();</div>
<div>  caster3-&gt;SetInput( sigmoid-&gt;GetOutput() );<br>  writer3-&gt;SetInput( caster3-&gt;GetOutput() );<br>  writer3-&gt;SetFileName(&quot;../data/FastMarchingFilterOutput3.hdr&quot;);<br>  caster3-&gt;SetOutputMinimum(   0 );<br>
  caster3-&gt;SetOutputMaximum( 255 );<br>  writer3-&gt;Update();</div>
<div>  caster4-&gt;SetInput( fastMarching-&gt;GetOutput() );<br>  writer4-&gt;SetInput( caster4-&gt;GetOutput() );<br>  writer4-&gt;SetFileName(&quot;../data/FastMarchingFilterOutput4.hdr&quot;);<br>  caster4-&gt;SetOutputMinimum(   0 );<br>
  caster4-&gt;SetOutputMaximum( 255 );</div>
<div><br>  //  Software Guide : BeginLatex<br> <br>  //<br>  //  Software Guide : EndLatex </div>
<div>  // Software Guide : BeginCodeSnippet<br>  fastMarching-&gt;SetOutputSize( <br>           reader-&gt;GetOutput()-&gt;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-&gt;SetStoppingValue(  stoppingTime  );<br>  // Software Guide : EndCodeSnippet</div>
<div><br> </div>
<div>  // Software Guide : BeginCodeSnippet<br>  try<br>    {<br>    writer-&gt;Update();<br>    }<br>  catch( itk::ExceptionObject &amp; excep )<br>    {<br>    std::cerr &lt;&lt; &quot;Exception caught !&quot; &lt;&lt; std::endl;<br>
    std::cerr &lt;&lt; excep &lt;&lt; std::endl;<br>    }<br>  // Software Guide : EndCodeSnippet</div>
<div><br>  writer4-&gt;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&lt; InternalImageType &gt; InternalWriterType;</div>

<div>  InternalWriterType::Pointer mapWriter = InternalWriterType::New();<br>  mapWriter-&gt;SetInput( fastMarching-&gt;GetOutput() );<br>  mapWriter-&gt;SetFileName(&quot;../data/FastMarchingFilterOutput5.hdr&quot;);<br>
  mapWriter-&gt;Update();</div>
<div>  InternalWriterType::Pointer speedWriter = InternalWriterType::New();<br>  speedWriter-&gt;SetInput( sigmoid-&gt;GetOutput() );<br>  speedWriter-&gt;SetFileName(&quot;../data/FastMarchingFilterOutput6.hdr&quot;);<br>
  speedWriter-&gt;Update();</div>
<div>  InternalWriterType::Pointer gradientWriter = InternalWriterType::New();<br>  gradientWriter-&gt;SetInput( gradientMagnitude-&gt;GetOutput() );<br>  gradientWriter-&gt;SetFileName(&quot;../data/FastMarchingFilterOutput7.hdr&quot;);<br>
  gradientWriter-&gt;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>