cars 1.0.0a1__cp311-cp311-win_amd64.whl → 1.0.0a3__cp311-cp311-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.

Files changed (81) hide show
  1. cars/__init__.py +4 -4
  2. cars/applications/application.py +14 -6
  3. cars/applications/application_template.py +22 -0
  4. cars/applications/auxiliary_filling/auxiliary_filling_from_sensors_app.py +15 -10
  5. cars/applications/auxiliary_filling/auxiliary_filling_wrappers.py +7 -6
  6. cars/applications/dem_generation/abstract_dem_generation_app.py +9 -5
  7. cars/applications/dem_generation/dem_generation_wrappers.py +48 -25
  8. cars/applications/dem_generation/dichotomic_generation_app.py +27 -9
  9. cars/applications/dem_generation/rasterization_app.py +85 -32
  10. cars/applications/dense_match_filling/abstract_dense_match_filling_app.py +4 -0
  11. cars/applications/dense_match_filling/cpp/dense_match_filling_cpp.cp311-win_amd64.dll.a +0 -0
  12. cars/applications/dense_match_filling/cpp/dense_match_filling_cpp.cp311-win_amd64.pyd +0 -0
  13. cars/applications/dense_match_filling/fill_disp_algo.py +41 -12
  14. cars/applications/dense_match_filling/plane_app.py +11 -0
  15. cars/applications/dense_match_filling/zero_padding_app.py +11 -1
  16. cars/applications/dense_matching/census_mccnn_sgm_app.py +254 -548
  17. cars/applications/dense_matching/cpp/dense_matching_cpp.cp311-win_amd64.dll.a +0 -0
  18. cars/applications/dense_matching/cpp/dense_matching_cpp.cp311-win_amd64.pyd +0 -0
  19. cars/applications/dense_matching/dense_matching_algo.py +59 -11
  20. cars/applications/dense_matching/dense_matching_wrappers.py +51 -31
  21. cars/applications/dense_matching/disparity_grid_algo.py +566 -0
  22. cars/applications/dense_matching/loaders/config_mapping.json +13 -0
  23. cars/applications/dense_matching/loaders/global_land_cover_map.tif +0 -0
  24. cars/applications/dense_matching/loaders/pandora_loader.py +78 -1
  25. cars/applications/dsm_filling/border_interpolation_app.py +10 -5
  26. cars/applications/dsm_filling/bulldozer_filling_app.py +14 -7
  27. cars/applications/dsm_filling/exogenous_filling_app.py +10 -5
  28. cars/applications/grid_generation/grid_correction_app.py +0 -53
  29. cars/applications/grid_generation/transform_grid.py +5 -5
  30. cars/applications/point_cloud_fusion/pc_fusion_algo.py +17 -11
  31. cars/applications/point_cloud_fusion/pc_fusion_wrappers.py +3 -4
  32. cars/applications/point_cloud_outlier_removal/abstract_outlier_removal_app.py +9 -5
  33. cars/applications/point_cloud_outlier_removal/small_components_app.py +5 -3
  34. cars/applications/point_cloud_outlier_removal/statistical_app.py +4 -2
  35. cars/applications/rasterization/abstract_pc_rasterization_app.py +1 -0
  36. cars/applications/rasterization/rasterization_algo.py +20 -27
  37. cars/applications/rasterization/rasterization_wrappers.py +6 -5
  38. cars/applications/rasterization/simple_gaussian_app.py +30 -17
  39. cars/applications/resampling/resampling_algo.py +44 -49
  40. cars/applications/sparse_matching/sift_app.py +2 -22
  41. cars/applications/sparse_matching/sparse_matching_wrappers.py +0 -49
  42. cars/applications/triangulation/line_of_sight_intersection_app.py +1 -1
  43. cars/applications/triangulation/triangulation_wrappers.py +2 -1
  44. cars/bundleadjustment.py +51 -11
  45. cars/cars.py +15 -5
  46. cars/core/constants.py +1 -1
  47. cars/core/geometry/abstract_geometry.py +166 -12
  48. cars/core/geometry/shareloc_geometry.py +61 -14
  49. cars/core/inputs.py +15 -0
  50. cars/core/projection.py +117 -0
  51. cars/data_structures/cars_dataset.py +7 -5
  52. cars/orchestrator/cluster/log_wrapper.py +1 -1
  53. cars/orchestrator/cluster/mp_cluster/multiprocessing_cluster.py +1 -1
  54. cars/orchestrator/orchestrator.py +1 -1
  55. cars/orchestrator/registry/saver_registry.py +0 -78
  56. cars/pipelines/default/default_pipeline.py +69 -52
  57. cars/pipelines/parameters/advanced_parameters.py +17 -0
  58. cars/pipelines/parameters/advanced_parameters_constants.py +4 -0
  59. cars/pipelines/parameters/depth_map_inputs.py +22 -67
  60. cars/pipelines/parameters/dsm_inputs.py +16 -29
  61. cars/pipelines/parameters/output_parameters.py +44 -8
  62. cars/pipelines/parameters/sensor_inputs.py +117 -24
  63. cars/pipelines/parameters/sensor_loaders/basic_sensor_loader.py +3 -3
  64. cars/pipelines/parameters/sensor_loaders/pivot_sensor_loader.py +2 -2
  65. cars/pipelines/parameters/sensor_loaders/sensor_loader.py +4 -6
  66. cars/pipelines/parameters/sensor_loaders/sensor_loader_template.py +2 -2
  67. cars/pipelines/pipeline.py +8 -8
  68. cars/pipelines/unit/unit_pipeline.py +276 -274
  69. cars/starter.py +20 -1
  70. cars-1.0.0a3.dist-info/DELVEWHEEL +2 -0
  71. {cars-1.0.0a1.dist-info → cars-1.0.0a3.dist-info}/METADATA +3 -2
  72. {cars-1.0.0a1.dist-info → cars-1.0.0a3.dist-info}/RECORD +77 -74
  73. cars.libs/libgcc_s_seh-1-ca70890bbc5723b6d0ea31e9c9cded2b.dll +0 -0
  74. cars.libs/libstdc++-6-00ee19f73d5122a1277c137b1c218401.dll +0 -0
  75. cars.libs/libwinpthread-1-f5042e8e3d21edce20c1bc99445f551b.dll +0 -0
  76. cars-1.0.0a1.dist-info/DELVEWHEEL +0 -2
  77. cars.libs/libgcc_s_seh-1-f2b6825d483bdf14050493af93b5997d.dll +0 -0
  78. cars.libs/libstdc++-6-6b0059df6bc601df5a0f18a5805eea05.dll +0 -0
  79. cars.libs/libwinpthread-1-e01b8e85fd67c2b861f64d4ccc7df607.dll +0 -0
  80. {cars-1.0.0a1.dist-info → cars-1.0.0a3.dist-info}/WHEEL +0 -0
  81. {cars-1.0.0a1.dist-info → cars-1.0.0a3.dist-info}/entry_points.txt +0 -0
