cars 1.0.0a3__cp313-cp313-win_amd64.whl → 1.0.0a4__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cars might be problematic. Click here for more details.
- cars/__init__.py +3 -3
- cars/applications/__init__.py +0 -3
- cars/applications/application_template.py +20 -0
- cars/applications/auxiliary_filling/abstract_auxiliary_filling_app.py +12 -2
- cars/applications/auxiliary_filling/auxiliary_filling_algo.py +2 -2
- cars/applications/auxiliary_filling/auxiliary_filling_from_sensors_app.py +80 -36
- cars/applications/dem_generation/dem_generation_algo.py +1 -1
- cars/applications/dem_generation/dem_generation_wrappers.py +23 -57
- cars/applications/dem_generation/dichotomic_generation_app.py +3 -3
- cars/applications/dem_generation/rasterization_app.py +100 -41
- cars/applications/dense_match_filling/__init__.py +1 -1
- cars/applications/dense_match_filling/abstract_dense_match_filling_app.py +2 -15
- cars/applications/dense_match_filling/fill_disp_algo.py +32 -373
- cars/applications/dense_match_filling/fill_disp_wrappers.py +0 -343
- cars/applications/dense_match_filling/zero_padding_app.py +10 -5
- cars/applications/dense_matching/abstract_dense_matching_app.py +2 -1
- cars/applications/dense_matching/census_mccnn_sgm_app.py +38 -39
- cars/applications/dense_matching/cpp/dense_matching_cpp.cp313-win_amd64.dll.a +0 -0
- cars/applications/dense_matching/cpp/dense_matching_cpp.cp313-win_amd64.pyd +0 -0
- cars/applications/dense_matching/dense_matching_algo.py +48 -14
- cars/applications/dense_matching/dense_matching_wrappers.py +11 -3
- cars/applications/dense_matching/disparity_grid_algo.py +84 -62
- cars/applications/dense_matching/loaders/pandora_loader.py +91 -33
- cars/applications/dsm_filling/border_interpolation_app.py +1 -7
- cars/applications/dsm_filling/bulldozer_filling_app.py +2 -8
- cars/applications/dsm_filling/exogenous_filling_app.py +4 -9
- cars/applications/grid_generation/abstract_grid_generation_app.py +1 -1
- cars/applications/grid_generation/epipolar_grid_generation_app.py +4 -2
- cars/applications/grid_generation/grid_correction_app.py +4 -1
- cars/applications/grid_generation/grid_generation_algo.py +7 -2
- cars/applications/ground_truth_reprojection/abstract_ground_truth_reprojection_app.py +1 -1
- cars/applications/ground_truth_reprojection/direct_localization_app.py +2 -2
- cars/applications/ground_truth_reprojection/ground_truth_reprojection_algo.py +2 -1
- cars/applications/point_cloud_fusion/abstract_pc_fusion_app.py +0 -155
- cars/applications/point_cloud_fusion/mapping_to_terrain_tiles_app.py +0 -658
- cars/applications/point_cloud_fusion/pc_fusion_algo.py +0 -1339
- cars/applications/point_cloud_fusion/pc_fusion_wrappers.py +0 -869
- cars/applications/point_cloud_outlier_removal/abstract_outlier_removal_app.py +2 -1
- cars/applications/point_cloud_outlier_removal/outlier_removal_algo.py +9 -8
- cars/applications/point_cloud_outlier_removal/small_components_app.py +96 -267
- cars/applications/point_cloud_outlier_removal/statistical_app.py +116 -275
- cars/applications/rasterization/abstract_pc_rasterization_app.py +1 -1
- cars/applications/rasterization/rasterization_algo.py +18 -6
- cars/applications/rasterization/rasterization_wrappers.py +2 -1
- cars/applications/rasterization/simple_gaussian_app.py +60 -113
- cars/applications/resampling/abstract_resampling_app.py +1 -1
- cars/applications/resampling/bicubic_resampling_app.py +3 -1
- cars/applications/resampling/resampling_algo.py +16 -4
- cars/applications/resampling/resampling_wrappers.py +3 -1
- cars/applications/sparse_matching/abstract_sparse_matching_app.py +1 -1
- cars/applications/sparse_matching/sift_app.py +3 -3
- cars/applications/sparse_matching/sparse_matching_algo.py +3 -2
- cars/applications/sparse_matching/sparse_matching_wrappers.py +1 -1
- cars/applications/triangulation/abstract_triangulation_app.py +1 -1
- cars/applications/triangulation/line_of_sight_intersection_app.py +13 -11
- cars/applications/triangulation/pc_transform.py +552 -0
- cars/applications/triangulation/triangulation_algo.py +6 -4
- cars/applications/triangulation/triangulation_wrappers.py +1 -0
- cars/bundleadjustment.py +6 -6
- cars/cars.py +11 -9
- cars/core/cars_logging.py +80 -49
- cars/core/constants.py +0 -1
- cars/core/datasets.py +5 -2
- cars/core/geometry/abstract_geometry.py +256 -25
- cars/core/geometry/shareloc_geometry.py +110 -82
- cars/core/inputs.py +57 -19
- cars/core/outputs.py +1 -1
- cars/core/preprocessing.py +17 -3
- cars/core/projection.py +9 -6
- cars/core/tiling.py +10 -3
- cars/data_structures/cars_dataset.py +5 -5
- cars/data_structures/corresponding_tiles_tools.py +0 -103
- cars/data_structures/format_transformation.py +4 -1
- cars/devibrate.py +6 -3
- cars/extractroi.py +20 -21
- cars/orchestrator/cluster/abstract_cluster.py +15 -5
- cars/orchestrator/cluster/abstract_dask_cluster.py +6 -2
- cars/orchestrator/cluster/dask_jobqueue_utils.py +1 -1
- cars/orchestrator/cluster/log_wrapper.py +148 -21
- cars/orchestrator/cluster/mp_cluster/multiprocessing_cluster.py +11 -3
- cars/orchestrator/cluster/mp_cluster/multiprocessing_profiler.py +2 -2
- cars/orchestrator/cluster/pbs_dask_cluster.py +1 -1
- cars/orchestrator/cluster/sequential_cluster.py +5 -4
- cars/orchestrator/cluster/slurm_dask_cluster.py +1 -1
- cars/orchestrator/orchestrator.py +14 -3
- cars/orchestrator/registry/id_generator.py +1 -0
- cars/orchestrator/registry/saver_registry.py +2 -2
- cars/pipelines/conf_resolution/conf_final_resolution.json +5 -3
- cars/pipelines/default/default_pipeline.py +462 -1073
- cars/pipelines/parameters/advanced_parameters.py +74 -64
- cars/pipelines/parameters/advanced_parameters_constants.py +2 -5
- cars/pipelines/parameters/application_parameters.py +71 -0
- cars/pipelines/parameters/depth_map_inputs.py +0 -314
- cars/pipelines/parameters/dsm_inputs.py +40 -4
- cars/pipelines/parameters/output_parameters.py +2 -2
- cars/pipelines/parameters/sensor_inputs.py +30 -75
- cars/pipelines/parameters/sensor_inputs_constants.py +0 -2
- cars/pipelines/parameters/sensor_loaders/__init__.py +4 -3
- cars/pipelines/parameters/sensor_loaders/basic_classif_loader.py +106 -0
- cars/pipelines/parameters/sensor_loaders/{basic_sensor_loader.py → basic_image_loader.py} +16 -22
- cars/pipelines/parameters/sensor_loaders/pivot_classif_loader.py +121 -0
- cars/pipelines/parameters/sensor_loaders/{pivot_sensor_loader.py → pivot_image_loader.py} +10 -21
- cars/pipelines/parameters/sensor_loaders/sensor_loader.py +4 -6
- cars/pipelines/parameters/sensor_loaders/sensor_loader_template.py +1 -3
- cars/pipelines/pipeline_template.py +1 -3
- cars/pipelines/unit/unit_pipeline.py +527 -1016
- cars/starter.py +4 -3
- cars-1.0.0a4.dist-info/DELVEWHEEL +2 -0
- {cars-1.0.0a3.dist-info → cars-1.0.0a4.dist-info}/METADATA +135 -53
- {cars-1.0.0a3.dist-info → cars-1.0.0a4.dist-info}/RECORD +115 -131
- cars.libs/libgcc_s_seh-1-b2494fcbd4d80cf2c98fdd5261f6d850.dll +0 -0
- cars.libs/libstdc++-6-e9b0d12ae0e9555bbae55e8dfd08c3f7.dll +0 -0
- cars.libs/libwinpthread-1-7882d1b093714ccdfaf4e0789a817792.dll +0 -0
- cars/applications/dense_match_filling/cpp/__init__.py +0 -0
- cars/applications/dense_match_filling/cpp/dense_match_filling_cpp.cp313-win_amd64.dll.a +0 -0
- cars/applications/dense_match_filling/cpp/dense_match_filling_cpp.cp313-win_amd64.pyd +0 -0
- cars/applications/dense_match_filling/cpp/dense_match_filling_cpp.py +0 -72
- cars/applications/dense_match_filling/cpp/includes/dense_match_filling.hpp +0 -46
- cars/applications/dense_match_filling/cpp/meson.build +0 -9
- cars/applications/dense_match_filling/cpp/src/bindings.cpp +0 -11
- cars/applications/dense_match_filling/cpp/src/dense_match_filling.cpp +0 -142
- cars/applications/dense_match_filling/plane_app.py +0 -556
- cars/applications/hole_detection/__init__.py +0 -30
- cars/applications/hole_detection/abstract_hole_detection_app.py +0 -125
- cars/applications/hole_detection/cloud_to_bbox_app.py +0 -346
- cars/applications/hole_detection/hole_detection_algo.py +0 -144
- cars/applications/hole_detection/hole_detection_wrappers.py +0 -53
- cars/applications/point_cloud_denoising/__init__.py +0 -29
- cars/applications/point_cloud_denoising/abstract_pc_denoising_app.py +0 -273
- cars/applications/point_cloud_fusion/__init__.py +0 -30
- cars/applications/point_cloud_fusion/cloud_fusion_constants.py +0 -39
- cars/applications/sparse_matching/pandora_sparse_matching_app.py +0 -0
- cars/pipelines/parameters/depth_map_inputs_constants.py +0 -25
- cars-1.0.0a3.dist-info/DELVEWHEEL +0 -2
- cars.libs/libgcc_s_seh-1-ca70890bbc5723b6d0ea31e9c9cded2b.dll +0 -0
- cars.libs/libstdc++-6-00ee19f73d5122a1277c137b1c218401.dll +0 -0
- cars.libs/libwinpthread-1-f5042e8e3d21edce20c1bc99445f551b.dll +0 -0
- {cars-1.0.0a3.dist-info → cars-1.0.0a4.dist-info}/WHEEL +0 -0
- {cars-1.0.0a3.dist-info → cars-1.0.0a4.dist-info}/entry_points.txt +0 -0
|
@@ -26,400 +26,50 @@ their neighbourhood.
|
|
|
26
26
|
|
|
27
27
|
# Standard imports
|
|
28
28
|
|
|
29
|
-
import logging
|
|
30
29
|
|
|
31
30
|
import numpy as np
|
|
32
31
|
|
|
33
32
|
# Third party imports
|
|
34
33
|
import xarray as xr
|
|
35
|
-
from scipy.linalg import lstsq
|
|
36
|
-
from scipy.ndimage import binary_dilation, binary_erosion, label
|
|
37
34
|
|
|
38
35
|
from cars.applications.dense_match_filling import (
|
|
39
36
|
fill_disp_wrappers as fill_wrap,
|
|
40
37
|
)
|
|
41
|
-
from cars.applications.hole_detection import (
|
|
42
|
-
hole_detection_algo,
|
|
43
|
-
hole_detection_wrappers,
|
|
44
|
-
)
|
|
45
38
|
from cars.conf import mask_cst
|
|
46
39
|
|
|
47
40
|
# Cars import
|
|
48
41
|
from cars.core import constants as cst
|
|
49
42
|
|
|
50
43
|
|
|
51
|
-
def
|
|
52
|
-
disp_map: xr.Dataset,
|
|
53
|
-
corresponding_poly,
|
|
54
|
-
row_min,
|
|
55
|
-
col_min,
|
|
56
|
-
ignore_nodata: bool,
|
|
57
|
-
ignore_zero_fill: bool,
|
|
58
|
-
ignore_extrema: bool,
|
|
59
|
-
nb_pix: int,
|
|
60
|
-
percent_to_erode: float,
|
|
61
|
-
class_index: list,
|
|
62
|
-
fill_valid_pixels: bool,
|
|
63
|
-
):
|
|
64
|
-
"""
|
|
65
|
-
Finds central area of invalid region and estimates disparity values
|
|
66
|
-
in this area according to a plan model estimation. The estimation
|
|
67
|
-
of this model is done using disparity values at invalid region
|
|
68
|
-
borders.
|
|
69
|
-
|
|
70
|
-
:param disp_map: disparity map with several layers ('disp',
|
|
71
|
-
'disp_msk', 'msk_invalid_sec')
|
|
72
|
-
:type disp_map: 2D np.array (row, col)
|
|
73
|
-
:param corresponding_poly: list of holes polygons
|
|
74
|
-
:type corresponding_poly: list(Polygon)
|
|
75
|
-
:param row_min: row offset of combined tile
|
|
76
|
-
:type row_min: int
|
|
77
|
-
:param col_min: col offset of combined tile
|
|
78
|
-
:type col_min: int
|
|
79
|
-
:param ignore_nodata: option to activate to
|
|
80
|
-
ignore nodata values at disp mask borders
|
|
81
|
-
:type ignore_nodata: bool
|
|
82
|
-
:param ignore_zero_fill: option to activate to
|
|
83
|
-
ignore zero values at disp mask borders
|
|
84
|
-
:type ignore_zero_fill: bool
|
|
85
|
-
:param ignore_extrema: option to activate to ignore
|
|
86
|
-
extrema values at disp mask borders
|
|
87
|
-
:type ignore_extrema: bool
|
|
88
|
-
:param nb_pix: pixel number used to define disparity values band
|
|
89
|
-
at invalid region borders that will be considered for disp estimation
|
|
90
|
-
:type nb_pix: int
|
|
91
|
-
:param percent_to_erode: percentage to define size of central area
|
|
92
|
-
:type percent_to_erode: float
|
|
93
|
-
:param class_index: list of tag to use
|
|
94
|
-
:type class_index: list(str)
|
|
95
|
-
:param fill_valid_pixels: option to fill valid pixels
|
|
96
|
-
:type fill_valid_pixels: bool
|
|
97
|
-
|
|
98
|
-
:return: mask of invalid region that hasn't been filled yet
|
|
99
|
-
(original invalid region - central area)
|
|
100
|
-
:rtype: 2D np.array (row, col)
|
|
101
|
-
"""
|
|
102
|
-
|
|
103
|
-
# Generate a structuring element that will consider features
|
|
104
|
-
|
|
105
|
-
# connected even if they touch diagonally
|
|
106
|
-
struct = fill_wrap.generate_binary_structure(2, 2)
|
|
107
|
-
|
|
108
|
-
disp_mask = np.copy(disp_map["disp_msk"].values)
|
|
109
|
-
disp_values = np.copy(disp_map["disp"].values)
|
|
110
|
-
|
|
111
|
-
# Find invalid region of interest in disp data from polygon info
|
|
112
|
-
classif_mask = hole_detection_wrappers.classif_to_stacked_array(
|
|
113
|
-
disp_map, class_index
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
classif_mask_arrays, num_features = label(
|
|
117
|
-
(classif_mask > 0).astype(int), structure=struct
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
list_roi_msk = []
|
|
121
|
-
|
|
122
|
-
for segm in range(1, num_features + 1):
|
|
123
|
-
roi_msk = classif_mask_arrays == segm
|
|
124
|
-
|
|
125
|
-
# Create Polygon of current mask
|
|
126
|
-
mask_polys = hole_detection_algo.get_roi_coverage_as_poly_with_margins(
|
|
127
|
-
roi_msk, row_offset=row_min, col_offset=col_min, margin=0
|
|
128
|
-
)
|
|
129
|
-
# Clean mask polygons, remove artefacts
|
|
130
|
-
cleaned_mask_poly = []
|
|
131
|
-
for msk_pol in mask_polys:
|
|
132
|
-
# if area > 20 : small groups to remove
|
|
133
|
-
if msk_pol.area > 20:
|
|
134
|
-
cleaned_mask_poly.append(msk_pol)
|
|
135
|
-
|
|
136
|
-
if len(cleaned_mask_poly) > 1:
|
|
137
|
-
# polygons due to surrounding no data
|
|
138
|
-
# use biggest poly
|
|
139
|
-
main_poly = None
|
|
140
|
-
biggest_area = 0
|
|
141
|
-
for curent_poly in cleaned_mask_poly:
|
|
142
|
-
current_area = curent_poly.area
|
|
143
|
-
if current_area > biggest_area:
|
|
144
|
-
main_poly = curent_poly
|
|
145
|
-
cleaned_mask_poly = [main_poly]
|
|
146
|
-
logging.debug("Not single polygon for current mask")
|
|
147
|
-
|
|
148
|
-
intersect_holes = False
|
|
149
|
-
# Check if main poly intersect found classif polygons
|
|
150
|
-
if len(cleaned_mask_poly) > 0:
|
|
151
|
-
for hole_poly in corresponding_poly:
|
|
152
|
-
if hole_poly.intersects(cleaned_mask_poly[0]):
|
|
153
|
-
intersect_holes = True
|
|
154
|
-
|
|
155
|
-
if intersect_holes:
|
|
156
|
-
# is a hole to fill, not nodata in the border
|
|
157
|
-
|
|
158
|
-
# Option 'ignore_nodata' adds invalid values of disp mask at roi_msk
|
|
159
|
-
# invalid region borders
|
|
160
|
-
if ignore_nodata:
|
|
161
|
-
fill_wrap.add_surrounding_nodata_to_roi(
|
|
162
|
-
roi_msk, disp_values, disp_mask
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
# Selected invalid region dilation
|
|
166
|
-
dilatation = binary_dilation(
|
|
167
|
-
roi_msk, structure=struct, iterations=nb_pix
|
|
168
|
-
)
|
|
169
|
-
# dilated mask - initial mask = band of 'nb_pix' pix around roi
|
|
170
|
-
roi_msk_tmp = np.logical_xor(dilatation, roi_msk)
|
|
171
|
-
|
|
172
|
-
# do not use nan
|
|
173
|
-
roi_msk_tmp = np.logical_and(
|
|
174
|
-
roi_msk_tmp,
|
|
175
|
-
~np.isnan(disp_values),
|
|
176
|
-
)
|
|
177
|
-
roi_msk_tmp = np.logical_and(
|
|
178
|
-
roi_msk_tmp,
|
|
179
|
-
~np.isnan(disp_mask),
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
# Band disp values retrieval
|
|
183
|
-
# Optional filter processing n°1 : ignore invalid values in band
|
|
184
|
-
if ignore_zero_fill:
|
|
185
|
-
initial_len = np.sum(roi_msk_tmp)
|
|
186
|
-
roi_msk_tmp = np.logical_and(
|
|
187
|
-
roi_msk_tmp,
|
|
188
|
-
disp_map["disp"].values.astype(bool),
|
|
189
|
-
)
|
|
190
|
-
logging.info(
|
|
191
|
-
"Zero_fill_disp_mask - Filtering {} \
|
|
192
|
-
disparity values, equivalent to {}% of data".format(
|
|
193
|
-
initial_len - np.sum(roi_msk_tmp),
|
|
194
|
-
100 - (100 * np.sum(roi_msk_tmp)) / initial_len,
|
|
195
|
-
)
|
|
196
|
-
)
|
|
197
|
-
band_disp_values = disp_values[roi_msk_tmp]
|
|
198
|
-
|
|
199
|
-
# Optional filter processing n°2 : remove extreme values (10%)
|
|
200
|
-
if ignore_extrema and len(band_disp_values) != 0:
|
|
201
|
-
initial_len = len(band_disp_values)
|
|
202
|
-
msk_extrema = np.copy(roi_msk_tmp)
|
|
203
|
-
msk_extrema[:] = 0
|
|
204
|
-
msk_extrema[
|
|
205
|
-
np.where(
|
|
206
|
-
abs(disp_values - np.mean(band_disp_values))
|
|
207
|
-
< 1.65 * np.std(band_disp_values)
|
|
208
|
-
)
|
|
209
|
-
] = 1
|
|
210
|
-
roi_msk_tmp = np.logical_and(
|
|
211
|
-
roi_msk_tmp,
|
|
212
|
-
msk_extrema,
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
band_disp_values = disp_values[roi_msk_tmp]
|
|
216
|
-
logging.info(
|
|
217
|
-
"Extrema values - Filtering {} disparity values,\
|
|
218
|
-
equivalent to {}% of data".format(
|
|
219
|
-
initial_len - len(band_disp_values),
|
|
220
|
-
100 - (100 * len(band_disp_values)) / initial_len,
|
|
221
|
-
)
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
if len(band_disp_values) != 0:
|
|
225
|
-
disp_moy = np.mean(band_disp_values)
|
|
226
|
-
logging.info("Disparity mean comptuted : {}".format(disp_moy))
|
|
227
|
-
|
|
228
|
-
# roi_msk can be filled with 0 if neighbours have filled mask
|
|
229
|
-
if np.sum(~roi_msk) > 0:
|
|
230
|
-
# Definition of central area to fill using plane model
|
|
231
|
-
erosion_value = fill_wrap.define_interpolation_band_width(
|
|
232
|
-
roi_msk, percent_to_erode
|
|
233
|
-
)
|
|
234
|
-
central_area = binary_erosion(
|
|
235
|
-
roi_msk, structure=struct, iterations=erosion_value
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
# Exclude pixels outside of epipolar footprint
|
|
239
|
-
mask = (
|
|
240
|
-
disp_map[cst.EPI_MSK].values
|
|
241
|
-
!= mask_cst.NO_DATA_IN_EPIPOLAR_RECTIFICATION
|
|
242
|
-
)
|
|
243
|
-
if not fill_valid_pixels:
|
|
244
|
-
# Exclude valid pixels
|
|
245
|
-
mask = np.logical_and(
|
|
246
|
-
mask, disp_map["disp_msk"].values == 0
|
|
247
|
-
)
|
|
248
|
-
central_area = np.logical_and(central_area, mask)
|
|
249
|
-
|
|
250
|
-
variable_disp = calculate_disp_plane(
|
|
251
|
-
band_disp_values,
|
|
252
|
-
roi_msk_tmp,
|
|
253
|
-
central_area,
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
disp_map["disp"].values[central_area] = variable_disp
|
|
257
|
-
disp_map["disp_msk"].values[central_area] = 255
|
|
258
|
-
disp_map[cst.EPI_MSK].values[central_area] = 0
|
|
259
|
-
fill_wrap.update_filling(
|
|
260
|
-
disp_map, central_area, "plane.hole_center"
|
|
261
|
-
)
|
|
262
|
-
|
|
263
|
-
# Retrieve borders that weren't filled yet
|
|
264
|
-
roi_msk[central_area] = 0
|
|
265
|
-
|
|
266
|
-
list_roi_msk.append(roi_msk)
|
|
267
|
-
return list_roi_msk
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
def calculate_disp_plane(
|
|
271
|
-
values,
|
|
272
|
-
mask,
|
|
273
|
-
central_area,
|
|
274
|
-
display=False,
|
|
275
|
-
):
|
|
44
|
+
def classif_to_stacked_array(disp_map, class_index):
|
|
276
45
|
"""
|
|
277
|
-
|
|
278
|
-
area using valid data and a plane model.
|
|
279
|
-
|
|
280
|
-
:param values: valid disparity values
|
|
281
|
-
:type values: 3D np.array (row, col)
|
|
282
|
-
:param mask: validity mask
|
|
283
|
-
:type mask: 3D np.array (row, col)
|
|
284
|
-
:param central_area: mask of disparity values to fill
|
|
285
|
-
:type central_area: 3D np.array (row, col)
|
|
286
|
-
:param display: plot interpolation fct in region to fill
|
|
287
|
-
:type display: boolean
|
|
288
|
-
|
|
289
|
-
:return: central interpolated disparity values
|
|
290
|
-
:rtype: list
|
|
291
|
-
"""
|
|
292
|
-
data_to_fill = np.where(central_area)
|
|
293
|
-
data = np.vstack([np.where(mask), values]).T
|
|
294
|
-
b_mat = data[:, 2]
|
|
295
|
-
# Calcul coefficient fonction optimale plan/quadratique
|
|
296
|
-
# ORDRE 1
|
|
297
|
-
a_mat = np.vstack((data[:, :2].T, np.ones_like(b_mat))).T
|
|
298
|
-
fit, __, __, __ = lstsq(a_mat, b_mat)
|
|
299
|
-
|
|
300
|
-
# Détermination des valeurs optimales pour les coords centrales
|
|
301
|
-
x_to_fill = data_to_fill[0]
|
|
302
|
-
y_to_fill = data_to_fill[1]
|
|
303
|
-
val = list(
|
|
304
|
-
map(lambda x, y: fit[0] * x + fit[1] * y + fit[2], x_to_fill, y_to_fill)
|
|
305
|
-
)
|
|
306
|
-
# Option d'affichage de la fonction plan
|
|
307
|
-
if display:
|
|
308
|
-
fill_wrap.plot_function(data, fit)
|
|
309
|
-
|
|
310
|
-
return val
|
|
46
|
+
Convert disparity dataset to mask correspoding to all classes
|
|
311
47
|
|
|
48
|
+
:param disp_map: disparity dataset
|
|
49
|
+
:type disp_map: xarray Dataset
|
|
50
|
+
:param class_index: classification tags
|
|
51
|
+
:type class_index: list of str
|
|
312
52
|
|
|
313
|
-
def fill_area_borders_using_interpolation(
|
|
314
|
-
disp_map,
|
|
315
|
-
masks_to_fill,
|
|
316
|
-
options,
|
|
317
|
-
fill_valid_pixels,
|
|
318
|
-
):
|
|
319
|
-
"""
|
|
320
|
-
Raster interpolation command
|
|
321
|
-
:param disp_map: disparity values
|
|
322
|
-
:type disp_map: 2D np.array (row, col)
|
|
323
|
-
:param masks_to_fill: masks to locate disp values to fill
|
|
324
|
-
:type masks_to_fill: list(2D np.array (row, col))
|
|
325
|
-
:param options: parameters for interpolation methods
|
|
326
|
-
:type options: dict
|
|
327
|
-
:param fill_valid_pixels: option to fill valid pixels
|
|
328
|
-
:type fill_valid_pixels: bool
|
|
329
53
|
"""
|
|
330
|
-
# Copy input data - disparity values + mask with values to fill
|
|
331
|
-
raster = np.copy(disp_map["disp"].values)
|
|
332
|
-
|
|
333
|
-
# Interpolation step
|
|
334
|
-
for mask_to_fill in masks_to_fill:
|
|
335
|
-
# Exclude pixels outside of epipolar footprint
|
|
336
|
-
mask = (
|
|
337
|
-
disp_map[cst.EPI_MSK].values
|
|
338
|
-
!= mask_cst.NO_DATA_IN_EPIPOLAR_RECTIFICATION
|
|
339
|
-
)
|
|
340
|
-
if not fill_valid_pixels:
|
|
341
|
-
# Exclude valid pixels
|
|
342
|
-
mask = np.logical_and(mask, disp_map["disp_msk"].values == 0)
|
|
343
|
-
mask_to_fill = np.logical_and(mask_to_fill, mask)
|
|
344
54
|
|
|
345
|
-
|
|
346
|
-
|
|
55
|
+
index_class = np.where(
|
|
56
|
+
np.isin(
|
|
57
|
+
np.array(disp_map.coords[cst.BAND_CLASSIF].values),
|
|
58
|
+
np.array(class_index),
|
|
347
59
|
)
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
disp_map[cst.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
def fill_disp_using_plane(
|
|
356
|
-
disp_map: xr.Dataset,
|
|
357
|
-
corresponding_poly,
|
|
358
|
-
row_min,
|
|
359
|
-
col_min,
|
|
360
|
-
ignore_nodata: bool,
|
|
361
|
-
ignore_zero_fill: bool,
|
|
362
|
-
ignore_extrema: bool,
|
|
363
|
-
nb_pix: int,
|
|
364
|
-
percent_to_erode: float,
|
|
365
|
-
interp_options: dict,
|
|
366
|
-
classification,
|
|
367
|
-
fill_valid_pixels,
|
|
368
|
-
) -> xr.Dataset:
|
|
369
|
-
"""
|
|
370
|
-
Fill disparity map holes
|
|
371
|
-
|
|
372
|
-
:param disp_map: disparity map
|
|
373
|
-
:type disp_map: xr.Dataset
|
|
374
|
-
:param corresponding_poly: list of holes polygons
|
|
375
|
-
:type corresponding_poly: list(Polygon)
|
|
376
|
-
:param row_min: row offset of combined tile
|
|
377
|
-
:type row_min: int
|
|
378
|
-
:param col_min: col offset of combined tile
|
|
379
|
-
:type col_min: int
|
|
380
|
-
:param ignore_nodata: ingore nodata
|
|
381
|
-
:type ignore_nodata: bool
|
|
382
|
-
:param ignore_zero_fill: ingnore zero fill
|
|
383
|
-
:type ignore_zero_fill: bool
|
|
384
|
-
:param ignore_extrema: ignore extrema
|
|
385
|
-
:type ignore_extrema: bool
|
|
386
|
-
:param nb_pix: margin to use
|
|
387
|
-
:type nb_pix: int
|
|
388
|
-
:param percent_to_erode: percent to erode
|
|
389
|
-
:type percent_to_erode: float
|
|
390
|
-
:param interp_options: interp_options
|
|
391
|
-
:type interp_options: dict
|
|
392
|
-
:param classification: list of tag to use
|
|
393
|
-
:type classification: list(str)
|
|
394
|
-
:param fill_valid_pixels: option to fill valid pixels
|
|
395
|
-
:type fill_valid_pixels: bool
|
|
396
|
-
"""
|
|
397
|
-
|
|
398
|
-
border_region = fill_central_area_using_plane(
|
|
399
|
-
disp_map,
|
|
400
|
-
corresponding_poly,
|
|
401
|
-
row_min,
|
|
402
|
-
col_min,
|
|
403
|
-
ignore_nodata,
|
|
404
|
-
ignore_zero_fill,
|
|
405
|
-
ignore_extrema,
|
|
406
|
-
nb_pix,
|
|
407
|
-
percent_to_erode,
|
|
408
|
-
classification,
|
|
409
|
-
fill_valid_pixels,
|
|
60
|
+
)[0].tolist()
|
|
61
|
+
# get index for each band classification of the non zero values
|
|
62
|
+
stack_index = np.any(
|
|
63
|
+
disp_map[cst.EPI_CLASSIFICATION].values[index_class, :, :] > 0,
|
|
64
|
+
axis=0,
|
|
410
65
|
)
|
|
411
66
|
|
|
412
|
-
|
|
413
|
-
disp_map,
|
|
414
|
-
border_region,
|
|
415
|
-
interp_options,
|
|
416
|
-
fill_valid_pixels,
|
|
417
|
-
)
|
|
67
|
+
return stack_index
|
|
418
68
|
|
|
419
69
|
|
|
420
70
|
def fill_disp_using_zero_padding(
|
|
421
71
|
disp_map: xr.Dataset,
|
|
422
|
-
|
|
72
|
+
classif_tag,
|
|
423
73
|
fill_valid_pixels,
|
|
424
74
|
) -> xr.Dataset:
|
|
425
75
|
"""
|
|
@@ -427,23 +77,32 @@ def fill_disp_using_zero_padding(
|
|
|
427
77
|
|
|
428
78
|
:param disp_map: disparity map
|
|
429
79
|
:type disp_map: xr.Dataset
|
|
430
|
-
:param
|
|
431
|
-
:type
|
|
80
|
+
:param classif_tag: classification tags
|
|
81
|
+
:type classif_tag: list
|
|
432
82
|
:param fill_valid_pixels: option to fill valid pixels
|
|
433
83
|
:type fill_valid_pixels: bool
|
|
434
84
|
"""
|
|
435
85
|
# get index of the application class config
|
|
436
86
|
# according the coords classif band
|
|
437
|
-
if cst.BAND_CLASSIF in disp_map.coords:
|
|
87
|
+
if cst.BAND_CLASSIF in disp_map.coords or "nodata" in classif_tag:
|
|
438
88
|
# get index for each band classification
|
|
439
|
-
|
|
440
|
-
disp_map,
|
|
441
|
-
|
|
89
|
+
if classif_tag != ["nodata"]:
|
|
90
|
+
stack_index = classif_to_stacked_array(disp_map, classif_tag)
|
|
91
|
+
else:
|
|
92
|
+
stack_index = np.zeros(disp_map[cst.EPI_MSK].values.shape)
|
|
93
|
+
if "nodata" in classif_tag:
|
|
94
|
+
nodata_mask = np.logical_or(
|
|
95
|
+
disp_map[cst.EPI_MSK].values != 0,
|
|
96
|
+
np.isnan(disp_map["disp"].values),
|
|
97
|
+
)
|
|
98
|
+
stack_index = np.logical_or(stack_index, nodata_mask)
|
|
99
|
+
|
|
442
100
|
# Exclude pixels outside of epipolar footprint
|
|
443
101
|
mask = (
|
|
444
102
|
disp_map[cst.EPI_MSK].values
|
|
445
103
|
!= mask_cst.NO_DATA_IN_EPIPOLAR_RECTIFICATION
|
|
446
104
|
)
|
|
105
|
+
|
|
447
106
|
if not fill_valid_pixels:
|
|
448
107
|
# Exclude valid pixels
|
|
449
108
|
mask = np.logical_and(mask, disp_map["disp_msk"].values == 0)
|