a working non-recursive floodfill algorithm written in C?

后端 未结 12 2225
日久生厌
日久生厌 2020-12-02 23:39

I\'ve been trying to find a working floodfill algorithm. Of the many algorithms I\'ve tried only the \'recursive line fill\' one behaves exactly as it should with the major

12条回答
  •  醉梦人生
    2020-12-03 00:30

    We noticed that our floodfill implementation on 3d volumes was consuming way much memory; so we modified the code in the following ways (there was a vast improvement):

    1. Create a sphere of radius = 10 voxs around the starting point, and mark all the voxels within that radius as "to be visited"

    2. If the current voxel > threshold, insert 1.

    3. Go to the neighbors [+1, -1, 0] (also check that one doesn't revisit any voxel), if the neighbor.getVoxVal = 0 (the initialization value for the target volume), then it falls at the boundary of the sphere, insert the coordinates in a different stack. (this would be the starting point for our next sphere)

    4. radius = radius + 10 (voxels)

    So at a time, our floodfill is working on a concentric sphere and filling things up, which is a part of the entire volume, and as I said, this has reduced the memory consumption drastically, but I am still searching for an implementation/idea that would be better.

提交回复
热议问题