@@ -63,14 +63,16 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
63
63
 
64
64
  # pylint: disable=too-many-instance-attributes
65
65
 
66
- def __init__(self, conf=None):
66
+ def __init__(self, scaling_coeff, conf=None):
67
67
  """
68
68
  Init function of Rasterization
69
69
 
70
+ :param scaling_coeff: scaling factor for resolution
71
+ :type scaling_coeff: float
70
72
  :param conf: configuration for Rasterization
71
73
  :return: an application_to_use object
72
74
  """
73
- super().__init__(conf=conf)
75
+ super().__init__(scaling_coeff, conf=conf)
74
76
 
75
77
  # check conf
76
78
  self.used_method = self.used_config["method"]
@@ -86,7 +88,12 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
86
88
  self.morphological_filters_size = self.used_config[
87
89
  "morphological_filters_size"
88
90
  ]
89
- self.median_filter_size = self.used_config["median_filter_size"]
91
+ self.preprocessing_median_filter_size = self.used_config[
92
+ "preprocessing_median_filter_size"
93
+ ]
94
+ self.postprocessing_median_filter_size = self.used_config[
95
+ "postprocessing_median_filter_size"
96
+ ]
90
97
  self.dem_median_output_resolution = self.used_config[
91
98
  "dem_median_output_resolution"
92
99
  ]
