Click here to Skip to main content
15,905,616 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Detecting codecs without DirectShow. Pin
Anthony_Yio29-Apr-04 23:11
Anthony_Yio29-Apr-04 23:11 
GeneralRe: Detecting codecs without DirectShow. Pin
Mike Dimmick30-Apr-04 2:40
Mike Dimmick30-Apr-04 2:40 
GeneralFlood fill of all image objects simultaneously Pin
Kolich29-Apr-04 20:45
Kolich29-Apr-04 20:45 
GeneralRe: Flood fill of all image objects simultaneously Pin
John R. Shaw30-Apr-04 10:55
John R. Shaw30-Apr-04 10:55 
GeneralRe: Flood fill of all image objects simultaneously Pin
Kolich4-May-04 19:11
Kolich4-May-04 19:11 
GeneralRe: Flood fill of all image objects simultaneously Pin
John R. Shaw4-May-04 20:52
John R. Shaw4-May-04 20:52 
GeneralRe: Flood fill of all image objects simultaneously Pin
Kolich4-May-04 22:23
Kolich4-May-04 22:23 
GeneralRe: Flood fill of all image objects simultaneously Pin
John R. Shaw5-May-04 9:03
John R. Shaw5-May-04 9:03 
Sounds more like a simple line scan algorithm of some sort is needed, something to how you would fill a polygon (only without knowing where the edges are first.

METHOD 1:

First you'll need a storage item something like the following:
struct bucket
{
    int x1, x2;
    struct bucket* pNext;
};

Then create an array equal to the height of the image:
bucket* pLineArray = new bucket[height];


Now start scanning at the upper left courner. When you encounter an leading edge: create a new bucket
pBucket = new bucket;
memset(pBucket,0,sizeof(bucket);

and store the location in x1 (left side of edge). Next skip over the edge, then scan until you reach the next edge. Now find the trailing edge (right side of edge) and store that in x2. Insert the bucket in the list at the current line.
void AddBucket(int nLine, bucket* pBucket)
{
    bucket* pNext;
    pNext = pLineArray[nLine];
    if( !pNext )
        pLineArray[nLine] = pNext
    else {
        while( pNext->pNext )
            pNext = pNext->pNext;
        pNext = pBucket;
    }
}

Continue to scan the line adding new buckets as you go.
NOTE: The top and bottom of each object are special cases where the left and right edges are the same (Example: a single pixel at top would contain the same values for x1 and x2.

Repeat the above for each line in the image.

Now that the information stored you can write a function to analyse the information to produce a line list for each of the individual objects.

METHOD 2:

Simulare to method 1, accept that when you encounter an edge you trace all the way around the object, storing the infomation in its own line list. Then exclude that region from futhur scanning.

This method requires multiple scans and that you maintian a list of line lists.

FINALY:
Method 1 will store the information in one pass, but requires futher anasyse to produce the final information (list of line lists).
Method 2 will probably be slower, but may be easier to code.

In either method, you would have one top level function that would be called and return a list of line lists.

I do not know if my ideas help! I do hope they give you some idea of whats envoled.

Recommend reading:
"Computer Graphics: Principles and Practice in C (2nd Edition)".
"Graphics Programming" by Michael Abrash.
The Graphics Gems books, much of the code in these books are available online.

Good Luck!

INTP
GeneralRe: Flood fill of all image objects simultaneously Pin
Kolich6-May-04 20:10
Kolich6-May-04 20:10 
GeneralRe: Flood fill of all image objects simultaneously Pin
John R. Shaw8-May-04 4:49
John R. Shaw8-May-04 4:49 
GeneralVK code for subtract Pin
Tyrus18229-Apr-04 20:24
Tyrus18229-Apr-04 20:24 
GeneralRe: VK code for subtract Pin
ohadp29-Apr-04 21:05
ohadp29-Apr-04 21:05 
GeneralThird party toolbar Pin
*Dreamz29-Apr-04 20:01
*Dreamz29-Apr-04 20:01 
GeneralRe: Third party toolbar Pin
nguyenvhn29-Apr-04 20:48
nguyenvhn29-Apr-04 20:48 
GeneralRe: Third party toolbar Pin
*Dreamz2-May-04 18:15
*Dreamz2-May-04 18:15 
QuestionCall another program from my project ?? Pin
Mughi29-Apr-04 19:45
Mughi29-Apr-04 19:45 
AnswerRe: Call another program from my project ?? Pin
GermanGeorge29-Apr-04 22:16
GermanGeorge29-Apr-04 22:16 
GeneralRe: Call another program from my project ?? Pin
Mughi29-Apr-04 22:49
Mughi29-Apr-04 22:49 
GeneralRe: Call another program from my project ?? Pin
GermanGeorge29-Apr-04 23:15
GermanGeorge29-Apr-04 23:15 
GeneralRe: Call another program from my project ?? Pin
Mughi2-May-04 19:05
Mughi2-May-04 19:05 
GeneralRe: Call another program from my project ?? Pin
Jitendra gangwar30-Apr-04 2:26
Jitendra gangwar30-Apr-04 2:26 
GeneralRe: Call another program from my project ?? Pin
Mughi2-May-04 19:07
Mughi2-May-04 19:07 
GeneralChanging cview's size .. Pin
AbinThomas29-Apr-04 19:25
AbinThomas29-Apr-04 19:25 
GeneralRe: Changing cview's size .. Pin
Anthony_Yio29-Apr-04 23:04
Anthony_Yio29-Apr-04 23:04 
GeneralRe: Changing cview's size .. Pin
AbinThomas29-Apr-04 23:55
AbinThomas29-Apr-04 23:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.