Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development
Register FAQ Today's Posts Search

Reply
 
Thread Tools Search this Thread
Old 26th April 2005, 03:32   #1  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 916
Traversing a irregular shape closed area with islands

Given a starting point (or a straight line) within an irregular shape closed area with islands, how can one ensure that the area, excepting the islands, is fully examined (traversed)at least once? I have tried eight directional paths but find that the examination ends after getting stuck in one tight spot, where either all adjacent pixels were already examined or area is locally only one pixel wide.
I ran into this problem while developing a plugin for Avisynth and appreciate if some one can help.
__________________
mohan
my plugins are now hosted here
vcmohan is offline   Reply With Quote
Old 26th April 2005, 08:32   #2  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
Maybe a font scanline converter logic, where it converts a shape into a 'list' of lit pixels, is what you need.

I made one for 3.0 so I can explain it to you if you want.
Bidoche is offline   Reply With Quote
Old 26th April 2005, 13:47   #3  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,868
That sounds like a standard fill problem. Google for area fill algorithm.
Guest is offline   Reply With Quote
Old 27th April 2005, 03:20   #4  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 916
A lot of thanks for suggestions.
Bidoche: Will appreciate if you can explain your list process.
__________________
mohan
my plugins are now hosted here
vcmohan is offline   Reply With Quote
Old 27th April 2005, 05:20   #5  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,182
May be not directly related, but some spot detection exists in DeSpot plugin.
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 28th April 2005, 00:15   #6  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
@vcmohan

For each y (considered) you maintain two list (of x):
a list of entering transitions and a list of exiting transitions.

Then given a filling convention, you walk the shape contours to fill those lists. (May need to split the shape into line segments)

That is to say that for each y you cross, you mark the corresponding x as a entering or exiting transition, depending if you are going up or down and the filling convention chosen.

Once it is done for all contours (islands too).
For each y, you sort the entering and exiting transitions list.
Then you just have to pair entering and exiting transition together to get horizontal spans of lit pixels. (kindof 'list')

Eventually those spans may need some merging if your shape allowed overlapping of contours.


If you want to look, 3.0 code for that is in src/text/rasterizer/(Beware intensive use of the STL)
Bidoche is offline   Reply With Quote
Old 28th April 2005, 05:12   #7  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 916
Thanks. But I am not sure whether it works in the situation I am in. Let me explain further. On the image there are a number of complicated shaped closed ares, islands etc. Only a black line demarcates these boundaries. So if I traverse from outside the area, I may be entering and exiting a number of such areas and will not know which contiguous area I am in. My search is therefore starting from within the area. I must ensure that I traverse fully all that irregular area including tight spots etc without getting stuck.

I am employing an eight directional search, but as I explained above getting stuck in tight spots. It appears that if I alter the order of the directions I search, at different places I get stuck. One solution appears as 8! types of searches, which is terrible to code and may not result in a fast enough solution.

Well I am trying Google search. Yesterday while doing it my system suddenly slowed down and my Firefox behaved strange. Later I realised that it did an automatic update and all my bookmarks lost. This is just an aside. Sorry for it if I violated any rule of forum.
__________________
mohan
my plugins are now hosted here
vcmohan is offline   Reply With Quote
Old 28th April 2005, 12:54   #8  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
Quote:
Originally posted by vcmohan
Thanks. But I am not sure whether it works in the situation I am in. Let me explain further. On the image there are a number of complicated shaped closed ares, islands etc. Only a black line demarcates these boundaries. So if I traverse from outside the area, I may be entering and exiting a number of such areas and will not know which contiguous area I am in.
That logic should always work, even with extremly complex shapes.
The only flaw is that, since it tests if the pixel center is in the area, it can miss small details avoiding pixel centers.
But then it can be solved by working at a higher precision.
Bidoche is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:44.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.