@@ -129,13 +136,20 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
129
136
 
130
137
  # Overload conf
131
138
  overloaded_conf["method"] = conf.get("method", "bulldozer_on_raster")
132
- overloaded_conf["resolution"] = conf.get("resolution", 2)
133
- overloaded_conf["margin"] = conf.get("margin", 500)
139
+ overloaded_conf["resolution"] = conf.get(
140
+ "resolution", float(self.scaling_coeff * 2)
141
+ )
142
+ overloaded_conf["margin"] = conf.get(
143
+ "margin", float(self.scaling_coeff * 500)
144
+ )
134
145
  overloaded_conf["morphological_filters_size"] = conf.get(
135
146
  "morphological_filters_size", 30
136
147
  )
137
- overloaded_conf["median_filter_size"] = conf.get(
138
- "median_filter_size", 5
148
+ overloaded_conf["preprocessing_median_filter_size"] = conf.get(
149
+ "preprocessing_median_filter_size", 5
150
+ )
151
+ overloaded_conf["postprocessing_median_filter_size"] = conf.get(
152
+ "postprocessing_median_filter_size", 7
139
153
  )
140
154
  overloaded_conf["dem_median_output_resolution"] = conf.get(
141
155
  "dem_median_output_resolution", 30
@@ -145,7 +159,9 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
145
159
  )
146
160
  overloaded_conf["min_dem"] = conf.get("min_dem", -500)
147
161
  overloaded_conf["max_dem"] = conf.get("max_dem", 1000)
148
- overloaded_conf["height_margin"] = conf.get("height_margin", 20)
162
+ overloaded_conf["height_margin"] = conf.get(
163
+ "height_margin", float(self.scaling_coeff * 20)
164
+ )
149
165
  overloaded_conf["bulldozer_max_object_size"] = conf.get(
150
166
  "bulldozer_max_object_size", 8
151
167
  )
@@ -164,12 +180,13 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
164
180
  application_constants.SAVE_INTERMEDIATE_DATA: bool,
165
181
  "margin": And(Or(float, int), lambda x: x > 0),
166
182
  "morphological_filters_size": And(int, lambda x: x > 0),
167
- "median_filter_size": And(int, lambda x: x > 0),
183
+ "preprocessing_median_filter_size": And(int, lambda x: x > 0),
184
+ "postprocessing_median_filter_size": And(int, lambda x: x > 0),
168
185
  "dem_median_output_resolution": And(int, lambda x: x > 0),
169
186
  "fillnodata_max_search_distance": And(int, lambda x: x > 0),
170
187
  "min_dem": And(Or(int, float), lambda x: x < 0),
171
188
  "max_dem": And(Or(int, float), lambda x: x > 0),
172
- "height_margin": And(Or(float, int), lambda x: x > 0),
189
+ "height_margin": Or(list, float, int),
173
190
  "bulldozer_max_object_size": And(int, lambda x: x > 0),
174
191
  "compute_stats": bool,
175
192
  "coregistration": bool,
@@ -191,8 +208,10 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
191
208
  dem_min_file_name,
192
209
  dem_max_file_name,
193
210
  dem_median_file_name,
194
- geoid_path,
211
+ input_geoid,
212
+ output_geoid,
195
213
  initial_elevation=None,
214
+ default_alt=0,
196
215
  cars_orchestrator=None,
197
216
  ):
