Jump to content

# How can I find the center of cluster points?

## Recommended Posts

Hi;

As you can see in the image below, I scattered clusters of some points. How can I find the center of each cluster( each colony.)?

Thanks for helping.

Edited by Masoud

#### Share this post

##### Share on other sites

You could use pcfilter to easily get an approximation of the center of the cluster. Within the if statement:

`vector center = pcfilter(pcloud, "P")`

Given the function weights according to the location of the search point it would not be an exact center.

#### Share this post

##### Share on other sites
13 minutes ago, Wooshum said:

You could use pcfilter to easily get an approximation of the center of the cluster. Within the if statement:

```
vector center = pcfilter(pcloud, "P")```

Given the function weights according to the location of the search point it would not be an exact center.

I think it gives me only the position of each point.

#### Share this post

##### Share on other sites

The pcfilter function will return the filtered (blurred, averaged, etc) positional value (or any attribute value you choose) of all of the points within the search radius and count. To demonstrate if you assign the center value to @P  and place the point wrangle within a sop solver you get a pseudo gravity sim. See attached HIP.

Edited by Wooshum
clarity

#### Share this post

##### Share on other sites

Sorry, but I don't get it.

#### Share this post

##### Share on other sites

Hey Masoud /;

check hip file it's that what you want  ?

it's not clean way but maybe work  ... /

I think your start Method can be better for distributions Points Cluster ..

CenterOfEachColoni_01.hip

#### Share this post

##### Share on other sites

Thank you "Milad", but I'm looking for the best way to calculate the center of those clusters.

#### Share this post

##### Share on other sites

Here is another approach (similar to the previous).

rough ideas:

• use pcfind() to get clusterpoints and add polylines (for connectivity)
• remove points which are isolated
• get connectivity classes
• create dummy points (one for each class), which should be the center points later
• each point should get all cluster points as vector array attribute (using for each is possible)
• create average over all vector array for each point to get the center

Probably there are faster solutions.

faster equivalent (avoiding for each)...

CenterOfEachColoni_01B.hipnc

Edited by Aizatulin
• 1

#### Share this post

##### Share on other sites

Hi,

You can just average out all the points found in the point cloud lookup where you are coloring them, and either create new points at the computed center or store it as an attribute.

• 1

#### Share this post

##### Share on other sites

or you could use a fuse and get your centers from that.

CenterOfEachColoni_01_fix.hiplc

• 1

#### Share this post

##### Share on other sites

Also make sure to look at the cluster points node which even offers an "output: average points" function.

• 1

#### Share this post

##### Share on other sites
On 2/22/2020 at 9:13 PM, konstantin magnus said:

Also make sure to look at the cluster points node which even offers an "output: average points" function.

Do you mean avg() function?

#### Share this post

##### Share on other sites
On 2/22/2020 at 8:05 PM, ThomasPara said:

or you could use a fuse and get your centers from that.

Awesome, thanks.

#### Share this post

##### Share on other sites

If you add a Cluster SOP after your Cluster Points SOP, it has a checkbox to output Cluster Centers.

-b

• 1

#### Share this post

##### Share on other sites

Thanks "Bonsak", good idea. But when I set "Output Attribute" to "Average Points", it shows some points that are not at the center of each cluster.

Edited by Masoud

#### Share this post

##### Share on other sites

If you got the cluster from pcopen command, wouldn’t the centerpoint be @P?

#### Share this post

##### Share on other sites

Make sure you set the same number of clusters on both the Cluster Points SOP and Cluster SOP. The Cluster Points SOP has the Cluster SOP inside it. So you could use 2 Cluster Points SOPs if you want and set the second to Average Points. You still need to set the same number of clusters on both nodes though.

-b

#### Share this post

##### Share on other sites
11 hours ago, ftaswin said:

If you got the cluster from pcopen command, wouldn’t the centerpoint be @P?

but say you have found 2 points, just say left and right, and your hero point was slightly offcentre...then the centre of the cluster should be the centre of left/right points...not the orig slightly offcentre hero.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now

×
• Donations

• Leaderboard