From c61bb864c026d26a393f2a09c82de9bbc5043c6f Mon Sep 17 00:00:00 2001 From: Christian C Date: Tue, 4 Mar 2025 19:10:07 -0800 Subject: Modularization --- include/lib/algo/flood_fill.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 include/lib/algo/flood_fill.h (limited to 'include/lib/algo/flood_fill.h') diff --git a/include/lib/algo/flood_fill.h b/include/lib/algo/flood_fill.h new file mode 100644 index 0000000..a48f4a1 --- /dev/null +++ b/include/lib/algo/flood_fill.h @@ -0,0 +1,20 @@ +#ifndef INC_LIB_ALGO_FLOOD_FILL_H +#define INC_LIB_ALGO_FLOOD_FILL_H + +#include +#include +#include +#include + +//----------------------------------------------- +// 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); + +#endif -- cgit v1.2.1