In this notebook, we will provide extension to the PB-M3C2 workflow that will be occasionally useful based on your application.
For best training results, the user should provide both pairs of segments that do correspond to each other, as well as pairs of segments that do not correspond. In manual labelling workflows, it is much easier to produce high quality corresponding pairs that it is to produce non-corresponding pairs. Here, we provide a function that allows you to generate pairs of non-corresponding segments automatically based on heuristic. The general procedure is exactly the same as in the base workflow and will not be further explained here.
import py4dgeo
py4dgeo.set_interactive_backend("vtk")
epoch0, epoch1 = py4dgeo.read_from_xyz(
"plane_horizontal_t1.xyz", "plane_horizontal_t2.xyz"
)
alg = py4dgeo.PBM3C2()
(
xyz_epoch0,
xyz_epoch1,
extracted_segments,
) = alg.export_segmented_point_cloud_and_segments(
epoch0=epoch0,
epoch1=epoch1,
)
Now, we will use labelling data from the file testdata-labelling-correspondent-only.csv
, which does not contain any pairs of non-corresponding segments. Running add_no_corresponding_seg
on this data, we automatically generate these. There are two heuristics that can be selected through the algorithm
parameter:
random
: For each segment in one epoch, label a random segment from the neighborhood in the other epoch as non-corresponding.closes
: For each segment in one epoch, take the closest segment in the other epoch and label it non-corresponding.The neighborhood of a segment is defined by the threshold parameter given as threshold_max_distance
.
augmented_extended_y = py4dgeo.add_no_corresponding_seg(
segments=extracted_segments,
threshold_max_distance=5,
algorithm="random",
extended_y_file_name="testdata-labelling-correspondent-only.csv",
)
We can then run the training algorithm, passing directly the augmented labelling data:
alg.training(
extracted_segments_file_name="extracted_segments.seg",
extended_y=augmented_extended_y,
)
distances, uncertainties = alg.compute_distances(epoch0=epoch0, epoch1=epoch1)