[Insight-users] SimpleFuzzyConnectednessScalarImageFilter

Zein Salah salah@gris.uni-tuebingen.de
Fri, 27 Sep 2002 16:49:03 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0177_01C26645.C9318EC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks Luis, I have discovered it by debugging my program.


Interesting Note:

I have read the paper (In the paper (Fuzzy Connectedness and Object =
Definition:  Theory, Algorithms, and Applications in Image=20
Segmentation",  J. Udupa and S. Samarasekera), page 259, it is stated =
that there are two version of the algorithm. One requires on some =
machine about 20 min for an image of 256x256x64, and the other version =
requires only 2 minutes  for the same image.=20
I have tried to discover which version is implemented in the ITK filter. =
I think it is the slow algorithm.=20
However I tried to modify the code in the =
itkSimpleFuzzyConnectednessImageFilterBase.txx file to the faster =
implementation
I just added an if statement, just like the fast algorithm in the paper. =
The filter with this modification required 1.5 minute instead of about =
40 minutes. Here is what I have done:

the original code:


template <class TInputImage, class TOutputImage>
void=20
SimpleFuzzyConnectednessImageFilterBase<TInputImage,TOutputImage>
::GenerateData()
{...
...
...
  while(! m_Queue.empty()) {
    current =3D m_Queue.front();
    m_Queue.pop();

       fmax =3D (unsigned short)(FindStrongPath(current));
       if(fmax > m_FuzzyScene->GetPixel(current)) {
          m_FuzzyScene->SetPixel(current,fmax);
          PushNeighbors(current);
       }
  }

  MakeSegmentObject();
}

The new code is:

template <class TInputImage, class TOutputImage>
void=20
SimpleFuzzyConnectednessImageFilterBase<TInputImage,TOutputImage>
::GenerateData()
{...
...
...
  while(! m_Queue.empty()) {
    current =3D m_Queue.front();
    m_Queue.pop();
=20
    // this is just what I did, something like what the paper suggests
    if ( m_FuzzyScene->GetPixel(current) < 1.0 ) {                    =20
       fmax =3D (unsigned short)(FindStrongPath(current));
       if(fmax > m_FuzzyScene->GetPixel(current)) {
          m_FuzzyScene->SetPixel(current,fmax);
          PushNeighbors(current);
       }
    }
  }

  MakeSegmentObject();
}

The resulter segmented image is somehow not correct. some areas are =
segmented good, others are not. I have expreimnted with different values =
intead of of the 0.1, The result did not improve.=20

Do you have an idea what could the problem be? Could you please test the =
new code on 3D- images. Perhaps you can see the results and compare the =
times.=20
What could be done to get the correct value for this if-statement.


Thanks,
Zein




->8<------------->8<------------->8<------------->8<------------->8<-----=
-------->8<-
Zein I. Salah=20
Universit=E4t T=FCbingen, WSI-GRIS=20
Sand 14=20
72076 T=FCbingen=20
Email: salah@gris.uni-tuebingen.de  / zeinsalah@hotmail.com
Tel.: (07071) 29 75465 (GRIS) , (07071) 96 44 39 (privat)=20
Fax: (07071) 29 54 66

------=_NextPart_000_0177_01C26645.C9318EC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4807.2300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV>Thanks Luis, I have discovered it by debugging my program.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG><FONT size=3D3><U>Interesting =
Note:</U></FONT></STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV>I have read the paper (In the paper (Fuzzy Connectedness and Object =

Definition:&nbsp; Theory, Algorithms, and Applications in Image=20
<BR>Segmentation",&nbsp; J. Udupa and S. Samarasekera), page 259, it is =
stated=20
that there are two&nbsp;version of the algorithm. One requires on some =
machine=20
about 20 min for&nbsp;an image of 256x256x64, and the other version =
requires=20
only 2 minutes&nbsp; for the same image. </DIV>
<DIV>I have tried to discover which version is implemented in the ITK =
filter. I=20
think it is the slow algorithm. </DIV>
<DIV>However I tried to modify the code in the=20
itkSimpleFuzzyConnectednessImageFilterBase.txx file to the faster=20
implementation</DIV>
<DIV>I just added an if statement, just like the fast algorithm in the =
paper.=20
The filter with this modification required <U>1.5 minute</U> instead of =
about=20
<U>40 minutes</U>. Here is what I have done:</DIV>
<DIV>&nbsp;</DIV>
<DIV>the original code:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff>template &lt;class TInputImage, class=20
TOutputImage&gt;<BR>void=20
<BR>SimpleFuzzyConnectednessImageFilterBase&lt;TInputImage,TOutputImage&g=
t;<BR>::GenerateData()<BR>{...</FONT></DIV>
<DIV><FONT color=3D#0000ff>...</FONT></DIV>
<DIV><FONT color=3D#0000ff>...</FONT></DIV>
<DIV><FONT color=3D#0000ff>&nbsp; while(! m_Queue.empty()) =
{<BR>&nbsp;&nbsp;&nbsp;=20
current =3D m_Queue.front();<BR>&nbsp;&nbsp;&nbsp;=20
m_Queue.pop();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fmax =3D =
(unsigned=20
short)(FindStrongPath(current));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
if(fmax=20
&gt; m_FuzzyScene-&gt;GetPixel(current))=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
m_FuzzyScene-&gt;SetPixel(current,fmax);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
PushNeighbors(current);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}</FONT></DIV>
<DIV><FONT color=3D#0000ff>&nbsp; }</FONT></DIV>
<DIV><FONT color=3D#0000ff></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff>&nbsp; MakeSegmentObject();<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>The new code is:</DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV><FONT color=3D#0000ff>template &lt;class TInputImage, class=20
TOutputImage&gt;<BR>void=20
<BR>SimpleFuzzyConnectednessImageFilterBase&lt;TInputImage,TOutputImage&g=
t;<BR>::GenerateData()<BR>{...</FONT></DIV>
<DIV><FONT color=3D#0000ff>...</FONT></DIV>
<DIV><FONT color=3D#0000ff>...</FONT></DIV>
<DIV><FONT color=3D#0000ff>&nbsp; while(! m_Queue.empty()) =
{<BR>&nbsp;&nbsp;&nbsp;=20
current =3D m_Queue.front();<BR>&nbsp;&nbsp;&nbsp; =
m_Queue.pop();</FONT></DIV>
<DIV><FONT color=3D#0000ff><FONT =
color=3D#ff0000>&nbsp;</FONT></FONT></DIV>
<DIV><FONT color=3D#0000ff><FONT color=3D#ff0000>&nbsp;&nbsp;&nbsp; // =
this is just=20
what I did, something like what the paper suggests</FONT><BR><FONT=20
color=3D#ff0000>&nbsp;&nbsp;&nbsp; if ( =
m_FuzzyScene-&gt;GetPixel(current) &lt;=20
<U>1.0</U> )=20
{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;</FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</FONT></DIV>
<DIV><FONT color=3D#0000ff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fmax =3D =
(unsigned=20
short)(FindStrongPath(current));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
if(fmax=20
&gt; m_FuzzyScene-&gt;GetPixel(current))=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
m_FuzzyScene-&gt;SetPixel(current,fmax);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
PushNeighbors(current);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR><FONT=20
color=3D#ff0000>&nbsp;&nbsp;&nbsp; }<BR></FONT>&nbsp; }</FONT></DIV>
<DIV><FONT color=3D#0000ff></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff>&nbsp; =
MakeSegmentObject();<BR>}</FONT></DIV></DIV>
<DIV><FONT color=3D#0000ff></FONT>&nbsp;</DIV>
<DIV>The resulter segmented image is somehow not correct. some areas are =

segmented good, others are not. I have expreimnted with different values =
intead=20
of of the <FONT color=3D#ff0000><U>0.1</U></FONT>, The result did not =
improve.=20
</DIV>
<DIV>&nbsp;</DIV>
<DIV>Do you have an idea what could the problem be? Could you please =
test the=20
new code on 3D- images. Perhaps you can see the results and compare the =
times.=20
</DIV>
<DIV>What could be done to get the correct value for this =
if-statement.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks,</DIV>
<DIV>Zein</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>-&gt;8&lt;-------------&gt;8&lt;-------------&gt;8&lt;----------=
---&gt;8&lt;-------------&gt;8&lt;-------------&gt;8&lt;-<BR>Zein=20
I. Salah <BR>Universit=E4t T=FCbingen, WSI-GRIS <BR>Sand 14 <BR>72076 =
T=FCbingen=20
<BR>Email: <A=20
href=3D"mailto:salah@gris.uni-tuebingen.de">salah@gris.uni-tuebingen.de</=
A>&nbsp;=20
/ <A =
href=3D"mailto:zeinsalah@hotmail.com">zeinsalah@hotmail.com</A><BR>Tel.: =

(07071) 29 75465 (GRIS) , (07071) 96 44 39 (privat) <BR>Fax: (07071) 29 =
54=20
66</FONT></DIV></BODY></HTML>

------=_NextPart_000_0177_01C26645.C9318EC0--