[Insight-users] Transform the contour from image to chaincode

Reinhold Füreder R.Fureder at exeter.ac.uk
Fri Jul 23 07:23:06 EDT 2004


Hi Jiang,

The reason for its stopping looks quite obvious with this extensive
trace output - as usually Luis' idea was more or less already the
solution ;-)

When the algorithm finds the "center point 100" all its neighbourhood
looks like it was finished. In fact, the algorithm should continue at
the second last point (so-called "above 100") now.

Thus, your algorithm requires one little "enhancement": use a stack with
coordinates/indices of found contour points if they have still
neighbouring contour points not being found. Consequently you should
have the "above 100" at the top of your stack when the algorith stops at
the "center point 100", hence, the algorithm should then continue with
the top element of the stack and it is only finished when the original
algorithm stops AND the stack is empty.

HTH and I have not missed anything,
    Reinhold

> -----Original Message-----
> From: insight-users-bounces at itk.org 
> [mailto:insight-users-bounces at itk.org] On Behalf Of Jiang
> Sent: Friday, July 23, 2004 12:46 PM
> To: 'Luis Ibanez'
> Cc: ITK
> Subject: AW: [Insight-users] Transform the contour from image 
> to chaincode
> 
> 
> Hi Luis,
> I tried one contour image and the searching always stops at 
> one point prematurely. I paste the 7*7 neighbor of this point 
> at the original contour image. The center point "100" is the 
> stop point. And it above "100" and right three "100" are 
> found points. It left two "100" are not found points.
> 
> End Point is at    138     160
>     0    100    0    0    100    0    0
>     0    0    100    0    100    0    0
>     0    0    0    100    100    0    0
>     0    0    0    100    0    0    0
>     0    0    0    0    0    0    0
>     0    0    0    0    0    0    0
>     0    0    0    0    0    0    0
> 
> And the contour image is as the attachment. Now I find out 
> why it stops. It is good method to find out the problem. 
> Thank you. But I still struggle to figure it out.
> 
> 
> 
> Best regards,
> 
> Jiang
> -----Ursprüngliche Nachricht-----
> Von: insight-users-bounces at itk.org 
> [mailto:insight-users-bounces at itk.org] Im Auftrag von Luis Ibanez
> Gesendet: Donnerstag, 22. Juli 2004 17:12
> An: Jiang
> Cc: ITK
> Betreff: Re: [Insight-users] Transform the contour from image 
> to chaincode
> 
> 
> Hi Jiang,
> 
> Please do the following:
> 
> 
> 1) Identify the pixel were your algorithm is
>     stopping prematurely
> 
> 
> 2) Go to the same index in the original image,
>     where you have the contour in 0 and 100 values.
>     (e.g. the image as it is before you set any
>      of the contour points to zero).
> 
> 3) Take a 7x7 neighbor centered on this pixel
>     and post all the values of this neighbor
>     (arranged in a matrix) to the users-list.
> 
> 
> 
> Thanks
> 
> 
>    Luis
> 
> 
> 
> ---------------------
> Jiang wrote:
> 
> > Hi, all,
> > 
> > By some filters of itk, I get one closed contour as one image. This
> > image is one binary image that
> > 
> > the pixel value is 100 when is pixel is in the contour, otherwise it
> is 0.
> > 
> > Now I want to convert this contour to ChainCode. My pseudocode is as
> follow:
> > 
> >  
> > 
> >   Search the image from the first pixel to find the first 
> point in the
> 
> > contour;
> > 
> >   Add this point to ChainCode list, and set its value to 0;
> > 
> >   Search the immediate neighbors of of this point to check 
> if it is on
> 
> > contour;
> > 
> >          If this point’s value==100;
> > 
> >          {        Add it to ChainCode, and set its value to 0;
> > 
> >                    Loop searching
> > 
> >          }
> > 
> >          else
> > 
> >                    Stop searching;
> > 
> >                    Finish the ChainCode;
> > 
> >  
> > 
> > // The order of checking neighbors. Assume the current points is at
> “0”.
> > 
> > //    ------------------------    
> > 
> > //   |  5  |  3  |  8  |
> > 
> > //   |-------------------------|
> > 
> > //   |  1  |  0  |  2  |
> > 
> > //   |-------------------------|
> > 
> > //   |  7  |  4  |  6  |
> > 
> > //    -----------------------
> > 
> >  
> > 
> > This searching method works, but not always. Sometime, it stops at
> > somewhere, but the contour is
> > 
> > not completed. And the stopped point is not different as other found
> > points. I even enlarge the
> > 
> > neighbourhood to a bigger circle. But it is still not stable.
> > 
> >  
> > 
> > Maybe my question is beyond the range of this itk maillist. 
> I’m really
> 
> > upset with this problem.
> > 
> > Who can give me some suggestions?
> > 
> >  
> > 
> > Thanks a lot!
> > 
> >  
> > 
> >  
> > 
> > Jiang
> > 
> >  
> > 
> >  
> > 
> > 
> >
> --------------------------------------------------------------
> ----------
> > 
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org 
> > http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org 
> http://www.itk.org/mailman/listinfo/insight-> users
> 



More information about the Insight-users mailing list