198
217
  """
@@ -208,7 +227,8 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
208
227
  :type dem_max_file_name: str
209
228
  :param dem_median_file_name: path of dem_median
210
229
  :type dem_median_file_name: str
211
- :param geoid_path: geoid path
230
+ :param input_geoid: input geoid path
231
+ :param output_geoid: output geoid path
212
232
  :param dem_roi_to_use: dem roi polygon to use as roi
213
233
 
214
234
  :return: dem data computed with mean, min and max.
@@ -220,6 +240,11 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
220
240
  # Generate point cloud
221
241
  epsg = 4326
222
242
 
243
+ # Optimize the case when input and output geoid are the same
244
+ if output_geoid is True:
245
+ input_geoid = False
246
+ output_geoid = False
247
+
223
248
  resolution_in_meters = self.resolution
224
249
 
225
250
  # rasterize point cloud
@@ -275,24 +300,45 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
275
300
  not_filled_pixels = dem_data == nodata
276
301
 
277
302
  # Add geoid
278
- with rio.open(geoid_path) as in_geoid:
279
- # Reproject the geoid data to match the DSM
280
- input_geoid_data = np.empty(
281
- dem_data.shape, dtype=in_geoid.dtypes[0]
282
- )
303
+ if input_geoid:
304
+ with rio.open(input_geoid) as in_geoid:
305
+ # Reproject the geoid data to match the DSM
306
+ input_geoid_data = np.empty(
307
+ dem_data.shape, dtype=in_geoid.dtypes[0]
308
+ )
283
309
 
284
- logging.info("Reprojection of geoid data")
310
+ logging.info("Reprojection of geoid data")
285
311
 
286
- reproject(
287
- source=rio.band(in_geoid, 1),
288
- destination=input_geoid_data,
289
- src_transform=in_geoid.transform,
290
- src_crs=in_geoid.crs,
291
- dst_transform=profile["transform"],
292
- dst_crs=profile["crs"],
293
- resampling=Resampling.bilinear,
294
- )
295
- dem_data -= input_geoid_data
312
+ reproject(
313
+ source=rio.band(in_geoid, 1),
314
+ destination=input_geoid_data,
315
+ src_transform=in_geoid.transform,
316
+ src_crs=in_geoid.crs,
317
+ dst_transform=profile["transform"],
318
+ dst_crs=profile["crs"],
319
+ resampling=Resampling.bilinear,
320
+ )
321
+ dem_data -= input_geoid_data
322
+
323
+ if output_geoid:
324
+ with rio.open(input_geoid) as in_geoid:
325
+ # Reproject the geoid data to match the DSM
326
+ input_geoid_data = np.empty(
327
+ dem_data.shape, dtype=in_geoid.dtypes[0]
328
+ )
329
+
330
+ logging.info("Reprojection of geoid data")
331
+
332
+ reproject(
333
+ source=rio.band(in_geoid, 1),
334
+ destination=input_geoid_data,
335
+ src_transform=in_geoid.transform,
336
+ src_crs=in_geoid.crs,
337
+ dst_transform=profile["transform"],
338
+ dst_crs=profile["crs"],
339
+ resampling=Resampling.bilinear,
340
+ )
341
+ dem_data += input_geoid_data
296
342
 
297
343
  # apply morphological filters and height margin
298
344
  footprint = skimage.morphology.disk(
@@ -314,7 +360,10 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
314
360
  dem_median = skimage.filters.median(
315
361
  dem_data,
316
362
  footprint=np.ones(
317
- (self.median_filter_size, self.median_filter_size)
363
+ (
364
+ self.preprocessing_median_filter_size,
365
+ self.preprocessing_median_filter_size,
366
+ )
318
367
  ),
319
368
  )
320
369
 
@@ -329,13 +378,13 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
329
378
  dem_median[eroded_mask] = nodata
330
379
  dem_max[eroded_mask] = nodata
331
380
 
332
- # Rectify pixels where DEM min < DEM - min_depth
381
+ # Rectify pixels where DEM min < DEM median + min_depth
333
382
  dem_min = np.where(
334
- dem_median - dem_min < self.min_dem,
383
+ dem_min - dem_median < self.min_dem,
335
384
  dem_median + self.min_dem,
336
385
  dem_min,
337
386
  )
338
- # Rectify pixels where DEM max > DEM + max_height
387
+ # Rectify pixels where DEM max > DEM median + max_height
339
388
  dem_max = np.where(
340
389
  dem_max - dem_median > self.max_dem,
341
390
  dem_median + self.max_dem,
@@ -369,12 +418,15 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
369
418
  downsample_dem(
370
419
  dem_median_path_out,
371
420
  scale=self.dem_median_output_resolution / resolution_in_meters,
421
+ median_filter_size=self.postprocessing_median_filter_size,
422
+ default_alt=default_alt,
372
423
  )
373
424
 
374
425
  # Launch Bulldozer on dem min
375
426
  saved_transform = edit_transform(
376
427
  dem_min_path, resolution=resolution_in_meters
377
428
  )
429
+ logging.info("Launch Bulldozer on DEM min")
378
430
  temp_output_path = launch_bulldozer(
379
431
  dem_min_path,
380
432
  os.path.join(output_dir, "dem_min_bulldozer"),
@@ -390,6 +442,7 @@ class Rasterization(DemGeneration, short_name="bulldozer_on_raster"):
390
442
  dem_max_path, resolution=resolution_in_meters
391
443
  )
392
444
  reverse_dem(dem_max_path)
445
+ logging.info("Launch Bulldozer on DEM max")
393
446
  temp_output_path = launch_bulldozer(
394
447
  dem_max_path,
395
448
  os.path.join(output_dir, "dem_max_bulldozer"),
@@ -163,6 +163,7 @@ class DenseMatchFilling(ApplicationTemplate, metaclass=ABCMeta):
163
163
  pair_folder,
164
164
  pair_key,
165
165
  app_name=None,
166
+ nodata_epi_disp=0,
166
167
  ):
167
168
  """
