Author Topic: Gradual selection  (Read 656 times)


  • Newbie
  • *
  • Posts: 23
    • View Profile
Gradual selection
« on: May 03, 2021, 02:14:30 PM »
Hi guys,
can I use gradual selection only for selected photos from the project? I know that this tool works on a sparse cloud and not in photos, but I mean the situation that in some photos, e.g. with a forest, I have few points (e.g. 30) and I would not want to delete them anymore, while others have a lot of them (e.g. 10,000 ). I think that such a disproportion has a negative effect on the aligment results. Maybe there is another way? except of course manual.



  • Hero Member
  • *****
  • Posts: 806
    • View Profile
Re: Gradual selection
« Reply #1 on: May 03, 2021, 04:19:53 PM »
Hi MK,

i have a workaround for this problem. You can move all fotos with low number of tie points in a group (in example I grouped all images with less than 75 projections). Select that group and then proceed to do a gradual selection on certain criteria. You then obtain a certain number of selected points (in example  24 840). then run following code:
Code: [Select]
 deselects tpts that have projections in a  selected camera group
 import Metashape as ps
 chunk =
 point_cloud = chunk.point_cloud
 points = point_cloud.points
 projections = point_cloud.projections
 npoints = len(points)

 selected_group = list()
 if not [group for group in chunk.camera_groups if group.selected]:
  raise Exception("No camera group selected!")
 for camera in chunk.cameras:
  if not
 nselpts = 0
 for point in  points:
  if point.selected:
  nselpts += 1
 ndsel = 0
 for camera in selected_group:
  point_index = 0
  for proj in projections[camera]:
  track_id = proj.track_id
  while point_index < npoints and points[point_index].track_id < track_id:
  point_index += 1
  if point_index < npoints and points[point_index].track_id == track_id:
  if not points[point_index].valid:
  if points[point_index].selected  :
  points[point_index].selected = False
  ndsel += 1
 print("Number pts unselected: ",ndsel,"Number remaining: ",nselpts-ndsel)
This will deselect all tie points that have projections in the selected group (in example 28 points had projections in the selected group). You can then delete the remaining selected points without affecting points in selected group....

Hope this makes sense!
« Last Edit: May 03, 2021, 10:18:53 PM by Paulo »
Best Regards,

Paul Pelletier


  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Gradual selection
« Reply #2 on: May 04, 2021, 01:08:43 AM »
that's exactly what I meant, I will test it soon
thanks Paul