72 #include <visp3/imgproc/vpImgproc.h> 90 if (oldValue == newValue || I.
getSize() == 0) {
94 std::queue<vpImagePoint> seed_queue;
97 seed_queue.push(seedPoint);
99 while (!seed_queue.empty()) {
103 unsigned int x = (
unsigned int)current_seed.
get_j();
104 unsigned int y = (
unsigned int)current_seed.
get_i();
108 while (x1 >= 0 && I[y][x1] == oldValue) {
113 bool spanAbove =
false, spanBelow =
false;
115 while (x1 < (
int)I.
getWidth() && I[y][x1] == oldValue) {
118 if (!spanAbove && y > 0) {
119 if (I[y - 1][x1] == oldValue) {
126 if (x1 > 0 && I[y - 1][x1 - 1] == oldValue) {
131 if (x1 < (
int)I.
getWidth() - 1 && I[y - 1][x1 + 1] == oldValue) {
137 }
else if (spanAbove && y > 0 && I[y - 1][x1] != oldValue) {
141 if (!spanBelow && y < I.
getHeight() - 1) {
142 if (I[y + 1][x1] == oldValue) {
149 if (x1 > 0 && I[y + 1][x1 - 1] == oldValue) {
154 if (x1 < (
int)I.
getWidth() - 1 && I[y + 1][x1 + 1] == oldValue) {
160 }
else if (spanBelow && y < I.
getHeight() - 1 && I[y + 1][x1] != oldValue) {
VISP_EXPORT void floodFill(vpImage< unsigned char > &I, const vpImagePoint &seedPoint, const unsigned char oldValue, const unsigned char newValue, const vpImageMorphology::vpConnexityType &connexity=vpImageMorphology::CONNEXITY_4)
unsigned int getHeight() const
unsigned int getSize() const
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
unsigned int getWidth() const