168
169
  Create dataset and registered the output in the orchestrator
@@ -177,6 +178,8 @@ class DenseMatchFilling(ApplicationTemplate, metaclass=ABCMeta):
177
178
  :type pair_key: str
178
179
  :param app_name: application name for file names
179
180
  :type app_name: str
181
+ :param nodata_epi_disp: the nodata for the epi disp
182
+ :type nodata_epi_disp: int
180
183
 
181
184
  """
182
185
  if app_name is None:
@@ -204,6 +207,7 @@ class DenseMatchFilling(ApplicationTemplate, metaclass=ABCMeta):
204
207
  cst_disp.MAP,
205
208
  new_epipolar_disparity_map,
206
209
  cars_ds_name="epi_disp_" + app_name + "_filled",
210
+ nodata=nodata_epi_disp,
207
211
  )
208
212
 
209
213
  self.orchestrator.add_to_save_lists(
@@ -59,6 +59,7 @@ def fill_central_area_using_plane( # noqa: C901
59
59
  nb_pix: int,
60
60
  percent_to_erode: float,
61
61
  class_index: list,
62
+ fill_valid_pixels: bool,
62
63
  ):
63
64
  """
64
65
  Finds central area of invalid region and estimates disparity values
@@ -91,6 +92,8 @@ def fill_central_area_using_plane( # noqa: C901
91
92
  :type percent_to_erode: float
92
93
  :param class_index: list of tag to use
93
94
  :type class_index: list(str)
95
+ :param fill_valid_pixels: option to fill valid pixels
96
+ :type fill_valid_pixels: bool
94
97
 
95
98
  :return: mask of invalid region that hasn't been filled yet
96
99
  (original invalid region - central area)
@@ -233,11 +236,16 @@ def fill_central_area_using_plane( # noqa: C901
233
236
  )
234
237
 
235
238
  # Exclude pixels outside of epipolar footprint
236
- central_area = np.logical_and(
237
- central_area,
239
+ mask = (
238
240
  disp_map[cst.EPI_MSK].values
239
- != mask_cst.NO_DATA_IN_EPIPOLAR_RECTIFICATION,
241
+ != mask_cst.NO_DATA_IN_EPIPOLAR_RECTIFICATION
240
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)
241
249
 
242
250
  variable_disp = calculate_disp_plane(
243
251
  band_disp_values,
@@ -302,7 +310,12 @@ def calculate_disp_plane(
302
310
  return val
303
311
 
304
312
 
305
- def fill_area_borders_using_interpolation(disp_map, masks_to_fill, options):
313
+ def fill_area_borders_using_interpolation(
314
+ disp_map,
315
+ masks_to_fill,
316
+ options,
317
+ fill_valid_pixels,
318
+ ):
306
319
  """
307
320
  Raster interpolation command
308
321
  :param disp_map: disparity values
@@ -311,6 +324,8 @@ def fill_area_borders_using_interpolation(disp_map, masks_to_fill, options):
311
324
  :type masks_to_fill: list(2D np.array (row, col))
312
325
  :param options: parameters for interpolation methods
313
326
  :type options: dict
327
+ :param fill_valid_pixels: option to fill valid pixels
328
+ :type fill_valid_pixels: bool
314
329
  """
315
330
  # Copy input data - disparity values + mask with values to fill
316
331
  raster = np.copy(disp_map["disp"].values)
@@ -318,11 +333,14 @@ def fill_area_borders_using_interpolation(disp_map, masks_to_fill, options):
318
333
  # Interpolation step
319
334
  for mask_to_fill in masks_to_fill:
320
335
  # Exclude pixels outside of epipolar footprint
321
- mask_to_fill = np.logical_and(
322
- mask_to_fill,
336
+ mask = (
323
337
  disp_map[cst.EPI_MSK].values
324
- != mask_cst.NO_DATA_IN_EPIPOLAR_RECTIFICATION,
338
+ != mask_cst.NO_DATA_IN_EPIPOLAR_RECTIFICATION
325
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)
326
344
 
327
345
  interpol_raster = fill_wrap.make_raster_interpolation(
328
346
  raster, mask_to_fill, options
@@ -346,6 +364,7 @@ def fill_disp_using_plane(
346
364
  percent_to_erode: float,
347
365
  interp_options: dict,
348
366
  classification,
367
+ fill_valid_pixels,
349
368
  ) -> xr.Dataset:
350
369
  """
351
370
  Fill disparity map holes
@@ -372,6 +391,8 @@ def fill_disp_using_plane(
372
391
  :type interp_options: dict
373
392
  :param classification: list of tag to use
374
393
  :type classification: list(str)
394
+ :param fill_valid_pixels: option to fill valid pixels
395
+ :type fill_valid_pixels: bool
375
396
  """
376
397
 
377
398
  border_region = fill_central_area_using_plane(
@@ -385,18 +406,21 @@ def fill_disp_using_plane(
385
406
  nb_pix,
386
407
  percent_to_erode,
387
408
  classification,
409
+ fill_valid_pixels,
388
410
  )
389
411
 
390
412
  fill_area_borders_using_interpolation(
391
413
  disp_map,
392
414
  border_region,
393
415
  interp_options,
416
+ fill_valid_pixels,
394
417
  )
395
418
 
396
419
 
397
420
  def fill_disp_using_zero_padding(
398
421
  disp_map: xr.Dataset,
399
422
  class_index,
423
+ fill_valid_pixels,
400
424
  ) -> xr.Dataset:
401
425
  """
402
426
  Fill disparity map holes
@@ -405,6 +429,8 @@ def fill_disp_using_zero_padding(
405
429
  :type disp_map: xr.Dataset
406
430
  :param class_index: class index according to the classification tag
407
431
  :type class_index: int
432
+ :param fill_valid_pixels: option to fill valid pixels
433
+ :type fill_valid_pixels: bool
408
434
  """
409
435
  # get index of the application class config
410
436
  # according the coords classif band
@@ -414,14 +440,17 @@ def fill_disp_using_zero_padding(
414
440
  disp_map, class_index
415
441
  )
416
442
  # Exclude pixels outside of epipolar footprint
417
- stack_index = np.logical_and(
418
- stack_index,
443
+ mask = (
419
444
  disp_map[cst.EPI_MSK].values
420
- != mask_cst.NO_DATA_IN_EPIPOLAR_RECTIFICATION,
445
+ != mask_cst.NO_DATA_IN_EPIPOLAR_RECTIFICATION
421
446
  )
422
- # set disparity value to np.nan where the class is
447
+ if not fill_valid_pixels:
448
+ # Exclude valid pixels
449
+ mask = np.logical_and(mask, disp_map["disp_msk"].values == 0)
450
+ stack_index = np.logical_and(stack_index, mask)
451
+ # set disparity value to zero where the class is
423
452
  # non zero value and masked region
424
- disp_map["disp"].values[stack_index] = np.nan
453
+ disp_map["disp"].values[stack_index] = 0
425
454
  disp_map["disp_msk"].values[stack_index] = 255
426
455
  disp_map[cst.EPI_MSK].values[stack_index] = 0
427
456
  # Add a band to disparity dataset to memorize which pixels are filled
@@ -84,6 +84,7 @@ class PlaneFill(
84
84
  self.nb_pix = self.used_config["nb_pix"]
85
85
  self.percent_to_erode = self.used_config["percent_to_erode"]
86
86
  self.classification = self.used_config["classification"]
87
+ self.fill_valid_pixels = self.used_config["fill_valid_pixels"]
87
88
  # Saving files
88
89
  self.save_intermediate_data = self.used_config["save_intermediate_data"]
89
90
 
@@ -126,6 +127,9 @@ class PlaneFill(
126
127
  overloaded_conf["nb_pix"] = conf.get("nb_pix", 20)
127
128
  overloaded_conf["percent_to_erode"] = conf.get("percent_to_erode", 0.2)
128
129
  overloaded_conf["classification"] = conf.get("classification", None)
130
+ overloaded_conf["fill_valid_pixels"] = conf.get(
131
+ "fill_valid_pixels", True
132
+ )
129
133
  # Saving files
130
134
  overloaded_conf["save_intermediate_data"] = conf.get(
131
135
  "save_intermediate_data", False
@@ -144,6 +148,7 @@ class PlaneFill(
144
148
  "nb_pix": Or(None, int),
145
149
  "percent_to_erode": Or(None, float),
146
150
  "classification": Or(None, [str]),
151
+ "fill_valid_pixels": bool,
147
152
  }
148
153
 
149
154
  # Check conf
@@ -242,6 +247,7 @@ class PlaneFill(
242
247
  pair_folder,
243
248
  pair_key,
244
249
  app_name="plane",
250
+ nodata_epi_disp=-9999,
245
251
  )
246
252
 
247
253
  # Get saving infos in order to save tiles when they are computed
@@ -380,6 +386,7 @@ class PlaneFill(
380
386
  nb_pix=self.nb_pix,
381
387
  percent_to_erode=self.percent_to_erode,
382
388
  interp_options=interp_options,
389
+ fill_valid_pixels=self.fill_valid_pixels,
383
390
  saving_info=full_saving_info,
384
391
  )
385
392
 
@@ -405,6 +412,7 @@ def fill_disparity_plane_wrapper(
405
412
  nb_pix=20,
406
413
  percent_to_erode=0.3,
407
414
  interp_options=None,
415
+ fill_valid_pixels=True,
408
416
  saving_info=None,
409
417
  ):
410
418
  """
@@ -434,6 +442,8 @@ def fill_disparity_plane_wrapper(
434
442
  :type percent_to_erode: float
435
443
  :param interp_options: interp_options
436
444
  :type interp_options: dict
445
+ :param fill_valid_pixels: option to fill valid pixels
446
+ :type fill_valid_pixels: bool
437
447
  :param saving_info: saving infos
438
448
  :type saving_info: dict
439
449
 
@@ -469,6 +479,7 @@ def fill_disparity_plane_wrapper(
469
479
  percent_to_erode,
470
480
  interp_options,
471
481
  classification,
482
+ fill_valid_pixels,
472
483
  )
473
484
 
474
485
  # Find xarray Dataset corresponding to current tile
@@ -67,6 +67,7 @@ class ZerosPadding(
67
67
  # get conf
68
68
  self.used_method = self.used_config["method"]
69
69
  self.classification = self.used_config["classification"]
70
+ self.fill_valid_pixels = self.used_config["fill_valid_pixels"]
70
71
 
71
72
  # Saving files
72
73
  self.save_intermediate_data = self.used_config["save_intermediate_data"]
@@ -93,6 +94,9 @@ class ZerosPadding(
93
94
  overloaded_conf["method"] = conf.get("method", "zero_padding")
94
95
 
95
96
  overloaded_conf["classification"] = conf.get("classification", None)
97
+ overloaded_conf["fill_valid_pixels"] = conf.get(
98
+ "fill_valid_pixels", True
99
+ )
96
100
  # Saving files
97
101
  overloaded_conf["save_intermediate_data"] = conf.get(
98
102
  "save_intermediate_data", False
@@ -102,6 +106,7 @@ class ZerosPadding(
102
106
  "method": str,
103
107
  "save_intermediate_data": bool,
104
108
  "classification": Or(None, [str]),
109
+ "fill_valid_pixels": bool,
105
110
  }
106
111
 
107
112
  # Check conf
@@ -179,6 +184,7 @@ class ZerosPadding(
179
184
  pair_folder,
180
185
  pair_key,
181
186
  app_name="zero_padding",
187
+ nodata_epi_disp=-9999,
182
188
  )
183
189
 
184
190
  # Get saving infos in order to save tiles when they are computed
@@ -229,6 +235,7 @@ class ZerosPadding(
229
235
  window,
230
236
  overlap,
231
237
  classif_index=self.classification,
238
+ fill_valid_pixels=self.fill_valid_pixels,
232
239
  saving_info=full_saving_info,
233
240
  )
234
241
 
@@ -247,6 +254,7 @@ def fill_disparity_zeros_wrapper(
247
254
  window,
248
255
  overlap,
249
256
  classif_index,
257
+ fill_valid_pixels,
250
258
  saving_info=None,
251
259
  ):
252
260
  """
@@ -260,6 +268,8 @@ def fill_disparity_zeros_wrapper(
260
268
  :type overlap: list
261
269
  :param class_index: class index according to the classification tag
262
270
  :type class_index: list
271
+ :param fill_valid_pixels: option to fill valid pixels
272
+ :type fill_valid_pixels: bool
263
273
  :param saving_info: saving infos
264
274
  :type saving_info: dict
265
275
 
@@ -268,7 +278,7 @@ def fill_disparity_zeros_wrapper(
268
278
  """
269
279
  # Add a band to disparity dataset to memorize which pixels are filled
270
280
  disp = fd_wrappers.add_empty_filling_band(disp, ["zeros_padding"])
271
- fd_algo.fill_disp_using_zero_padding(disp, classif_index)
281
+ fd_algo.fill_disp_using_zero_padding(disp, classif_index, fill_valid_pixels)
272
282
  result = copy.copy(disp)
273
283
 
274
284
  # Fill with attributes