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

Jiang jiang at TI.Uni-Trier.DE
Thu Jul 22 10:31:14 EDT 2004


Hi Vaijanath,
Thank you for your kind help.
It seems that the only difference between my solution and yours are
starting point. My starting point is at one point of the contour. But
your starting point is at the center of the image. And I need the points
in the chain code are successive in the contour.
I observe my executed result and find that the stopped point in
uncompleted case is not because it reaches the boundary of the image.
And this stop point is SAME as other found contour points or unfound
contour points.
This is quite strange.

Best regards,

Jiang


-----Ursprüngliche Nachricht-----
Von: V Narasinga Rao [mailto:vaiju at cse.iitb.ac.in] 
Gesendet: Donnerstag, 22. Juli 2004 16:07
An: Jiang
Cc: ITK
Betreff: Re: [Insight-users] Transform the contour from image to
chaincode

Hi Jiang,

May be this solution works.

Since you said your image is a binary that is either 0 or 100. Now here
is 
my pseudo code.

1. start at center. if image is 100,100 then start at 50,50.
2. Now look at 8 neighbours from center, if the pixel value is 100 then 
for this entry mark 0 in your chain and repeat for all the pixels 
recursively. till either you cross the boundry of the image.
3. i.e. you will stop only if you have reached the boundry.

4. in your chain list you will have all the pixels which are in contour.

Yes one thing this means that you need to sacn the image excatly once.

Hope this help you out. In case you aren't able t o get this, let me
know 
i will send you the code.

Regards
Vaijanath

On Thu, 22 Jul 2004, 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
>
>
>



More information about the Insight-users mailing list