Well, I've managed to reduce it to 20 minutes with a 3d extension of the queue-based scanline flood fill algorithm. I don't know how much better it can get, as it's filling a very complex shape.
Main Topics
Browse All TopicsI have tested several flood fill algorithms in 2D, as outlined at:
http://www.academictutoria
Basically, I have successfully implemented 2D flood fills (4-way) with recursion, stacks, and scanline -stack implementations.
I have also extended the first two (recursion and stack) to 3D, allowing me to flood fill volume-based-images in matlab, which I later render in 3D. However, I have a large 3D image, 256x256x128, leading to 8,388,608 voxels. With my stack-based implementation, it takes ages to fill a small portion of the 3D image, hours even. Does anyone have any background in 3D flood fill algorithms? I've tried extending the quickfill and scanline-fill algorithms to 3D with little gain.
Thank you.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Seems very interesting what you are doing, so I'd like to understand it better, not only to try to support you, but also to satisfy my curiosity...
Voxel computation is very hard and, if you could avoid filling the interior voxels of a model (anyway they are not visible), then you can reduce drasticaly the run time. A first approach occur to me is to found the 3D convex hull and to work only with the "external" voxels.
Is it feasible? If the 3D shapes are non-convex ones, then it is more complicated...
Jose
I did it :)
After studying a few books on the subject, I was able to re-implement a 3D extension of the 2D 4N (4 neighbours) scanline algorithm to create a 3D-6N scan-column algorithm. Although it's mainly adding an extra dimension, I spent a LOT of time making sure that I can use vector addressing to fill almost entire "rows" (actually, it's more like an intersection of 3 lines, kind of like the x-y-z axes). If anyone's interested, let me know.
Basically, the 3D recursive version works only for VERY tiny areas, as a 20x20x20 voxel volume along can cause a stack overflow and crash MATLAB. The stack-based non-recursive one took 25 hours. My unoptimized 3D queue-based one took 17 hours. The optimized 3D scanline extension took about 40 minutes, and now this modified optimized 3d scan-column one is processing 8M voxels in 10 minutes :)
The author asks if anyone has experience with 3D flood algorithms. My answer is: yes, I do.
Of course, this is not the objective of the question, supposed to discover how to make the 3D flood in acceptable times.
I made a software to construct 3D structures to represent petroleum reservoirs, by using voxels, which could be set to specific colors and a transparency. The rendering times for equivalent structures as the one in the question were around 10 seconds, with the resources I had in 1991 (an IBM 5086 workstation), so I think we can expect less than 1 second today.
I have no objections to the author to close the question, despite my deception in not following in it.
Jose
Business Accounts
Answer for Membership
by: JoseParrotPosted on 2009-08-18 at 21:15:53ID: 25129575
Voxel computing always is expensive, as you have experienced by yourself;
It is common to avoid such approach, except if you are interested in 3D layers, as onion layers, for exemple, for 3d representation of petroleum reservoirs where you can turn some materials (sand, water, petroleum, etc.) into transparent ones. Or to simulate physics phenomena as mass, weight, density. If it is not the case, then it is better to model the objects as 3d meshes then applying colors to them.
Please clarify to us: what is a 3d image? What is the content of the voxels: colors? weights? Can you please show a result of one after the filling:
Anyway, as per your description, if a small 3d region of 256x256x128 voxels spends hours to fill it, then seems the inner loop procedure is wrong. I mean "inner" the algorithm to be performed inside a series of loops, tipically
for x...
for y...
for z
function F
next
next
next
where function F is the function to be executed x y z times.
If such inner function is a graphics call like SETPIXEL then it will be extremely slow.
Jose