3dgeo-heidelberg / py4dgeo

py4dgeo - A Python library for change analysis in 4D point clouds
https://py4dgeo.readthedocs.io
MIT License
78 stars 12 forks source link

height_threshold parameter not considered in RegionGrowingAlgorithm #324

Open hdaan opened 8 months ago

hdaan commented 8 months ago

In the RegionGrowingAlgorithm the parameter height_threshold is exposed but never considered during seed detection in find_seedpoints.

This leads to the detection of a lot of seeds with a low amount of height change. As a result, there are a lot of "unwanted" seeds, and, in some cases, large objects of low amount of change might prevent smaller objects with greater height change to grow, as the potential seed is already incorporated in the larger segment.

To fix this we can add an height_threshold check in line 945: Changing:

                    # Check whether the volume started decreasing
                    if previous_volume > volume:
                        # Only add seed if larger than the minimum period
                        if target_idx - start_idx >= self.minperiod:
                            corepoint_seeds.append(
                                RegionGrowingSeed(i, start_idx, target_idx)
                            )
                        break
                    else:
                        previous_volume = volume 

to:

                    # Check whether the volume started decreasing
                    if previous_volume > volume:
                        # Only add seed if larger than the minimum period and height of the change form larger than threshold
                        if (target_idx - start_idx >= self.minperiod) and (np.abs(np.max(used_timeseries) - np.min(used_timeseries)) >= self.height_threshold):
                            corepoint_seeds.append(
                                RegionGrowingSeed(i, start_idx, target_idx)
                            )
                        break
                    else:
                        previous_volume = volume