Ask Your Question
0

how to group clusters?

asked 2020-07-26 22:29:22 -0600

despair104 gravatar image

updated 2020-07-26 22:36:49 -0600

Using python and opencv most recent versions.

I have an image like this one:

image description

When the red dots appear, their position always random, so I don't know where they will be next time, this is just as an example. However there are 3 facts:

  1. I will have the x, y coordinates of each dot
  2. There will always be at least 3 clustered dots and the rest spread out elsewhere.
  3. There will always be only one cluster. It is possible that another 2 dots are closed together, but only 3 close dots will be considered clusters.

I want to detect where the cluster is and draw a shape around them. The expected output should be like this:

image description

Since I don't know where they will appear, if I use a red dot as a reference to measure distance, it is possible that one will be outside the cluster. If I try to determine if the dot is in the cluster measuring their x position, it is possible the next cluster will be further away and the spread out dots will be closer on the x side.

I have thought about measuring the distance of each dot against all others and set a threshold of a determined amount of pixels. After that, somehow draw the shape, but I just have no idea of how to do this.

The dots don't really contain any information besides their location (x,y).

Any ideas on how to solve this would be appreciated.

edit retag flag offensive close merge delete

Comments

Hi, I have faced same problem of group clusters so please answer its with nice wording thanks

fishfindersjudge gravatar imagefishfindersjudge ( 2020-07-28 03:21:38 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-07-27 02:33:01 -0600

berak gravatar image

unfortunately, opencv can't help you much here. (there's cv::partition(), but you can't use it from python)

have a look at scikit, DBSCAN should be close to what you want. in general, you need an algorithm, where you can specify a distance (function), not the desired number of clusters.

edit flag offensive delete link more

Comments

2

Hello! Pointing me to the right direction is more than enough, I will take a look at those libraries/algorythms, thank you!

despair104 gravatar imagedespair104 ( 2020-07-27 09:18:12 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-07-26 22:29:22 -0600

Seen: 275 times

Last updated: Jul 27 '20