<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><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->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>
</body></html>