<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> </DIV>
<DIV>Finally, my code can work now.</DIV>
<DIV> </DIV>
<DIV>I have to add geodesicActiveContour->GenerateSpeedImage(). Without it, the program always shows segmentation error.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Can you please share some experience about the selection of GVF parameters for 3D images"</DIV>
<DIV> </DIV>
<DIV>> > m_GVFFilter->SetNoiseLevel(500);<BR>> > m_GVFFilter->SetTimeStep(0.05);<BR>> > m_GVFFilter->SetIterationNum(5);</DIV>
<DIV> </DIV>
<DIV>Thanks for your help.</DIV>
<DIV> </DIV>
<DIV>Baoyun<BR></DIV>
<DIV> </DIV>
<DIV><BR><BR> </DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>
<DIV style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Amardeep Singh <amar.singh@gmx.de><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Baoyun Li <baoyun_li123@yahoo.com>; insight-users@itk.org<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Friday, March 6, 2009 10:44:54 AM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: Segmenation Error--after set advection image by GVF flow<BR></FONT><BR>Dear Baoyun<BR><BR>I am not sure, I understand what you mean by saying "Since you just recently fixed the GVF as advection term".<BR>I had hacked the code, because I did not know of the flag "SetAutoGenerateSpeedAdvection(...)". In the end, I ended up using the same code as you.<BR>You might want to have a look at the full posting:<BR>http://www.nabble.com/Use-of-advection-image-to-guide-geodesic-level-set-td22083962.html#a22159804<BR><BR>Best regards<BR>Amardeep<BR><BR>Baoyun Li wrote:<BR>> Dear Amardeep:<BR>> Thank
you for your help. Since you just recently fixed the GVF as advection term, can you please send me a copy of your test code.<BR>> I saw your original code (<A href="http://gvftest.cc/" target=_blank>GVFtest.cc</A>) pasted on the web. But that is not the working version.<BR>> Thanks.<BR>> Baoyun<BR>> <BR>> ------------------------------------------------------------------------<BR>> *From:* Amardeep Singh <<A href="mailto:amar.singh@gmx.de" ymailto="mailto:amar.singh@gmx.de">amar.singh@gmx.de</A>><BR>> *To:* Baoyun Li <<A href="mailto:baoyun_li123@yahoo.com" ymailto="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</A>><BR>> *Cc:* <A href="mailto:insight-users@itk.org" ymailto="mailto:insight-users@itk.org">insight-users@itk.org</A><BR>> *Sent:* Friday, March 6, 2009 4:36:35 AM<BR>> *Subject:* Re: Segmenation Error--after set advection image by GVF flow<BR>> <BR>> Dear Baoyun<BR>>
<BR>> Unfortunately, I have not yet encountered your error message, so I am not sure, if I can help you.<BR>> I would try to save the gradient vector field as a *.vtk file, not in Analyze format, as the gradient vector flow output is a vector field. Can Analyze deal with that? (I don't know.)<BR>> Furthermore, I would suggest that you encapsulate every Update() call in a try-catch block:<BR>> try<BR>> {<BR>> ...->Update();<BR>> }<BR>> catch( itk::ExceptionObject & excep )<BR>> {<BR>> std::cerr << "Exception caught !" << std::endl;<BR>> std::cerr << excep << std::endl;<BR>> }<BR>> <BR>> This might give you more meaningful error messages.<BR>> <BR>> Best regards<BR>> Amardeep<BR>>
<BR>> Baoyun Li wrote:<BR>> > Dear All:<BR>> > The error message is: Program *received* signal *SIGFPE*, *Arithmetic exception*.<BR>> > It happens in itkImageHelp.h<BR>> > index[NLoop] = static_cast<IndexValueType>(offset / offsetTable[NLoop]);<BR>> > inline static void ComputeIndexInner(const IndexType &bufferedRegionIndex,<BR>> > OffsetValueType &offset,<BR>> > const OffsetValueType offsetTable[],<BR>> > IndexType &index,<BR>> >
const UniqueTypeBoolFalse& )<BR>> > {<BR>> > index[NLoop] = static_cast<IndexValueType>(offset / offsetTable[NLoop]);<BR>> > offset = offset - (index[NLoop] * offsetTable[NLoop]);<BR>> > index[NLoop] = index[NLoop] + bufferedRegionIndex[NLoop];<BR>> > ImageHelper<NImageDimension, NLoop-1>::<BR>> > ComputeIndexInner(bufferedRegionIndex,<BR>> > offset,<BR>> > offsetTable,<BR>> > index,<BR>> >
Concept::Detail::UniqueType_bool<(NLoop==1)>());<BR>> > }<BR>> > Does this mean some overflow, or my datatype has some problme.<BR>> > Thanks<BR>> > Baoyun<BR>> ><BR>> > > ------------------------------------------------------------------------<BR>> > *From:* Baoyun Li <<A href="mailto:baoyun_li123@yahoo.com" ymailto="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</A> <mailto:<A href="mailto:baoyun_li123@yahoo.com" ymailto="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</A>>><BR>> > *To:* Amardeep Singh <<A href="mailto:amar.singh@gmx.de" ymailto="mailto:amar.singh@gmx.de">amar.singh@gmx.de</A> <mailto:<A href="mailto:amar.singh@gmx.de" ymailto="mailto:amar.singh@gmx.de">amar.singh@gmx.de</A>>><BR>> > *Cc:* <A href="mailto:insight-users@itk.org"
ymailto="mailto:insight-users@itk.org">insight-users@itk.org</A> <mailto:<A href="mailto:insight-users@itk.org" ymailto="mailto:insight-users@itk.org">insight-users@itk.org</A>><BR>> > *Sent:* Thursday, March 5, 2009 4:51:41 PM<BR>> > *Subject:* Re: Segmenation Error--after set advection image by GVF flow<BR>> ><BR>> > Dear Amardeep:<BR>> > After I called<BR>> ><BR>> > geodesicActiveContour->SetAdvectionImage(castflowfilter->GetOutput());<BR>> > Do I need to call GenerateAdvectioniImage() since Atumatic Generate is set off.<BR>> > After I add : geodesicActiveContour->GenerateAdvectionImage();<BR>> > I still got error, please give me some suggestions.<BR>> > Baoyun<BR>> > ------------------------------------------------------------------------<BR>> > *From:* Baoyun Li <<A href="mailto:baoyun_li123@yahoo.com"
ymailto="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</A> <mailto:<A href="mailto:baoyun_li123@yahoo.com" ymailto="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo.com</A>>><BR>> > *To:* Amardeep Singh <<A href="mailto:amar.singh@gmx.de" ymailto="mailto:amar.singh@gmx.de">amar.singh@gmx.de</A> <mailto:<A href="mailto:amar.singh@gmx.de" ymailto="mailto:amar.singh@gmx.de">amar.singh@gmx.de</A>>><BR>> > *Cc:* <A href="mailto:insight-users@itk.org" ymailto="mailto:insight-users@itk.org">insight-users@itk.org</A> <mailto:<A href="mailto:insight-users@itk.org" ymailto="mailto:insight-users@itk.org">insight-users@itk.org</A>><BR>> > *Sent:* Thursday, March 5, 2009 3:25:12 PM<BR>> > *Subject:* Segmenation Error--after set advection image by GVF flow<BR>> ><BR>> > Dear Amardeep and All:<BR>> > 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->Update();<BR>> > The program stop at: itkSegmentationLevelSetFunction_txx at return ( m_AdvectionImage->GetPixel(idx) );<BR>> > template <class TImageType, class TFeatureImageType><BR>> > typename SegmentationLevelSetFunction<TImageType, TFeatureImageType>::VectorType<BR>> > SegmentationLevelSetFunction<TImageType, TFeatureImageType><BR>> > ::AdvectionField(const NeighborhoodType &neighborhood,<BR>> > const FloatOffsetType &offset, GlobalDataStruct *) const<BR>> > {<BR>> > IndexType idx = neighborhood.GetIndex();<BR>> > ContinuousIndexType cdx;<BR>> > for (unsigned i = 0; i < ImageDimension; ++i)<BR>> > {<BR>> > cdx[i] =
static_cast<double>(idx[i]) - offset[i];<BR>> > }<BR>> > if ( m_VectorInterpolator->IsInsideBuffer(cdx) )<BR>> > {<BR>> > return ( m_VectorCast(m_VectorInterpolator->EvaluateAtContinuousIndex(cdx)));<BR>> > }<BR>> > //Just return the default else<BR>> > return ( m_AdvectionImage->GetPixel(idx) );<BR>> > }<BR>> > Clearly, something is still wrong with SetAdvectionImage. Below is related code.<BR>> > Can you please help me figure out which setting is wrong?<BR>> > Thanks<BR>> > Baoyun<BR>> ><BR>> > typedef itk::CovariantVector<double, Dim> myGradientType;<BR>> > typedef itk::Image<myGradientType, Dim> myGradientImageType;<BR>> > typedef itk::GradientVectorFlowImageFilter<myGradientImageType,
myGradientImageType><BR>> > myGVFFilterType;<BR>> > typedef itk::GradientImageFilter<DoublelImageType, double,double><BR>> > myGFilterType;<BR>> > typedef itk::GradientToMagnitudeImageFilter<myGradientImageType, DoublelImageType><BR>> > myGToMFilterType;<BR>> ><BR>> > typedef itk::GradientRecursiveGaussianImageFilter<<BR>> >
DoublelImageType,<BR>> > myGradientImageType<BR>> > > myFilterType;<BR>> > typedef typename GeodesicActiveContourFilterType::VectorImageType AdvectionImageType;<BR>> > typedef itk::CastImageFilter<myGradientImageType,AdvectionImageType><BR>> > CastFlowFilterType;<BR>> > typedef itk::LaplacianImageFilter<DoublelImageType, DoublelImageType> myLaplacianFilterType;<BR>> > typename myFilterType::Pointer filter = myFilterType::New();<BR>> >
typename myGFilterType::Pointer gfilter = myGFilterType::New();<BR>> > typename myGToMFilterType::Pointer gtomfilter = myGToMFilterType::New();<BR>> > typename myLaplacianFilterType::Pointer m_LFilter = myLaplacianFilterType::New();<BR>> > typename myGVFFilterType::Pointer m_GVFFilter = myGVFFilterType::New();<BR>> > typename CastFlowFilterType::Pointer castflowfilter = CastFlowFilterType::New();<BR>> > typedef itk::ImageFileWriter< myGradientImageType > WriterType2;<BR>> > typename WriterType2::Pointer writer21=WriterType2::New();<BR>> > > typename WriterType1::Pointer writer4=WriterType1::New();<BR>> > writer4->SetInput(caster11->GetOutput());<BR>> > writer4->SetFileName("../data/intial_contour.hdr");<BR>> > writer4->Update();<BR>> ><BR>> > sigmoid->SetOutputMinimum( 0.0
);<BR>> > sigmoid->SetOutputMaximum( 1.0 );<BR>> > caster12->SetInput(inputfilter);<BR>> > smoothing->SetInput(caster12->GetOutput() );<BR>> > gradientMagnitude->SetInput( smoothing->GetOutput() );<BR>> > sigmoid->SetInput( gradientMagnitude->GetOutput() );<BR>> > caster31->SetInput(inputfilter);<BR>> > filter->SetInput( caster31->GetOutput() ); //caster short to double<BR>> > filter->SetSigma( 1.0);<BR>> > filter->Update();<BR>> > gtomfilter->SetInput(filter->GetOutput());<BR>> > gtomfilter->Update();<BR>> > gfilter->SetInput(gtomfilter->GetOutput());<BR>> > gfilter->Update();<BR>> > m_GVFFilter->SetInput(gfilter->GetOutput());<BR>> > m_GVFFilter->SetLaplacianFilter(m_LFilter);<BR>> >
m_GVFFilter->SetNoiseLevel(500);<BR>> > m_GVFFilter->SetTimeStep(0.05);<BR>> > m_GVFFilter->SetIterationNum(5);<BR>> > m_GVFFilter->Update();<BR>> > writer21->SetInput(m_GVFFilter->GetOutput());<BR>> > writer21->SetFileName("../data/GVF_flow.hdr");<BR>> > writer21->Update();<BR>> > //to get gradient manitude of GVF low<BR>> > geodesicActiveContour->SetAutoGenerateSpeedAdvection(false);<BR>> > //typename myGradientImageType::Pointer m_GVFField;<BR>> > //m_GVFField = m_GVFFilter->GetOutput();<BR>> > castflowfilter->SetInput(m_GVFFilter->GetOutput());<BR>> > geodesicActiveContour->SetAdvectionImage(castflowfilter->GetOutput());<BR>> > // geodesicActiveContour->GenerateSpeedImage();<BR>> >
//geodesicActiveContour->SetAdvectionImage(m_GVFFilter->GetOutput());<BR>> > geodesicActiveContour->SetInput( caster11->GetOutput() );<BR>> > geodesicActiveContour->SetFeatureImage( sigmoid->GetOutput() );<BR>> > geodesicActiveContour->GenerateSpeedImage();<BR>> > geodesicActiveContour->Update();<BR>> > thresholder->SetInput( geodesicActiveContour->GetOutput() );<BR>> > thresholder->Update();<BR>> > outputfilter=thresholder->GetOutput();<BR>> ><BR>> ><BR>> ><BR>> ><BR>> <BR></DIV></DIV></div><br>
</body></html>