Ask Your Question
0

How can i find the centroid of the largest white(actually yellow) area using OpenCV with C++2008?

asked 2012-11-29 01:20:47 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

I am doing some images processing using OpenCV with C++2008.

I have to do the thresholding to make the image into black (other color) and white(actually yellow colour).

After that, since there are different areas of white areas on the image, I have to find the centroid of the largest white(actually yellow) area.

How can i find the centroid of the largest white(actually yellow) area using OpenCV with C++2008?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
4

answered 2012-11-29 02:34:51 -0500

Michael Burdinov gravatar image

When you apply threshold on image (at least the one implemented in OpenCV) you get image with one channel. If you are talking about yellow, than you have multi-channel image. How this happened?

Step 1: Use findContours function to find all objects in image (single channel binary image).

Step 2: Use contourArea function on each contour found in step 1 to find the largest one.

Step 3: Use moments function to find centroid of your contour.

edit flag offensive delete link more
1

answered 2012-11-29 07:04:37 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

You can use cvBlobsLib add on package. This will allow you to find blobs based on a given criterion, Area in your case. The index of the blob can be used to find other properties including centroid. The package performs very well though the documentation is sparse.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2012-11-29 01:20:47 -0500

Seen: 6,753 times

Last updated: Nov 29 '12