Ask Your Question
0

OpenCV - Computing a best fit grid

asked 2015-03-17 14:37:57 -0500

Mytheral gravatar image

updated 2015-03-17 15:02:53 -0500

So I have an image which looks similar to this:

image description

And what I need to do if create a best fit grid. The circles in this image are circular but they can be oval, oblong or any random shape you can think of and while they will be in the same relative location they could be shifted around by several pixels or the dots could "run" like when using paint.

I believe I need the grid so I can get the inner 75% of these dots and average the color contained in that 75%.

I've looked at Calib3d.findCirclesGridDefault but I believe that just creates a grid based on the center points of found circles. There isn't much documentation on the java side so please correct me if I'm wrong.

Calib3d.findCirclesGridDefault: http://docs.opencv.org/java/org/openc...

Is there an OpenCV Method to do this or is there any prefered method of generating a best fit grid?

edit retag flag offensive close merge delete

Comments

1

May be you can use threshold and connectedComponentsWithStats. Hence you will have gravity center of indiviudual shape.

LBerger gravatar imageLBerger ( 2015-03-17 15:29:20 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-03-18 12:38:29 -0500

Haris gravatar image

If I am understanding correctly, you are trying to get color values corresponding to each dot, then you can follow the contour approach instead of bounding grid. Assumes the background always white,

the procedure is like,

  • Threshold source image to create contours corresponding to dots.

  • Find contours to extract each object(dot) from thresholded image.

  • Now you can iterate through each contour, can draw mask corresponding for each contour.

  • In a loop use Mat::mean to calculate average color value, here you could use above created mask as the second argument to mean().

  • Repeat above two steps for each contour.

edit flag offensive delete link more

Comments

I'm attempting this method currently, only downside is it's detecting the full ticket at the moment instead the various circles.

Mytheral gravatar imageMytheral ( 2015-03-27 09:33:06 -0500 )edit

Are you sure the threshold out put generates only circles, and the rest with 0 pixel value?

Haris gravatar imageHaris ( 2015-03-29 03:53:40 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-03-17 14:37:57 -0500

Seen: 794 times

Last updated: Mar 18 '15