<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"><DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB>Dear itk users, </SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB>I’m new to itk (just in my first week). I have successfully configured itk and also vtk. I am now reading the ItkSoftwareGuide and I trying to run some of the examples provided. I’m little bit confused with the meaning of the Update function (for instance writer->Update();</SPAN><SPAN lang=EN-GB style="FONT-SIZE: 10pt"> </SPAN><SPAN lang=EN-GB>). According to the book update function triggers the execution of the pipeline. When I change its location in the code, the code still running without end. </SPAN><SPAN lang=EN-GB>For example in the example </SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">FastMarchingImageFilter.c++ <SPAN> </SPAN>if I move writer4->Update();and put it just after caster4->SetOutputMaximum( 255 ); ,as with the other writers, the code still running without end !</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'"> </SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB>I couldn’t understand where exactly this function should be placed in a given code.</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB>Is it better to call this function with the last filter (i.e. a writer ) or I can call it after each filter (and even reader and writer) ? What’s the difference between both??</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB>Please could you answer me? </SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB>Thank you </SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-GB>Martine</SPAN></P><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"></SPAN></SPAN>Please see the code:</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"> </P><FONT color=#008000 size=2>
<P>// The following example implements a fast marching solution to a simple level set evolution problem. </P></FONT><FONT color=#0000ff size=2>
<P>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkCurvatureAnisotropicDiffusionImageFilter.h"</P></FONT><FONT color=#0000ff size=2>
<P>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkGradientMagnitudeRecursiveGaussianImageFilter.h"</P></FONT><FONT color=#0000ff size=2>
<P>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkSigmoidImageFilter.h"</P></FONT><FONT color=#0000ff size=2>
<P>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkImage.h"</P></FONT><FONT color=#0000ff size=2>
<P>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkFastMarchingImageFilter.h"</P></FONT><FONT color=#0000ff size=2>
<P>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkBinaryThresholdImageFilter.h"</P></FONT><FONT color=#0000ff size=2>
<P>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkImageFileReader.h"</P></FONT><FONT color=#0000ff size=2>
<P>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkImageFileWriter.h"</P></FONT><FONT color=#0000ff size=2>
<P>#include</FONT><FONT size=2> </FONT><FONT color=#a31515 size=2>"itkRescaleIntensityImageFilter.h"</P>
<P> </P></FONT><FONT color=#0000ff size=2>
<P>int</FONT><FONT size=2> main( )</P>
<P>{ </P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>float</FONT><FONT size=2> InternalPixelType;</P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> Dimension = 2;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::Image< InternalPixelType, Dimension > InternalImageType;</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>unsigned</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2> OutputPixelType;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::Image< OutputPixelType, Dimension > OutputImageType;</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::BinaryThresholdImageFilter< InternalImageType, OutputImageType > ThresholdingFilterType;</P>
<P>ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> InternalPixelType timeThreshold = atof( </FONT><FONT color=#a31515 size=2>"100"</FONT><FONT size=2> ); </P>
<P></P>
<P>thresholder->SetLowerThreshold( 0.0 );</P>
<P>thresholder->SetUpperThreshold( timeThreshold );</P>
<P>thresholder->SetOutsideValue( 0 );</P>
<P>thresholder->SetInsideValue( 255 );</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::ImageFileReader< InternalImageType > ReaderType;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::ImageFileWriter< OutputImageType > WriterType;</P>
<P></P>
<P>ReaderType::Pointer reader = ReaderType::New();</P>
<P>WriterType::Pointer writer = WriterType::New();</P>
<P>reader->SetFileName(</FONT><FONT color=#a31515 size=2>"d:/BrainProtonDensitySlice.png"</FONT><FONT size=2>);</P>
<P>writer->SetFileName(</FONT><FONT color=#a31515 size=2>"d:/FastMarchingSegmentedImg.png"</FONT><FONT size=2>);</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::RescaleIntensityImageFilter< InternalImageType, OutputImageType > CastFilterType;</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::CurvatureAnisotropicDiffusionImageFilter< InternalImageType, InternalImageType > SmoothingFilterType;</P>
<P></P>
<P>SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::GradientMagnitudeRecursiveGaussianImageFilter< InternalImageType, InternalImageType > GradientFilterType;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::SigmoidImageFilter< InternalImageType, InternalImageType > SigmoidFilterType;</P>
<P></P>
<P>GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();</P>
<P>SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();</P>
<P></P>
<P>sigmoid->SetOutputMinimum( 0.0 );</P>
<P>sigmoid->SetOutputMaximum( 1.0 );</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::FastMarchingImageFilter< InternalImageType, InternalImageType > FastMarchingFilterType;</P>
<P></P>
<P>FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();</P>
<P></P>
<P>smoothing->SetInput( reader->GetOutput() );</P>
<P>gradientMagnitude->SetInput( smoothing->GetOutput() );</P>
<P>sigmoid->SetInput( gradientMagnitude->GetOutput() );</P>
<P>fastMarching->SetInput( sigmoid->GetOutput() );</P>
<P>thresholder->SetInput( fastMarching->GetOutput() );</P>
<P>writer->SetInput( thresholder->GetOutput() );</P>
<P></P>
<P>smoothing->SetTimeStep( 0.125 );</P>
<P>smoothing->SetNumberOfIterations( 5 );</P>
<P>smoothing->SetConductanceParameter( 9.0 );</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> sigma = atof( </FONT><FONT color=#a31515 size=2>"1.0"</FONT><FONT size=2> );</P>
<P></P>
<P>gradientMagnitude->SetSigma( sigma );</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> alpha = atof( </FONT><FONT color=#a31515 size=2>"-0.5"</FONT><FONT size=2> );</P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> beta = atof( </FONT><FONT color=#a31515 size=2>"3.0"</FONT><FONT size=2> );</P>
<P> </P>
<P>sigmoid->SetAlpha( alpha );</P>
<P>sigmoid->SetBeta( beta );</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> FastMarchingFilterType::NodeContainer NodeContainer;</P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> FastMarchingFilterType::NodeType NodeType;</P>
<P>NodeContainer::Pointer seeds = NodeContainer::New();</P>
<P></P>
<P>InternalImageType::IndexType seedPosition;</P>
<P></P>
<P>seedPosition[0] = atoi( </FONT><FONT color=#a31515 size=2>"81"</FONT><FONT size=2> );</P>
<P>seedPosition[1] = atoi( </FONT><FONT color=#a31515 size=2>"114"</FONT><FONT size=2> );</P>
<P>NodeType node;</P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> seedValue = 0.0;</P>
<P></P>
<P>node.SetValue( seedValue );</P>
<P>node.SetIndex( seedPosition );</P>
<P></P>
<P>seeds->Initialize();</P>
<P>seeds->InsertElement( 0, node );</P>
<P></P>
<P>fastMarching->SetTrialPoints( seeds );</P>
<P></P>
<P>CastFilterType::Pointer caster1 = CastFilterType::New();</P>
<P>CastFilterType::Pointer caster2 = CastFilterType::New();</P>
<P>CastFilterType::Pointer caster3 = CastFilterType::New();</P>
<P>CastFilterType::Pointer caster4 = CastFilterType::New();</P>
<P>WriterType::Pointer writer1 = WriterType::New();</P>
<P>WriterType::Pointer writer2 = WriterType::New();</P>
<P>WriterType::Pointer writer3 = WriterType::New();</P>
<P>WriterType::Pointer writer4 = WriterType::New();</P>
<P>caster1->SetInput( smoothing->GetOutput() );</P>
<P>writer1->SetInput( caster1->GetOutput() );</P>
<P>writer1->SetFileName(</FONT><FONT color=#a31515 size=2>"d:/FastMarchingFilterOutput1.png"</FONT><FONT size=2>);</P>
<P>caster1->SetOutputMinimum( 0 );</P>
<P>caster1->SetOutputMaximum( 255 );</P>
<P>writer1->Update();</P>
<P>caster2->SetInput( gradientMagnitude->GetOutput() );</P>
<P>writer2->SetInput( caster2->GetOutput() );</P>
<P>writer2->SetFileName(</FONT><FONT color=#a31515 size=2>"d:/FastMarchingFilterOutput2.png"</FONT><FONT size=2>);</P>
<P>caster2->SetOutputMinimum( 0 );</P>
<P>caster2->SetOutputMaximum( 255 );</P>
<P>writer2->Update();</P>
<P>caster3->SetInput( sigmoid->GetOutput() );</P>
<P>writer3->SetInput( caster3->GetOutput() );</P>
<P>writer3->SetFileName(</FONT><FONT color=#a31515 size=2>"d:/FastMarchingFilterOutput3.png"</FONT><FONT size=2>);</P>
<P>caster3->SetOutputMinimum( 0 );</P>
<P>caster3->SetOutputMaximum( 255 );</P>
<P>writer3->Update();</P>
<P>caster4->SetInput( fastMarching->GetOutput() );</P>
<P>writer4->SetInput( caster4->GetOutput() );</P>
<P>writer4->SetFileName(</FONT><FONT color=#a31515 size=2>"d:/FastMarchingFilterOutput4.png"</FONT><FONT size=2>);</P>
<P>caster4->SetOutputMinimum( 0 );</P>
<P>caster4->SetOutputMaximum( 255 );</P>
<P>writer4->Update(); </FONT><FONT color=#008000 size=2>// here where I have moved writer4->Update();</P></FONT><FONT size=2>
<P></P>
<P>fastMarching->SetOutputSize( reader->GetOutput()->GetBufferedRegion().GetSize() );</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>const</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> stoppingTime = atof( </FONT><FONT color=#a31515 size=2>"100"</FONT><FONT size=2> );</P>
<P>fastMarching->SetStoppingValue( stoppingTime );</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>try</P></FONT><FONT size=2>
<P>{</P>
<P>writer->Update();</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2>catch</FONT><FONT size=2>( itk::ExceptionObject & excep )</P>
<P>{</P>
<P>std::cerr << </FONT><FONT color=#a31515 size=2>"Exception caught !"</FONT><FONT size=2> << std::endl;</P>
<P>std::cerr << excep << std::endl;</P>
<P>}</P>
<P></P>
<P></FONT><FONT color=#008000 size=2>//writer4->Update();</P></FONT><FONT size=2>
<P></P>
<P></FONT><FONT color=#0000ff size=2>typedef</FONT><FONT size=2> itk::ImageFileWriter< InternalImageType > InternalWriterType;</P>
<P>InternalWriterType::Pointer mapWriter = InternalWriterType::New();</P>
<P>mapWriter->SetInput( fastMarching->GetOutput() );</P>
<P>mapWriter->SetFileName(</FONT><FONT color=#a31515 size=2>"d:/FastMarchingFilterOutput4.mha"</FONT><FONT size=2>);</P>
<P>mapWriter->Update();</P>
<P>InternalWriterType::Pointer speedWriter = InternalWriterType::New();</P>
<P>speedWriter->SetInput( sigmoid->GetOutput() );</P>
<P>speedWriter->SetFileName(</FONT><FONT color=#a31515 size=2>"d:/FastMarchingFilterOutput3.mha"</FONT><FONT size=2>);</P>
<P>speedWriter->Update();</P>
<P>InternalWriterType::Pointer gradientWriter = InternalWriterType::New();</P>
<P>gradientWriter->SetInput( gradientMagnitude->GetOutput() );</P>
<P>gradientWriter->SetFileName(</FONT><FONT color=#a31515 size=2>"d:/FastMarchingFilterOutput2.mha"</FONT><FONT size=2>);</P>
<P>gradientWriter->Update();</P>
<P>std::cout << </FONT><FONT color=#a31515 size=2>"Code end !"</FONT><FONT size=2> << std::endl;</P>
<P>std::cin.get();</P>
<P></FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2> 0;</P>
<P>}</P></FONT></DIV></DIV><BR></DIV></div><br>
<hr size="1">
Envoyé avec <a href="http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52423/*http://fr.docs.yahoo.com/mail/overview/index.html">Yahoo! Mail</a>.<br>Une boite mail plus intelligente. </a></body></html>