Forum

Author Topic: Gradual Selection: How to select certain percentage of points  (Read 2548 times)

smescarzaga

  • Newbie
  • *
  • Posts: 25
    • View Profile
I'm trying to automate a workflow that calls for the selection of a percentage of the sparse cloud at each iteration, rather than at some threshold of reconstruction uncertainty, projection error, etc. I've seen below where a threshold variable is passed into a gradual selection

Code: [Select]
fltr = ps.PointCloud.Filter()
    fltr.init(chunk, ps.PointCloud.Filter.ReconstructionUncertainty)
    fltr.selectPoints(2 * thresh)


How I can I specify in the script to select a percentage of the initial points?

EDIT: As a clarification, I'd like the filter to select a percentage of the points in my cloud based on reconstruction uncertainty.
« Last Edit: July 02, 2019, 01:22:45 AM by smescarzaga »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14854
    • View Profile
Re: Gradual Selection: How to select certain percentage of points
« Reply #1 on: July 02, 2019, 06:55:39 PM »
Hello smescarzaga,

I can suggest to use the following approach:

Code: [Select]
import Metashape as ps
chunk = ps.app.document.chunk
THRESHOLD = 10 #percentage values for selection


fltr = ps.PointCloud.Filter()
fltr.init(chunk, ps.PointCloud.Filter.ReconstructionUncertainty)
values = fltr.values.copy()
values.sort()
thresh = values[int(len(values)* (1-THRESHOLD/100))]
fltr.selectPoints(thresh)

It will set selected the given percentage of the points (THRESHOLD).
Best regards,
Alexey Pasumansky,
Agisoft LLC

smescarzaga

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Gradual Selection: How to select certain percentage of points
« Reply #2 on: July 02, 2019, 10:25:44 PM »
This works great! Thank you Alexey!

xyz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Gradual Selection: How to select certain percentage of points
« Reply #3 on: February 08, 2021, 11:16:59 AM »
I would like to apply this script to the total number of points as well.
Anybody knows how to do this? I was thinking about implementing len(chunk.point_cloud.points) in some way