diff options
author | Christian C <cc@localhost> | 2025-03-07 21:58:41 -0800 |
---|---|---|
committer | Christian C <cc@localhost> | 2025-03-07 21:58:41 -0800 |
commit | 0d1f5979dd1d6062af118fae3a1aa1863ea596f2 (patch) | |
tree | 4cb9973682409cbc23cd6c93cb26f14c4702d8ed /src/lib/algo/flood_fill.c | |
parent | 12a1b2269c64bfbe61490a9a2a8eaa84ec3b41de (diff) |
Library directories
Diffstat (limited to 'src/lib/algo/flood_fill.c')
-rw-r--r-- | src/lib/algo/flood_fill.c | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/lib/algo/flood_fill.c b/src/lib/algo/flood_fill.c deleted file mode 100644 index 62db658..0000000 --- a/src/lib/algo/flood_fill.c +++ /dev/null @@ -1,33 +0,0 @@ -#include <lib/algo/flood_fill.h> - -// Flood -// Floods a mask from a given set of image to determine the contiguous regions -// 1. Check that the (x,y) is within the picture -// 2. Check if the (x,y) coordinate in the mask is unused -// 3. Check if the (x,y) coordinate in the image is non-background -// 4. Check if the (x,y) coordinate in the image is the same color as the fill color -// 5. If all hold, set the label for the pixel, and check each neighbor -// Otherwise, stop flooding -bool_t flood(uint8_t* image, uint16_t* mask, size_t width, size_t height, size_t channels, size_t x, size_t y, uint8_t* fill_color, uint16_t label) -{ - if ((x >= width) | (y >= height)) { - return FALSE; - } - size_t coord = x + y*width; - if (mask[coord] != 0) { - return FALSE; - } - if (color_zero(&(image[coord*channels]), channels)) { - return FALSE; - } - if (color_equal(&(image[coord*channels]), fill_color, channels)) { - mask[coord] = label; - flood(image, mask, width, height, channels, x, y+1, fill_color, label); - flood(image, mask, width, height, channels, x, y-1, fill_color, label); - flood(image, mask, width, height, channels, x+1, y, fill_color, label); - flood(image, mask, width, height, channels, x-1, y, fill_color, label); - return TRUE; - } - return FALSE; -} - |