Masoud Posted February 21, 2020 Share Posted February 21, 2020 (edited) 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. CenterOfEachColoni_01.hip Edited February 21, 2020 by Masoud Quote Link to comment Share on other sites More sharing options...
Wooshum Posted February 21, 2020 Share Posted February 21, 2020 You could use pcfilter to easily get an approximation of the center of the cluster. Within the if statement: vector center = pcfilter(pcloud, "P") see: https://www.sidefx.com/docs/houdini/vex/functions/pcfilter.html Given the function weights according to the location of the search point it would not be an exact center. Quote Link to comment Share on other sites More sharing options...
Masoud Posted February 21, 2020 Author Share Posted February 21, 2020 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") see: https://www.sidefx.com/docs/houdini/vex/functions/pcfilter.html 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. Quote Link to comment Share on other sites More sharing options...
Wooshum Posted February 21, 2020 Share Posted February 21, 2020 (edited) 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. pseudo_gravity.hipnc Edited February 21, 2020 by Wooshum clarity Quote Link to comment Share on other sites More sharing options...
Masoud Posted February 21, 2020 Author Share Posted February 21, 2020 Sorry, but I don't get it. Quote Link to comment Share on other sites More sharing options...
Ultraman Posted February 21, 2020 Share Posted February 21, 2020 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 Quote Link to comment Share on other sites More sharing options...
Masoud Posted February 21, 2020 Author Share Posted February 21, 2020 Thank you "Milad", but I'm looking for the best way to calculate the center of those clusters. Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted February 21, 2020 Share Posted February 21, 2020 (edited) 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. CenterOfEachColoni_01.hipnc faster equivalent (avoiding for each)... CenterOfEachColoni_01B.hipnc Edited February 29, 2020 by Aizatulin 1 Quote Link to comment Share on other sites More sharing options...
animatrix Posted February 22, 2020 Share Posted February 22, 2020 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 Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted February 22, 2020 Share Posted February 22, 2020 or you could use a fuse and get your centers from that. CenterOfEachColoni_01_fix.hiplc 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted February 22, 2020 Share Posted February 22, 2020 Also make sure to look at the cluster points node which even offers an "output: average points" function. 1 Quote Link to comment Share on other sites More sharing options...
Masoud Posted February 24, 2020 Author Share Posted February 24, 2020 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? Quote Link to comment Share on other sites More sharing options...
Masoud Posted February 24, 2020 Author Share Posted February 24, 2020 On 2/22/2020 at 8:05 PM, ThomasPara said: or you could use a fuse and get your centers from that. CenterOfEachColoni_01_fix.hiplc Awesome, thanks. Quote Link to comment Share on other sites More sharing options...
bonsak Posted February 25, 2020 Share Posted February 25, 2020 If you add a Cluster SOP after your Cluster Points SOP, it has a checkbox to output Cluster Centers. -b 1 Quote Link to comment Share on other sites More sharing options...
Masoud Posted February 27, 2020 Author Share Posted February 27, 2020 (edited) 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 February 27, 2020 by Masoud Quote Link to comment Share on other sites More sharing options...
ftaswin Posted February 27, 2020 Share Posted February 27, 2020 If you got the cluster from pcopen command, wouldn’t the centerpoint be @P? Quote Link to comment Share on other sites More sharing options...
bonsak Posted February 27, 2020 Share Posted February 27, 2020 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 cluster-centers.hip Quote Link to comment Share on other sites More sharing options...
Noobini Posted February 27, 2020 Share Posted February 27, 2020 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.