67 #include <visp3/imgproc/vpImgproc.h>
77 if ((oldValue == newValue) || (I.
getSize() == 0)) {
81 std::queue<vpImagePoint> seed_queue;
84 seed_queue.push(seedPoint);
86 while (!seed_queue.empty()) {
90 unsigned int x =
static_cast<unsigned int>(current_seed.
get_j());
91 unsigned int y =
static_cast<unsigned int>(current_seed.
get_i());
92 int x1 =
static_cast<int>(x);
95 while ((x1 >= 0) && (I[y][x1] == oldValue)) {
100 bool spanAbove =
false, spanBelow =
false;
102 while ((x1 <
static_cast<int>(I.
getWidth())) && (I[y][x1] == oldValue)) {
105 if ((!spanAbove) && (y > 0)) {
106 if (I[y - 1][x1] == oldValue) {
113 if ((x1 > 0) && (I[y - 1][x1 - 1] == oldValue)) {
118 if ((x1 < (
static_cast<int>(I.
getWidth()) - 1)) && (I[y - 1][x1 + 1] == oldValue)) {
125 else if (spanAbove && (y > 0) && (I[y - 1][x1] != oldValue)) {
129 if ((!spanBelow) && (y < (I.
getHeight() - 1))) {
130 if (I[y + 1][x1] == oldValue) {
137 if ((x1 > 0) && (I[y + 1][x1 - 1] == oldValue)) {
142 if ((x1 < (
static_cast<int>(I.
getWidth()) - 1)) && (I[y + 1][x1 + 1] == oldValue)) {
149 else if (spanBelow && (y < (I.
getHeight() - 1)) && (I[y + 1][x1] != oldValue)) {
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
unsigned int getWidth() const
unsigned int getSize() const
unsigned int getHeight() const
VISP_EXPORT void floodFill(VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > &I, const VISP_NAMESPACE_ADDRESSING vpImagePoint &seedPoint, const unsigned char oldValue, const unsigned char newValue, const VISP_NAMESPACE_ADDRESSING vpImageMorphology::vpConnexityType &connexity=VISP_NAMESPACE_ADDRESSING vpImageMorphology::CONNEXITY_4)