<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>Dear Amardeep:</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV>
<DIV>&nbsp;</DIV>
<DIV>After I called</DIV><BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;geodesicActiveContour-&gt;SetAdvectionImage(castflowfilter-&gt;GetOutput()); </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Do&nbsp;I need to call GenerateAdvectioniImage() since Atumatic Generate&nbsp;is set off.</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">After I add&nbsp;: geodesicActiveContour-&gt;GenerateAdvectionImage();</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">I still got error, please give me some suggestions.</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Baoyun<BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Baoyun Li &lt;baoyun_li123@yahoo.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Amardeep Singh &lt;amar.singh@gmx.de&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">Cc:</SPAN></B> insight-users@itk.org<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Thursday, March 5, 2009 3:25:12 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Segmenation Error--after set advection image by GVF flow<BR></FONT><BR>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV>Dear Amardeep and All:</DIV>
<DIV>&nbsp;</DIV>
<DIV>Now I can build the program after seting advection image by GVF flow. However, when I run the program, the program shows segmeation error when geodesicActiveContour-&gt;Update();<BR></DIV>
<DIV>The program stop at: itkSegmentationLevelSetFunction_txx&nbsp; at&nbsp; return ( m_AdvectionImage-&gt;GetPixel(idx) );<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV>template &lt;class TImageType, class TFeatureImageType&gt;<BR>typename SegmentationLevelSetFunction&lt;TImageType, TFeatureImageType&gt;::VectorType<BR>SegmentationLevelSetFunction&lt;TImageType, TFeatureImageType&gt;<BR>::AdvectionField(const NeighborhoodType &amp;neighborhood,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const FloatOffsetType &amp;offset, GlobalDataStruct *)&nbsp; const<BR>{<BR>&nbsp; IndexType idx = neighborhood.GetIndex();<BR>&nbsp; ContinuousIndexType cdx;<BR>&nbsp; for (unsigned i = 0; i &lt; ImageDimension; ++i)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; cdx[i] = static_cast&lt;double&gt;(idx[i]) - offset[i];<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; if ( m_VectorInterpolator-&gt;IsInsideBuffer(cdx) )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; return ( m_VectorCast(m_VectorInterpolator-&gt;EvaluateAtContinuousIndex(cdx)));<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; //Just return the
 default else<BR>&nbsp;&nbsp;&nbsp; return ( m_AdvectionImage-&gt;GetPixel(idx) );<BR>&nbsp; <BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>Clearly, something is still wrong with SetAdvectionImage. Below is related code.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Can you please help me figure out which setting is wrong? </DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks</DIV>
<DIV>&nbsp;</DIV>
<DIV>Baoyun</DIV>
<DIV><BR>&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp; typedef itk::CovariantVector&lt;double, Dim&gt; myGradientType;<BR>&nbsp; typedef itk::Image&lt;myGradientType, Dim&gt;&nbsp;&nbsp; myGradientImageType;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp; typedef itk::GradientVectorFlowImageFilter&lt;myGradientImageType, myGradientImageType&gt;<BR>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myGVFFilterType;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp; typedef itk::GradientImageFilter&lt;DoublelImageType, double,double&gt;<BR>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myGFilterType;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp; typedef itk::GradientToMagnitudeImageFilter&lt;myGradientImageType, DoublelImageType&gt;<BR>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myGToMFilterType;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>&nbsp; typedef itk::GradientRecursiveGaussianImageFilter&lt;<BR>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DoublelImageType,<BR>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 myGradientImageType<BR>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&nbsp; myFilterType;<BR>&nbsp; typedef typename GeodesicActiveContourFilterType::VectorImageType&nbsp;&nbsp; AdvectionImageType; <BR>&nbsp; typedef itk::CastImageFilter&lt;myGradientImageType,AdvectionImageType&gt; <BR>&nbsp;&nbsp; CastFlowFilterType;<BR>&nbsp; typedef itk::LaplacianImageFilter&lt;DoublelImageType, DoublelImageType&gt; myLaplacianFilterType;<BR>&nbsp; typename myFilterType::Pointer filter = myFilterType::New();<BR>&nbsp; typename myGFilterType::Pointer gfilter = myGFilterType::New();<BR>&nbsp; typename myGToMFilterType::Pointer gtomfilter = myGToMFilterType::New();<BR>&nbsp; typename myLaplacianFilterType::Pointer
 m_LFilter = myLaplacianFilterType::New();<BR>&nbsp; typename myGVFFilterType::Pointer m_GVFFilter = myGVFFilterType::New();<BR>&nbsp; typename CastFlowFilterType::Pointer castflowfilter = CastFlowFilterType::New(); </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp; typedef itk::ImageFileWriter&lt; myGradientImageType &gt;&nbsp; WriterType2;<BR>&nbsp; typename WriterType2::Pointer writer21=WriterType2::New(); <BR>&nbsp; </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>&nbsp; typename WriterType1::Pointer writer4=WriterType1::New();<BR>&nbsp; writer4-&gt;SetInput(caster11-&gt;GetOutput());<BR>&nbsp; writer4-&gt;SetFileName("../data/intial_contour.hdr");<BR>&nbsp; writer4-&gt;Update();</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>&nbsp; sigmoid-&gt;SetOutputMinimum(&nbsp; 0.0&nbsp; );<BR>&nbsp; sigmoid-&gt;SetOutputMaximum(&nbsp; 1.0&nbsp; );<BR>&nbsp; caster12-&gt;SetInput(inputfilter);<BR>&nbsp; smoothing-&gt;SetInput(caster12-&gt;GetOutput() );<BR>&nbsp; gradientMagnitude-&gt;SetInput( smoothing-&gt;GetOutput() );<BR>&nbsp; sigmoid-&gt;SetInput( gradientMagnitude-&gt;GetOutput() );</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp; caster31-&gt;SetInput(inputfilter);<BR>&nbsp; filter-&gt;SetInput( caster31-&gt;GetOutput() ); //caster short to double<BR>&nbsp; filter-&gt;SetSigma( 1.0);<BR>&nbsp; filter-&gt;Update();<BR>&nbsp; gtomfilter-&gt;SetInput(filter-&gt;GetOutput());<BR>&nbsp; gtomfilter-&gt;Update();<BR>&nbsp; gfilter-&gt;SetInput(gtomfilter-&gt;GetOutput());<BR>&nbsp; gfilter-&gt;Update();<BR>&nbsp; m_GVFFilter-&gt;SetInput(gfilter-&gt;GetOutput());<BR>&nbsp; m_GVFFilter-&gt;SetLaplacianFilter(m_LFilter);<BR>&nbsp; m_GVFFilter-&gt;SetNoiseLevel(500);<BR>&nbsp; m_GVFFilter-&gt;SetTimeStep(0.05);<BR>&nbsp; m_GVFFilter-&gt;SetIterationNum(5);<BR>&nbsp; m_GVFFilter-&gt;Update();<BR>&nbsp; writer21-&gt;SetInput(m_GVFFilter-&gt;GetOutput());<BR>&nbsp; writer21-&gt;SetFileName("../data/GVF_flow.hdr");<BR>&nbsp; writer21-&gt;Update();<BR>//to get gradient manitude of GVF low</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;<BR>&nbsp; geodesicActiveContour-&gt;SetAutoGenerateSpeedAdvection(false);<BR>&nbsp; //typename myGradientImageType::Pointer m_GVFField; <BR>&nbsp; //m_GVFField = m_GVFFilter-&gt;GetOutput();<BR>&nbsp; castflowfilter-&gt;SetInput(m_GVFFilter-&gt;GetOutput()); <BR>&nbsp; geodesicActiveContour-&gt;SetAdvectionImage(castflowfilter-&gt;GetOutput()); <BR>&nbsp;// geodesicActiveContour-&gt;GenerateSpeedImage(); <BR>&nbsp; //geodesicActiveContour-&gt;SetAdvectionImage(m_GVFFilter-&gt;GetOutput()); </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;<BR>&nbsp; <BR>&nbsp;&nbsp; </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;&nbsp; </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp; <BR>&nbsp; geodesicActiveContour-&gt;SetInput( caster11-&gt;GetOutput() );<BR>&nbsp; geodesicActiveContour-&gt;SetFeatureImage( sigmoid-&gt;GetOutput() );<BR>&nbsp; geodesicActiveContour-&gt;GenerateSpeedImage(); <BR>&nbsp; geodesicActiveContour-&gt;Update();<BR>&nbsp; thresholder-&gt;SetInput( geodesicActiveContour-&gt;GetOutput() );<BR>&nbsp; thresholder-&gt;Update();<BR>&nbsp; outputfilter=thresholder-&gt;GetOutput();<BR></DIV></DIV><BR></DIV></DIV><BR></DIV></DIV></div><br>

      </body></html>