[Insight-users] Urgenthelp with Observer class to store image sequence

Jayant Chauhan gripened@hotmail.com
Fri May 14 12:04:53 EDT 2004


<html><div style='background-color:'><DIV class=RTE>
<P>Hey Luis,<BR>Figured out what I was doing wrong, its geodesic filter that is iterating, so I should use the observer on it. I then create local threshold and zerocrossing filters in my observer execution function, And it works cool</P>
<P>&nbsp;</P>
<P>thanking you</P>
<P>with regards</P>
<P>Jayant<BR></P></DIV>
<DIV></DIV>&gt;From: Luis Ibanez &lt;luis.ibanez@kitware.com&gt; 
<DIV></DIV>&gt;To: Jayant Chauhan &lt;gripened@hotmail.com&gt; 
<DIV></DIV>&gt;CC: insight-users@itk.org 
<DIV></DIV>&gt;Subject: Re: [Insight-users] Urgenthelp with Observer class to store image sequence 
<DIV></DIV>&gt;Date: Thu, 13 May 2004 20:05:09 -0400 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Hi Jayant, 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;The datapipeline will not execute in the order that 
<DIV></DIV>&gt;your organized your code. What matters is the topology 
<DIV></DIV>&gt;of the pipeline. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;If you have 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp;FilterB-&gt;SetInput(&nbsp;&nbsp; FilterA-&gt;GetOutput()&nbsp;&nbsp; ); 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;the FilterA will always execute before Filter B. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;What you should do is to draw your pipeline in a piece 
<DIV></DIV>&gt;of paper, like: 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;FilterA --&gt;&nbsp;&nbsp;Filter B ---+ 
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FilterQ -----&gt; Output 
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
<DIV></DIV>&gt;FilterK --&gt;&nbsp;&nbsp;Filter M ---+ 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Then, simply follow the flow of data from the sources 
<DIV></DIV>&gt;to the consumers. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Note that if you are running the pipeline several 
<DIV></DIV>&gt;times, only the filter that have any change in parameters 
<DIV></DIV>&gt;will be executed again, and will force the filters 
<DIV></DIV>&gt;downstream to execute too. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;--- 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;When you say that 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp;"I'm not able to get the Observer to work" 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;what do you mean ? 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp; A) it seg.faults ? 
<DIV></DIV>&gt;&nbsp;&nbsp; B) it throws exceptions ? 
<DIV></DIV>&gt;&nbsp;&nbsp; C) its Execute() method is not invoked ? 
<DIV></DIV>&gt;&nbsp;&nbsp; D) it prints always zero progress ? 
<DIV></DIV>&gt;&nbsp;&nbsp; C) it prints garbage .... ? 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Please be more precise, 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp; Thanks 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Luis 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;----------------------- 
<DIV></DIV>&gt;Jayant Chauhan wrote: 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;&gt;Hey Fellas, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;Seems I am a lil bit confused about the sequential flow of 
<DIV></DIV>&gt;&gt;control in ITK. 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;When I include all my image reading and filter executions in the 
<DIV></DIV>&gt;&gt;main(), it works, but when I create a function which does all this 
<DIV></DIV>&gt;&gt;as a member of my class, then I am not able to get the Observer to 
<DIV></DIV>&gt;&gt;work. My code is as follows, I am using the 
<DIV></DIV>&gt;&gt;GeodesicActiveContourLevelSetImageFilter to segment my image, and 
<DIV></DIV>&gt;&gt;want to store all the contours, ie, the zerocrossing, so I add the 
<DIV></DIV>&gt;&gt;observer to my zerocrossing filter,ie, m_contour. 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;ALso it seems that only when I add my geodesicfilter to the 
<DIV></DIV>&gt;&gt;observer are the contours stored and not when I add m_contour. ie. 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; m_observer-&gt;SetCallbackFunction( this, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp; firstFilter::GetContourAfterIteration ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;*m_geodesic*-&gt;AddObserver(itk::IterationEvent(), m_observer); 
<DIV></DIV>&gt;&gt;//works 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;*m_contour*-&gt;AddObserver(itk::IterationEvent(), m_observer); 
<DIV></DIV>&gt;&gt;//doesnt work 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; my code: 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;*_firstFilter.h_* 
<DIV></DIV>&gt;&gt;*__* #ifndef _FIRST_FILTER_H 
<DIV></DIV>&gt;&gt;#define _FIRST_FILTER_H 
<DIV></DIV>&gt;&gt;#include "itkImage.h" 
<DIV></DIV>&gt;&gt;#include "itkImageFileReader.h" 
<DIV></DIV>&gt;&gt;#include "itkImageFileWriter.h" 
<DIV></DIV>&gt;&gt;#include "itkGeodesicActiveContourLevelSetImageFilter.h" 
<DIV></DIV>&gt;&gt;#include "itkCurvatureAnisotropicDiffusionImageFilter.h" 
<DIV></DIV>&gt;&gt;#include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" 
<DIV></DIV>&gt;&gt;#include "itkSigmoidImageFilter.h" 
<DIV></DIV>&gt;&gt;#include "itkBinaryThresholdImageFilter.h" 
<DIV></DIV>&gt;&gt;#include "itkGeodesicActiveContourLevelSetFunction.h" 
<DIV></DIV>&gt;&gt;#include "itkSegmentationLevelSetImageFilter.h" 
<DIV></DIV>&gt;&gt;#include "itkCastImageFilter.h" 
<DIV></DIV>&gt;&gt;#include "itkRescaleIntensityImageFilter.h" 
<DIV></DIV>&gt;&gt;#include "itkZeroCrossingImageFilter.h" 
<DIV></DIV>&gt;&gt;#include "itkCommand.h" 
<DIV></DIV>&gt;&gt;#include "itkWeightedAddImageFilter.h" 
<DIV></DIV>&gt;&gt; 
<DIV></DIV>&gt;&gt;template &lt;class TInputImage, class TInternalImage, class 
<DIV></DIV>&gt;&gt;TOutputImage&gt; 
<DIV></DIV>&gt;&gt;class firstFilter{ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; public: 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; typedef 
<DIV></DIV>&gt;&gt;itk::CurvatureAnisotropicDiffusionImageFilter&lt;TInputImage, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TInternalImage&gt; SmoothingFilterType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; typedef 
<DIV></DIV>&gt;&gt;itk::GradientMagnitudeRecursiveGaussianImageFilter&lt;TInternalImage, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TInternalImage&gt; GradientFilterType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; typedef itk::SigmoidImageFilter&lt;TInternalImage, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TInternalImage&gt; SigmoidFilterType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; typedef 
<DIV></DIV>&gt;&gt;itk::GeodesicActiveContourLevelSetImageFilter&lt;TInternalImage, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TInternalImage&gt; GACFilterType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;typedef itk::BinaryThresholdImageFilter&lt;TInternalImage, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TOutputImage&gt; TFilterType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; typedef itk::ZeroCrossingImageFilter&lt;TOutputImage, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TInternalImage&gt; ZeroFilterType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; typedef itk::WeightedAddImageFilter&lt;TInternalImage, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TInternalImage, TInternalImage&gt; WAddFilterType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; typedef itk::SimpleMemberCommand&lt; firstFilter &gt;&nbsp;&nbsp;ObserverType; 
<DIV></DIV>&gt;&gt; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; SmoothingFilterType::Pointer m_smoothing; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; GradientFilterType::Pointer m_gradient; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; SigmoidFilterType::Pointer m_sigmoid; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; SmoothingFilterType::Pointer m_framesmoothing; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; GradientFilterType::Pointer m_framegradient; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; SigmoidFilterType::Pointer m_framesigmoid; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; GACFilterType::Pointer m_geodesic; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; TFilterType::Pointer m_threshold; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; ZeroFilterType::Pointer m_contour; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; WAddFilterType::Pointer m_wadd; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; ObserverType::Pointer m_observer; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; firstFilter(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; void ExecuteGAC(char* , char* , char* , char* , char* , char* , 
<DIV></DIV>&gt;&gt;char*, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; int , float , float , float , 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; float , float , float ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; void GetContourAfterIteration(); 
<DIV></DIV>&gt;&gt;}; 
<DIV></DIV>&gt;&gt;template &lt;class TInputImage, class TInternalImage, class 
<DIV></DIV>&gt;&gt;TOutputImage&gt; 
<DIV></DIV>&gt;&gt;void firstFilter&lt;TInputImage, TInternalImage, TOutputImage&gt; 
<DIV></DIV>&gt;&gt;::ExecuteGAC(char* featureimage, char* frameimage, char* 
<DIV></DIV>&gt;&gt;initlevelset, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; char* sigmoidresult, char* framesigmoidresult, char* 
<DIV></DIV>&gt;&gt;gacresult, char* threshresult, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; int no_iter, float sigma, float alpha, float beta, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; float ascale, float cscale, float pscale){ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::ImageFileReader&lt;TInputImage&gt; InputImageReader; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::ImageFileReader&lt;TInternalImage&gt; InternalImageReader; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; typedef itk::ImageFileWriter&lt;TInternalImage&gt; 
<DIV></DIV>&gt;&gt;InternalImageWriter; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::ImageFileWriter&lt;TOutputImage&gt; OutputImageWriter; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;std::cout&lt;&lt;"I am inside the function "&lt;&lt;std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;InputImageReader::Pointer reader1 = InputImageReader::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;InputImageReader::Pointer reader2 = InputImageReader::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; InternalImageReader::Pointer internalreader1 = 
<DIV></DIV>&gt;&gt;InternalImageReader::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;InternalImageWriter::Pointer internalwriter1 = 
<DIV></DIV>&gt;&gt;InternalImageWriter::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; OutputImageWriter::Pointer sigmoidwriter = 
<DIV></DIV>&gt;&gt;OutputImageWriter::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;OutputImageWriter::Pointer framesigmoidwriter = 
<DIV></DIV>&gt;&gt;OutputImageWriter::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;OutputImageWriter::Pointer gacwriter = OutputImageWriter::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;OutputImageWriter::Pointer twriter = OutputImageWriter::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; reader1-&gt;SetFileName(featureimage); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;reader2-&gt;SetFileName(frameimage); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;internalreader1-&gt;SetFileName(initlevelset); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;sigmoidwriter-&gt;SetFileName(sigmoidresult); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;framesigmoidwriter-&gt;SetFileName(framesigmoidresult); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;m_smoothing-&gt;SetInput(reader1-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framesmoothing-&gt;SetInput(reader2-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_gradient-&gt;SetSigma(sigma); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_gradient-&gt;SetInput(m_smoothing-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framegradient-&gt;SetSigma(sigma); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framegradient-&gt;SetInput(m_framesmoothing-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_sigmoid-&gt;SetInput(m_gradient-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_sigmoid-&gt;SetAlpha( alpha ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; m_sigmoid-&gt;SetBeta( beta ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framesigmoid-&gt;SetInput(m_framegradient-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framesigmoid-&gt;SetAlpha( alpha ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; m_framesigmoid-&gt;SetBeta( alpha ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_wadd-&gt;SetInput1(m_sigmoid-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_wadd-&gt;SetInput2(m_framesigmoid-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_geodesic-&gt;SetPropagationScaling( pscale ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_geodesic-&gt;SetCurvatureScaling( cscale ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; m_geodesic-&gt;SetAdvectionScaling( ascale ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; m_geodesic-&gt;SetMaximumRMSError(0.02); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_geodesic-&gt;SetNumberOfIterations( no_iter ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_geodesic-&gt;SetReverseExpansionDirection(false); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_geodesic-&gt;SetInput(internalreader1-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_geodesic-&gt;SetFeatureImage(m_wadd-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;gacwriter-&gt;SetFileName(gacresult); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; twriter-&gt;SetFileName(threshresult); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_threshold-&gt;SetInput(m_geodesic-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::RescaleIntensityImageFilter&lt;TInternalImage, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; TOutputImage&gt; CastFilterType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;CastFilterType::Pointer sigmoidcastfilter = 
<DIV></DIV>&gt;&gt;CastFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;CastFilterType::Pointer gaccastfilter = CastFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; sigmoidcastfilter-&gt;SetInput(m_sigmoid-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;gaccastfilter-&gt;SetInput(m_geodesic-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; sigmoidcastfilter-&gt;SetOutputMinimum(0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;sigmoidcastfilter-&gt;SetOutputMaximum(255); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; gaccastfilter-&gt;SetOutputMinimum(0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;gaccastfilter-&gt;SetOutputMaximum(255); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;sigmoidwriter-&gt;SetInput(sigmoidcastfilter-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;gacwriter-&gt;SetInput(gaccastfilter-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;twriter-&gt;SetInput(m_threshold-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;CastFilterType::Pointer zerocastfilter = CastFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;zerocastfilter-&gt;SetOutputMinimum(0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;zerocastfilter-&gt;SetOutputMaximum(255); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;OutputImageWriter::Pointer zcwriter = OutputImageWriter::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_contour-&gt;SetInput(m_threshold-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;zerocastfilter-&gt;SetInput(m_contour-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;zcwriter-&gt;SetFileName("zerocrossing.png"); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;zcwriter-&gt;SetInput(zerocastfilter-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; try{ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; gacwriter-&gt;Update(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; twriter-&gt;Update(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; sigmoidwriter-&gt;Update(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; zcwriter-&gt;Update(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;} 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;catch (itk::ExceptionObject &amp; err) 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;{ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cerr&lt;&lt;"Exception caught "&lt;&lt;std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cerr&lt;&lt;err&lt;&lt;std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;} 
<DIV></DIV>&gt;&gt; 
<DIV></DIV>&gt;&gt;} 
<DIV></DIV>&gt;&gt; 
<DIV></DIV>&gt;&gt;template &lt;class TInputImage, class TInternalImage, class 
<DIV></DIV>&gt;&gt;TOutputImage&gt; 
<DIV></DIV>&gt;&gt;void firstFilter&lt;TInputImage, TInternalImage, TOutputImage&gt; 
<DIV></DIV>&gt;&gt;::GetContourAfterIteration(){ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; static unsigned int iterationCounter = 0; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;std::cout&lt;&lt;"Hey do I get a change "&lt;&lt;std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::ImageFileWriter&lt;TOutputImage&gt; ImageWriter; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::RescaleIntensityImageFilter&lt;TInternalImage, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; TOutputImage&gt; CastFilterType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;ImageWriter::Pointer contour_writer = ImageWriter::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;CastFilterType::Pointer zccast = CastFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;zccast-&gt;SetOutputMinimum(0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;zccast-&gt;SetOutputMaximum(255); 
<DIV></DIV>&gt;&gt; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;char* contourfile; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;contourfile = (char*)malloc(sizeof(char)*50); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; if ( (iterationCounter != 0) &amp;&amp; (iterationCounter%25 == 0) ){ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; sprintf(contourfile,"%d%s",iterationCounter,".png"); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cout &lt;&lt; "No. elpased iterations: " &lt;&lt; 
<DIV></DIV>&gt;&gt;m_geodesic-&gt;GetElapsedIterations() &lt;&lt; std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cout &lt;&lt; "RMS change: " &lt;&lt; m_geodesic-&gt;GetRMSChange() &lt;&lt; 
<DIV></DIV>&gt;&gt;std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; contour_writer-&gt;SetFileName(contourfile); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; zccast-&gt;SetInput(m_contour-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; contour_writer-&gt;SetInput(zccast-&gt;GetOutput()); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; try{ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;contour_writer-&gt;Update(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; } 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; catch (itk::ExceptionObject &amp; err){ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;std::cerr&lt;&lt;"ITK Exception caught :"&lt;&lt;err&lt;&lt;std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; } 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;} 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;else{ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cout&lt;&lt;"Iteration counter :"&lt;&lt;iterationCounter&lt;&lt;std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;} 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;iterationCounter++; 
<DIV></DIV>&gt;&gt;} 
<DIV></DIV>&gt;&gt; 
<DIV></DIV>&gt;&gt;template &lt;class TInputImage, class TInternalImage, class 
<DIV></DIV>&gt;&gt;TOutputImage&gt; 
<DIV></DIV>&gt;&gt;firstFilter&lt;TInputImage, TInternalImage, TOutputImage&gt; 
<DIV></DIV>&gt;&gt;::firstFilter(){ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_smoothing = SmoothingFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framesmoothing = SmoothingFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_smoothing-&gt;SetTimeStep(0.125); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_smoothing-&gt;SetNumberOfIterations(5); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; m_smoothing-&gt;SetConductanceParameter(3.0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framesmoothing-&gt;SetTimeStep(0.125); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framesmoothing-&gt;SetNumberOfIterations(5); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; m_framesmoothing-&gt;SetConductanceParameter(3.0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_gradient = GradientFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framegradient = GradientFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; m_sigmoid = SigmoidFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framesigmoid = SigmoidFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; m_sigmoid-&gt;SetOutputMinimum(0.0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; m_sigmoid-&gt;SetOutputMaximum(1.0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_framesigmoid-&gt;SetOutputMinimum(0.0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; m_framesigmoid-&gt;SetOutputMaximum(1.0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_wadd = WAddFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_wadd-&gt;SetAlpha(0.5); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; m_geodesic = GACFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_geodesic-&gt;SetIsoSurfaceValue(127.0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; m_threshold = TFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; m_threshold-&gt;SetLowerThreshold(-1000.0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_threshold-&gt;SetUpperThreshold(0.0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; m_threshold-&gt;SetOutsideValue(0); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_threshold-&gt;SetInsideValue(255); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_contour =&nbsp;&nbsp;ZeroFilterType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_observer = ObserverType::New(); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_observer-&gt;SetCallbackFunction( this, 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp; firstFilter::GetContourAfterIteration ); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;m_geodesic-&gt;AddObserver(itk::IterationEvent(), m_observer); 
<DIV></DIV>&gt;&gt;} 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;#endif 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; 
<DIV></DIV>&gt;&gt;-------------------------------------------------------------------------------------------------------------- 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;*_firstFilter.cxx_* 
<DIV></DIV>&gt;&gt;#include "firstFilter.h" 
<DIV></DIV>&gt;&gt;int main(int argc, char** argv){ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef unsigned char InputPixelType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef float InternalPixelType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef unsigned char OutputPixelType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::Image&lt;InputPixelType, 2&gt; InputImageType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::Image&lt;InternalPixelType, 2&gt; InternalImageType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::Image&lt;OutputPixelType, 2&gt; OutputImageType; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::ImageFileReader&lt;InputImageType&gt; InputImageReader; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::ImageFileReader&lt;InternalImageType&gt; 
<DIV></DIV>&gt;&gt;InternalImageReader; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; typedef itk::ImageFileWriter&lt;InternalImageType&gt; 
<DIV></DIV>&gt;&gt;InternalImageWriter; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;typedef itk::ImageFileWriter&lt;OutputImageType&gt; OutputImageWriter; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;if (argc &lt; 15){ 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cerr&lt;&lt;"Incorrect usage, Correct usage being : "&lt;&lt;std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cerr&lt;&lt;"firstFilter.exe FeatureImage FrameImage 
<DIV></DIV>&gt;&gt;InitialLevelSetImage "; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cerr&lt;&lt;"sigmoidresult framesigmoidresult geodesicresult 
<DIV></DIV>&gt;&gt;thresholdresult "; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cerr&lt;&lt;"NoOfIterations&nbsp;&nbsp;sigma alpha beta pscale cscale 
<DIV></DIV>&gt;&gt;ascale "; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; std::cerr&lt;&lt;"--------------"&lt;&lt;std::endl; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp; exit(1); 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;} 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;firstFilter&lt;InputImageType, InternalImageType, OutputImageType&gt;&nbsp;&nbsp; 
<DIV></DIV>&gt;&gt;ff; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;ff.ExecuteGAC(argv[1], argv[2], argv[3], argv[4], argv[5], 
<DIV></DIV>&gt;&gt;argv[6], argv[7], atoi(argv[8]), 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;atof(argv[9]), atof(argv[10]), atof(argv[11]), 
<DIV></DIV>&gt;&gt;atof(argv[12]), atof(argv[13]), 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;atof(argv[14])) ; 
<DIV></DIV>&gt;&gt; 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; return 1; 
<DIV></DIV>&gt;&gt;} 
<DIV></DIV>&gt;&gt;---------------------------------------------------------------------------------------------------------- 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;Any suggestions please, have to finish this asap 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;with regards 
<DIV></DIV>&gt;&gt;&nbsp;&nbsp;Jayant 
<DIV></DIV>&gt;&gt; 
<DIV></DIV>&gt;&gt;------------------------------------------------------------------------ 
<DIV></DIV>&gt;&gt;Send flowers in 24 hours! At MSN Shopping. 
<DIV></DIV>&gt;&gt;&lt;http://g.msn.com/8HMAENIN/2743??PS=47575&gt; 
<DIV></DIV>&gt;&gt;_______________________________________________ Insight-users 
<DIV></DIV>&gt;&gt;mailing list Insight-users@itk.org 
<DIV></DIV>&gt;&gt;http://www.itk.org/mailman/listinfo/insight-users 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV></div><br clear=all><hr>Win a Gillette MACH3 Razor. <a href="http://g.msn.com/8HMAENIN/2728??PS=47575">Click Here. </a> </html>



More information about the Insight-users mailing list