Ask Your Question

Fill irregular area

asked 2015-06-18 03:33:09 -0500

ato gravatar image

updated 2018-12-25 14:43:47 -0500


I wanted to ask if you could please help me. I have to fill an area as shown in Figure (img1.jpg)

and get img2.jpg

I have to fill only the top I filled until I find a white color. I also have to count how many pixels are green E 'can do such a thing with opencv? I use vb2010 with emgu, but that's okay with c # and opencv. Sorry for my English I used ul online translator Grazie

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2015-06-19 13:40:03 -0500

pklab gravatar image

Check cv::floodFill and

An example using the FloodFill technique can be found at opencv_source_code/samples/cpp/ffilldemo.cpp

edit flag offensive delete link more

answered 2015-06-24 08:56:20 -0500

Karthikeyan gravatar image

As suggested, you can use the floodfill. For your image, this code will probably work out.

//Use this mouse call back for selecting the seedpoint.

void onMouse( int event, int x, int y, int, void* ) {

if( event != EVENT_LBUTTONDOWN )

//Floodfill the image with green colour.
floodFill(InputImage, Point(x,y), Scalar(0,255,0), NULL, Scalar::all(10), Scalar::all(10));


edit flag offensive delete link more

answered 2015-06-24 04:47:01 -0500

ato gravatar image

updated 2015-06-24 04:49:08 -0500

hi guy :)

i resolved

this is the code for visual basic

Dim ImgStor As MemStorage

Dim seedPoint As Point = New Point(0, 0)

Dim cc As Emgu.CV.Structure.MCvConnectedComp

CvInvoke.cvFloodFill(img, seedPoint, New MCvScalar(0, 0, 0), New MCvScalar(100, 100, 100), New MCvScalar(100, 100, 100), cc, 4, ImgStor)

Me.Text = cc.area

PictureBox1.Image = img.ToBitmap

I hope will be of help to others.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-06-18 03:33:09 -0500

Seen: 917 times

Last updated: Jun 24 '15