LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Floodfill Algorithm

Hi,
 
I need a floodfill algorithm in LabVIEW version 7.1 that uses purely LabVIEW commands, no CINs or DLLs.  I'd use IMAQ, but it is too complicated to use, and also I don't have the full package.  If I could just get the algorithm, because I don't need a subvi, just something that can perform floodfill.  I would really appreciate your help!  Thanks!
 
7J1L1M
0 Kudos
Message 1 of 19
(5,103 Views)

"7J1L1M" <x@no.email> wrote in message news:1162942807406-437957@exchange.ni.com...
Hi,
&nbsp;
I need a floodfill algorithm in LabVIEW version 7.1 that uses purely LabVIEW commands, no CINs or DLLs.&nbsp; I'd use IMAQ, but it is too complicated to use, and also I don't have the full package.&nbsp; If I could just get the algorithm, because I don't need a subvi, just something that can perform floodfill.&nbsp; I would really appreciate your help!&nbsp; Thanks!
&nbsp;
7J1L1M




http://en.wikipedia.org/wiki/Flood_fill


Regards,


Wiebe.
0 Kudos
Message 2 of 19
(5,090 Views)

Thanks Wiebe.  Would someone else have a LabVIEW program as well?  Smiley Indifferent

7J1L1M

0 Kudos
Message 3 of 19
(5,082 Views)

"7J1L1M" <x@no.email> wrote in message news:1162995008897-438264@exchange.ni.com...
Thanks Wiebe.&nbsp; Would someone else have a LabVIEW program as well?&nbsp; Smiley Indifferent
7J1L1M



OK, I though that was to easy..


Why do you need the algorithm? Is it just to color the picture? Do you need the total nr of connecting pixels?


Also important... How fast should it be?


Normally, I'd use NI Vision to do a threshold (bandpass) on the color, and then a blob analysis. That would get you you the same result as a floodfill.


Here is some source code, but it's in C. Converting it to LabVIEW can be tricky (if it has to be fast):


http://student.kuleuven.be/~m0216922/CG/floodfill.html


Here's some in depth information:


http://www.math.tau.ac.il/~dcor/Graphics/cg-slides/flood-fill03.pdf


Regards,


Wiebe.
0 Kudos
Message 4 of 19
(5,068 Views)

Wiebe,

Thanks for you reply.  I have two main reasons for the floodfill thing.  For one program, I need it for a picture editor, but I can't use IMAQ (hard to use) and I don't have quite all the commands.  I also need to use the algorithm to tailor up a mask for a picture interface.  I was also hoping to use something that doesn't require outside files (just in case it causes a computer failure, my LabVIEW doesn't seem to like them very much...).  I will try the C-Code, but how would I implement it into LabVIEW?  I am not very good at the DLL interface node, everytime I do it myself, I always mess up.  Thanks for your help, and I look forward to your next email.

7J1L1M

0 Kudos
Message 5 of 19
(5,061 Views)

Oh, sorry, I forgot to specify the speed and other things.

I would prefer it to be a nice, fast, and simple algorithm.

Also, I need its sensitivity to be definable (4 and 8 connectivity).  Sorry I forgot to say that!

 

7J1L1M

0 Kudos
Message 6 of 19
(5,059 Views)

Ok... It's not that hard. Just don't try to do it with recursion, that would complicate things a lot! I might want to use the algorithm myself, so I made the vi. Although it spoils your fun of making the vi, I'll post it here.

 

This implementation uses the naive, simple algorithm. The scanline algorithm should be much ("orders of magnitude", wikipedia) faster, but harder to implement. So simple and fast are, as often, mutualy exclusive.

 

Regards,

 

Wiebe.

 

Message 7 of 19
(5,039 Views)

Wow!  Thanks!  Smiley Very Happy

I was trying to make something that would recursively follow the outline of the fill thing.  Would that have worked as well?  Thanks again!

7J1L1M

0 Kudos
Message 8 of 19
(5,034 Views)

By the way, I tried out the floodfill vi.  It works great, but at first it seemed to have trouble coloring in a line when it got long.  This was when the pixel selector was set to 8 and the line I tried to floodfill was at a 45 degree angle.  It only partially colored it, then its like it got to a limit of pixels it could color in.  Now it suddenly works.  Maybe it was just me, but just in case, I thought you should know.  Other than that, it works great!  Thanks again!

7J1L1M

0 Kudos
Message 9 of 19
(5,026 Views)

"7J1L1M" <x@no.email> wrote in message news:1163085009236-438967@exchange.ni.com...
Wow!&nbsp; Thanks!&nbsp; Smiley Very Happy
I was trying to make something that would recursively follow the outline of the fill thing.&nbsp; Would that have worked as well?&nbsp; Thanks again!
7J1L1M



This problem seems very simple. But searching the web, you'll soon find that great mind have thought about it (over and over again). I think that inventing a fast, low memory profile, elegant algorithm would get you noticed. I didn't even try to come up with something for myself.


Following an outline is tricky, because (for one) there might be an area inside the outlined area that should not be filled.


While testing, I thought it didn't work. It turned out I didn't pick the same color, althought they looked the same. Perhaps that happened to you too (in the other thread). Otherwise I don't know what it might have been.


Regards,


Wiebe.
0 Kudos
Message 10 of 19
(5,014 Views)