Is there a way to remove pointclouds which has 1000points or lower?

Feel free to ask any question here
Post Reply
Eternal
Posts: 1
Joined: Wed Feb 14, 2024 4:48 pm

Is there a way to remove pointclouds which has 1000points or lower?

Post by Eternal »

Greetings,

While employing Treeiso to distinguish trees and subsequently segmenting the cloud based on integer values, I discerned that enhancing the quality of my work could be achieved by excluding clouds containing fewer than 1000 points. Notably, the trees identified through Treeiso consistently exhibit over 8000 points.


How to remove the smaller pointclouds?
daniel
Site Admin
Posts: 7713
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Is there a way to remove pointclouds which has 1000points or lower?

Post by daniel »

I guess you mean 'automatically'... Sadly I don't see any way to do it right now (apart from adding a line of code somewhere of course). Or maybe the Python interfaces could help.
Daniel, CloudCompare admin
lweidner
Posts: 10
Joined: Fri Jan 21, 2022 9:47 pm

Re: Is there a way to remove pointclouds which has 1000points or lower?

Post by lweidner »

Hi,
I wrote a short script using the python GUI plugin recently which does something similar, basically it was meant to delete entities which weren't visible. I think the number of points is an attribute you can access through the python API, or definitely you can after passing the points to a numpy array.

Here's some untested code below. You would first select all the point clouds, then run the script, and the ones with less than 1000 points should disappear. (sometimes when I run my other version of this it crashes and I don't know why. usually it works though if I try again :) )

Code: Select all

import cccorelib
import pycc

CC = pycc.GetInstance()

def main():
    entities = CC.getSelectedEntities()
    

    if not entities:
        raise RuntimeError("No entities selected")

    for entity in entities:
        if len(entity.points)<1000: #did not test this, but something accessing the "points" attribute should work
            CC.removeFromDB(entity)

    CC.updateUI()


if __name__ == '__main__':
    main()
daniel
Site Admin
Posts: 7713
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Is there a way to remove pointclouds which has 1000points or lower?

Post by daniel »

Nice, thanks for the post!

Just make sure not to select an entity and its children, as depending on the order this command is processed, you may try to access or remove an already deleted object.
Daniel, CloudCompare admin
Post Reply