AW: [Insight-users] Transform the contour from image to chaincode
V Narasinga Rao
vaiju at cse.iitb.ac.in
Thu Jul 22 10:55:41 EDT 2004
Hi Jiang,
The algorithm which I said will always end on boundry conditions and not
in between. Also once you enter the chain you can easily sort on x and
then on y. Thus you will alwyas get a contour in the chain.
Yes I accept the fact that this algo will take more time, but atleast
garuntee that you will always find a contour.
This works on the basis of filling.
Hope now it's clear. I mean I am a newbie in this field, so work on
guesses and then test. And i have tested the code that i said to you.
Regards
Vaijanath
On Thu, 22 Jul 2004, Jiang wrote:
> 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
>>
>>
>>
>
> _______________________________________________
> 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