Ask Your Question
1

Fill irregular area

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

ato gravatar image

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

Hello

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

https://www.dropbox.com/s/hvgjmyvcw9z...

and get img2.jpg

https://www.dropbox.com/s/kpccy42w0ps...

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
2

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

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
0

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

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 )
    return;

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

}

edit flag offensive delete link more
0

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

ato gravatar image

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

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

Question Tools

1 follower

Stats

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

Seen: 1,315 times

Last updated: Jun 24 '15