Page 1 of 1

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

Posted: Wed Feb 14, 2024 4:51 pm
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?

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

Posted: Thu Feb 15, 2024 7:06 am
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.

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

Posted: Fri Feb 16, 2024 7:46 pm
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()

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

Posted: Sat Feb 17, 2024 7:57 am
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.