I need to use the floodFill function of EMGUCV in C#.
I managed to use it like this:
Image<Gray, Byte> img = new Image<Gray, byte>(this.B);
img.Save("orig.png");
int height = img.Rows;
int width = img.Cols;
Point s = new Point( 227, 295);
int tol = 8;
Mat outputMask = new Mat(height + 2, width + 2, Emgu.CV.CvEnum.DepthType.Cv8U, 1);
Rectangle dummyRect = new Rectangle();
CvInvoke.FloodFill(img,
outputMask,
s,
new MCvScalar(255, 0, 0),
out dummyRect,
new MCvScalar(tol), new MCvScalar(tol),
Emgu.CV.CvEnum.Connectivity.EightConnected);
//Emgu.CV.CvEnum.FloodFillType.MaskOnly);
img.Save("imgModif.png");
Console.Write("End");
However the output I get in img (or in outputMask) when I use it does not make any sense at all. Some white rectangular areas. I am expecting the results of a "photoshop like" magic wand. ANy idea of what is wrong? Moreover, even though I specify (255,0,0) as the fill color, the result is white in img. (B is a preloaded Bitmap image)
I am trying to do the same as this:
http://www.andrew-seaford.co.uk/flood-fill-opencv/
except I work with a grayscale image initially.
THis is what i get if I set the tol=255 (which should fill the whole image in white, if this function was really behaving like a magic wand):
This ''rectangle'' that can be seen does not make sense, even worse, you can see some white pixels going out of this rectangle region (on Lena's hat)... so it does not even seem to be a sort of rectangular constraint. Also a few pixels in the "pseudo rectangle" are not white... I would be curious if someone could test this function on their system with a lena image.