Reputation: 43
so, I'm trying to flood fill different regions of the image, with different shades of grey. This is my input image: 1
So here is my code for flood filling one of the regions with some grey shade:
image = cv.imread('img.jpg', 0)
height, width = image.shape[:2]
for i in range(height):
for j in range(width):
if image[i][j] == 255:
cv.floodFill(image, None, (i, j), 90)
cv.imwrite('test1.jpg', image)
break
else:
continue
break
After this I get: 2
And if I try to load the new image again, and go through the pixels, the same pixel that was used to start flood fill in the previous example, still has the 255 value instead of 90. How is that? What am I missing here?
Thanks, guys!
Upvotes: 1
Views: 56
Reputation: 23002
floodFill()
and other functions which take a point expect them to be in x, y
coordinates. You're sending in row, col
coordinates instead (i.e., y, x
), so you're floodfill()
ing a different area than you actually detect that is white.
Upvotes: 1