[Insight-users] (no subject)

Martine Lefevre martine_lef at yahoo.fr
Wed Aug 27 07:05:41 EDT 2008


Hi Luis,
Thank you to explain me this .
Best regards 
Martine



----- Message d'origine ----
De : Luis Ibanez <luis.ibanez at kitware.com>
À : Martine Lefevre <martine_lef at yahoo.fr>
Cc : Daniel Mace <dlm19 at duke.edu>; insight itk <insight-users at itk.org>
Envoyé le : Mardi, 26 Août 2008, 16h09mn 14s
Objet : Re: [Insight-users] Re : meaning of Update() function? where exactly this function should be placed ?


Hi Martine,


The Update() method must is called on each terminal
node of the pipeline.


In the case of this example, the pipeline has four
terminal nodes (each one of the four writers),
therefore you must call Update() on each one.


The pipeline of this example looks like


          +--------- writer1
          |
          +--------- writer2
    ------|
          +--------- writer3
          |
          +--------- writer4



Dan's original advice assumed that you had a linear
pipeline with a single terminal node, such as:


    filter1-->filter2-->filter3-->filter4


In this later case, you only need to call Update()
in filter4.



Regards,


      Luis


-----------------------
Martine Lefevre wrote:
> Hi Daniel,
> I have a question. if Update should be called on the last filter in the 
> pipeline why its called after each writer in this example ? I could n't 
> see the purpose ?
> Thanks
> Martine
> 
>  
> 
> ----- Message d'origine ----
> De : Daniel Mace <dlm19 at duke.edu>
> À : Martine Lefevre <martine_lef at yahoo.fr>
> Cc : insight itk <insight-users at itk.org>
> Envoyé le : Lundi, 25 Août 2008, 5h59mn 56s
> Objet : Re: [Insight-users] meaning of Update() function? where exactly 
> this function should be placed ?
> 
> Martine,
> 
> You should only need to call Update() on the last filter in the pipeline
> (in your case, the writers).  As you noted, the Update() on the writer
> will trickle down and call Update on all the filters in the pipeline. 
> It should also be called after you have set all the parameters for all
> the filters in the pipeline.  In your case, you are calling
> writer4->Update() before you have set the parameters for your
> FastMarchingFilter (which might be why it keeps running).
> 
> The only time I've needed to call Update() on a filter that is not the
> last filter in the pipeline is to Update the reader if I need to get the
> size of the image prior to updating the pipeline (which, may or may not
> have been resolved by now).
> 
> Cheers,
> Dan
> 
> 
> Martine Lefevre wrote:
>  >
>  > Dear itk users,
>  >
>  > 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(); ).
>  > 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. For example in the example
>  > FastMarchingImageFilter.c++  if I move writer4->Update();and put it
>  > just after caster4->SetOutputMaximum( 255 ); ,as with the other
>  > writers, the code still running without end !
>  >
>  > I couldn’t understand where exactly this function should be placed in
>  > a given code.
>  >
>  > 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??
>  >
>  > Please could you answer me?
>  >
>  > Thank you
>  >
>  > Martine
>  >
>  > Please see the code:
>  >
>  > 
>  >
>  > // The following example implements a fast marching solution to a
>  > simple level set evolution problem.
>  >
>  > #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
>  >
>  > #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
>  >
>  > #include "itkSigmoidImageFilter.h"
>  >
>  > #include "itkImage.h"
>  >
>  > #include "itkFastMarchingImageFilter.h"
>  >
>  > #include "itkBinaryThresholdImageFilter.h"
>  >
>  > #include "itkImageFileReader.h"
>  >
>  > #include "itkImageFileWriter.h"
>  >
>  > #include "itkRescaleIntensityImageFilter.h"
>  >
>  > 
>  >
>  > int main( )
>  >
>  > {
>  >
>  > typedef float InternalPixelType;
>  >
>  > const unsigned int Dimension = 2;
>  >
>  > typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
>  >
>  > typedef unsigned char OutputPixelType;
>  >
>  > typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>  >
>  > typedef itk::BinaryThresholdImageFilter< InternalImageType,
>  > OutputImageType > ThresholdingFilterType;
>  >
>  > ThresholdingFilterType::Pointer thresholder =
>  > ThresholdingFilterType::New();
>  >
>  > const InternalPixelType timeThreshold = atof( "100" );
>  >
>  > thresholder->SetLowerThreshold( 0.0 );
>  >
>  > thresholder->SetUpperThreshold( timeThreshold );
>  >
>  > thresholder->SetOutsideValue( 0 );
>  >
>  > thresholder->SetInsideValue( 255 );
>  >
>  > typedef itk::ImageFileReader< InternalImageType > ReaderType;
>  >
>  > typedef itk::ImageFileWriter< OutputImageType > WriterType;
>  >
>  > ReaderType::Pointer reader = ReaderType::New();
>  >
>  > WriterType::Pointer writer = WriterType::New();
>  >
>  > reader->SetFileName("d:/BrainProtonDensitySlice.png");
>  >
>  > writer->SetFileName("d:/FastMarchingSegmentedImg.png");
>  >
>  > typedef itk::RescaleIntensityImageFilter< InternalImageType,
>  > OutputImageType > CastFilterType;
>  >
>  > typedef itk::CurvatureAnisotropicDiffusionImageFilter<
>  > InternalImageType, InternalImageType > SmoothingFilterType;
>  >
>  > SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();
>  >
>  > typedef itk::GradientMagnitudeRecursiveGaussianImageFilter<
>  > InternalImageType, InternalImageType > GradientFilterType;
>  >
>  > typedef itk::SigmoidImageFilter< InternalImageType, InternalImageType
>  > > SigmoidFilterType;
>  >
>  > GradientFilterType::Pointer gradientMagnitude = 
> GradientFilterType::New();
>  >
>  > SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();
>  >
>  > sigmoid->SetOutputMinimum( 0.0 );
>  >
>  > sigmoid->SetOutputMaximum( 1.0 );
>  >
>  > typedef itk::FastMarchingImageFilter< InternalImageType,
>  > InternalImageType > FastMarchingFilterType;
>  >
>  > FastMarchingFilterType::Pointer fastMarching =
>  > FastMarchingFilterType::New();
>  >
>  > smoothing->SetInput( reader->GetOutput() );
>  >
>  > gradientMagnitude->SetInput( smoothing->GetOutput() );
>  >
>  > sigmoid->SetInput( gradientMagnitude->GetOutput() );
>  >
>  > fastMarching->SetInput( sigmoid->GetOutput() );
>  >
>  > thresholder->SetInput( fastMarching->GetOutput() );
>  >
>  > writer->SetInput( thresholder->GetOutput() );
>  >
>  > smoothing->SetTimeStep( 0.125 );
>  >
>  > smoothing->SetNumberOfIterations( 5 );
>  >
>  > smoothing->SetConductanceParameter( 9.0 );
>  >
>  > const double sigma = atof( "1.0" );
>  >
>  > gradientMagnitude->SetSigma( sigma );
>  >
>  > const double alpha = atof( "-0.5" );
>  >
>  > const double beta = atof( "3.0" );
>  >
>  > 
>  >
>  > sigmoid->SetAlpha( alpha );
>  >
>  > sigmoid->SetBeta( beta );
>  >
>  > typedef FastMarchingFilterType::NodeContainer NodeContainer;
>  >
>  > typedef FastMarchingFilterType::NodeType NodeType;
>  >
>  > NodeContainer::Pointer seeds = NodeContainer::New();
>  >
>  > InternalImageType::IndexType seedPosition;
>  >
>  > seedPosition[0] = atoi( "81" );
>  >
>  > seedPosition[1] = atoi( "114" );
>  >
>  > NodeType node;
>  >
>  > const double seedValue = 0.0;
>  >
>  > node.SetValue( seedValue );
>  >
>  > node.SetIndex( seedPosition );
>  >
>  > seeds->Initialize();
>  >
>  > seeds->InsertElement( 0, node );
>  >
>  > fastMarching->SetTrialPoints( seeds );
>  >
>  > CastFilterType::Pointer caster1 = CastFilterType::New();
>  >
>  > CastFilterType::Pointer caster2 = CastFilterType::New();
>  >
>  > CastFilterType::Pointer caster3 = CastFilterType::New();
>  >
>  > CastFilterType::Pointer caster4 = CastFilterType::New();
>  >
>  > WriterType::Pointer writer1 = WriterType::New();
>  >
>  > WriterType::Pointer writer2 = WriterType::New();
>  >
>  > WriterType::Pointer writer3 = WriterType::New();
>  >
>  > WriterType::Pointer writer4 = WriterType::New();
>  >
>  > caster1->SetInput( smoothing->GetOutput() );
>  >
>  > writer1->SetInput( caster1->GetOutput() );
>  >
>  > writer1->SetFileName("d:/FastMarchingFilterOutput1.png");
>  >
>  > caster1->SetOutputMinimum( 0 );
>  >
>  > caster1->SetOutputMaximum( 255 );
>  >
>  > writer1->Update();
>  >
>  > caster2->SetInput( gradientMagnitude->GetOutput() );
>  >
>  > writer2->SetInput( caster2->GetOutput() );
>  >
>  > writer2->SetFileName("d:/FastMarchingFilterOutput2.png");
>  >
>  > caster2->SetOutputMinimum( 0 );
>  >
>  > caster2->SetOutputMaximum( 255 );
>  >
>  > writer2->Update();
>  >
>  > caster3->SetInput( sigmoid->GetOutput() );
>  >
>  > writer3->SetInput( caster3->GetOutput() );
>  >
>  > writer3->SetFileName("d:/FastMarchingFilterOutput3.png");
>  >
>  > caster3->SetOutputMinimum( 0 );
>  >
>  > caster3->SetOutputMaximum( 255 );
>  >
>  > writer3->Update();
>  >
>  > caster4->SetInput( fastMarching->GetOutput() );
>  >
>  > writer4->SetInput( caster4->GetOutput() );
>  >
>  > writer4->SetFileName("d:/FastMarchingFilterOutput4.png");
>  >
>  > caster4->SetOutputMinimum( 0 );
>  >
>  > caster4->SetOutputMaximum( 255 );
>  >
>  > writer4->Update(); // here where I have moved writer4->Update();
>  >
>  > fastMarching->SetOutputSize(
>  > reader->GetOutput()->GetBufferedRegion().GetSize() );
>  >
>  > const double stoppingTime = atof( "100" );
>  >
>  > fastMarching->SetStoppingValue( stoppingTime );
>  >
>  > try
>  >
>  > {
>  >
>  > writer->Update();
>  >
>  > }
>  >
>  > catch( itk::ExceptionObject & excep )
>  >
>  > {
>  >
>  > std::cerr << "Exception caught !" << std::endl;
>  >
>  > std::cerr << excep << std::endl;
>  >
>  > }
>  >
>  > //writer4->Update();
>  >
>  > typedef itk::ImageFileWriter< InternalImageType > InternalWriterType;
>  >
>  > InternalWriterType::Pointer mapWriter = InternalWriterType::New();
>  >
>  > mapWriter->SetInput( fastMarching->GetOutput() );
>  >
>  > mapWriter->SetFileName("d:/FastMarchingFilterOutput4.mha");
>  >
>  > mapWriter->Update();
>  >
>  > InternalWriterType::Pointer speedWriter = InternalWriterType::New();
>  >
>  > speedWriter->SetInput( sigmoid->GetOutput() );
>  >
>  > speedWriter->SetFileName("d:/FastMarchingFilterOutput3.mha");
>  >
>  > speedWriter->Update();
>  >
>  > InternalWriterType::Pointer gradientWriter = InternalWriterType::New();
>  >
>  > gradientWriter->SetInput( gradientMagnitude->GetOutput() );
>  >
>  > gradientWriter->SetFileName("d:/FastMarchingFilterOutput2.mha");
>  >
>  > gradientWriter->Update();
>  >
>  > std::cout << "Code end !" << std::endl;
>  >
>  > std::cin.get();
>  >
>  > return 0;
>  >
>  > }
>  >
>  >
>  >
>  > ------------------------------------------------------------------------
>  > Envoyé avec Yahoo! Mail
>  > 
> <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>.
>  > Une boite mail plus intelligente.
>  > ------------------------------------------------------------------------
>  >
>  > _______________________________________________
>  > Insight-users mailing list
>  > Insight-users at itk.org <mailto:Insight-users at itk.org>
>  > http://www.itk.org/mailman/listinfo/insight-users
>  > 
> 
> 
> ------------------------------------------------------------------------
> Envoyé avec Yahoo! Mail 
> <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>.
> Une boite mail plus intelligente.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



      _____________________________________________________________________________ 
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080827/6a366921/attachment-0001.htm>


More information about the Insight-users mailing list