Commit 92e2ee13d79f39393239f168f92ec9990cf30bd9

Authored by Louis Baetens
1 parent 868bbef5
Exists in master

RMV the deprecated parts

ALCD/OTB_workflow.py
... ... @@ -298,22 +298,14 @@ def image_classification(global_parameters, shell=True, proceed=True, additional
298 298 def confidence_map_viz(global_parameters, additional_name = ''):
299 299 '''
300 300 6.5 Enhancement of the classification map
301   - TODO : improve this function with median
302 301 '''
303 302 main_dir = global_parameters["user_choices"]["main_dir"]
304 303  
305 304 confidence_map_in = op.join(main_dir, 'Out', "confidence{}.tif".format(additional_name))
306 305 confidence_map_out = op.join(main_dir, 'Out', "confidence{}_enhanced.tif".format(additional_name))
307 306  
308   - #~ cutoff_threshold = 0.75
309   - #~ dilate_radius = 3
310   - #~ confidence_map_exploitation.confidence_map_change(confidence_map_in, confidence_map_outconfidence_map_out, cutoff_threshold, dilate_radius, method = 'old')
311   -
312   - confidence_map_exploitation.confidence_map_change(confidence_map_in, confidence_map_out, median_radius = 11, method = 'new')
313   -
  307 + confidence_map_exploitation.confidence_map_change(confidence_map_in, confidence_map_out, median_radius = 11)
314 308  
315   -
316   -
317 309 return
318 310 #-------- 3. POST-PROCESSING ---------------------
319 311  
... ...
ALCD/all_run_alcd.py
... ... @@ -311,28 +311,6 @@ def main():
311 311 run_all(part = 4, first_iteration = first_iteration, force = force)
312 312 run_all(part = 5, first_iteration = first_iteration, force = force)
313 313 run_all(part = 6, first_iteration = first_iteration, force = force)
314   -
315   - # -----------------------------------------------___-
316   - # ELIF 2 A SUPPRIMER !!!!! ----------------------___-
317   - elif user_input == 2:
318   - run_all(part = 1, first_iteration = first_iteration, location=location, wanted_date=wanted_date, clear_date=clear_date)
319   -
320   - src_masks_dir = glob.glob(op.join('/mnt/data/home/baetensl/clouds_detection_git/Data_ALCD_copy_to_keep_all_good',
321   - '{}_*_{}'.format(location, wanted_date), 'In_data', 'Masks'))[0]
322   - dst_masks_dir = op.join(glob.glob(op.join('/mnt/data/home/baetensl/clouds_detection_git/Data_ALCD',
323   - '{}_*_{}'.format(location, wanted_date)))[0], 'In_data', 'Masks')
324   -
325   - shutil.rmtree(dst_masks_dir)
326   - shutil.copytree(src_masks_dir, dst_masks_dir)
327   -
328   - run_all(part = 2, first_iteration = first_iteration)
329   - run_all(part = 3, first_iteration = first_iteration)
330   - run_all(part = 4, first_iteration = first_iteration)
331   - run_all(part = 5, first_iteration = first_iteration)
332   - run_all(part = 6, first_iteration = first_iteration)
333   -
334   - # -----------------------------------------------___-
335   - # -----------------------------------------------___-
336 314 else:
337 315 print('Please enter a valid step value [0 or 1]')
338 316  
... ...
ALCD/confidence_map_exploitation.py
... ... @@ -20,61 +20,21 @@ import merge_shapefiles
20 20  
21 21  
22 22  
23   -def confidence_map_change(in_tif, out_tif, median_radius = 5, cutoff_threshold = 0.75, dilate_radius = 3, method = 'new'):
  23 +def confidence_map_change(in_tif, out_tif, median_radius = 5):
24 24 '''
25 25 Change the confidence map to an enhanced one
26 26 '''
27   -
28   - if method != 'old':
29   - # If number is even, add 1 to be odd
30   - if median_radius % 2 == 0:
31   - median_radius = median_radius+1
32   -
33   - MedianFilter = otbApplication.Registry.CreateApplication("BandMathX")
34   - MedianFilter.SetParameterStringList("il", [str(in_tif)])
35   - MedianFilter.SetParameterString("out", str(out_tif))
36   - #~ MedianFilter.SetParameterString("exp", "(median(im1b1N{}x{})) < 0.9*im1b1N{}x{}/im1b1N{}x{} ? (median(im1b1N{}x{})) : 0".format(median_radius, median_radius, median_radius, median_radius))
37   - MedianFilter.SetParameterString("exp", "(median(im1b1N{}x{}))".format(median_radius, median_radius))
38   - MedianFilter.UpdateParameters()
39   - MedianFilter.ExecuteAndWriteOutput()
40   -
41   - else: # Old method, should not be used
42   - # Cutoff
43   - RangeManip = otbApplication.Registry.CreateApplication("BandMathX")
44   - RangeManip.SetParameterStringList("il", [str(in_tif)])
45   - RangeManip.SetParameterString("exp", "((im1b1 < {} ? 0 : 100) + (im1b1 == 0 ? 100 : 0))".format(cutoff_threshold))
46   - RangeManip.UpdateParameters()
47   - RangeManip.Execute()
48   -
  27 + # If number is even, add 1 to be odd
  28 + if median_radius % 2 == 0:
  29 + median_radius = median_radius+1
  30 +
  31 + MedianFilter = otbApplication.Registry.CreateApplication("BandMathX")
  32 + MedianFilter.SetParameterStringList("il", [str(in_tif)])
  33 + MedianFilter.SetParameterString("out", str(out_tif))
  34 + MedianFilter.SetParameterString("exp", "(median(im1b1N{}x{}))".format(median_radius, median_radius))
  35 + MedianFilter.UpdateParameters()
  36 + MedianFilter.ExecuteAndWriteOutput()
49 37  
50   - Smoothing = otbApplication.Registry.CreateApplication("Smoothing")
51   - Smoothing.SetParameterInputImage("in",RangeManip.GetParameterOutputImage("out"))
52   - Smoothing.SetParameterString("type","gaussian")
53   - Smoothing.SetParameterString("type.gaussian.radius",str(5))
54   - Smoothing.UpdateParameters()
55   - Smoothing.Execute()
56   -
57   - Substract = otbApplication.Registry.CreateApplication("BandMathX")
58   - Substract.AddImageToParameterInputImageList("il",Smoothing.GetParameterOutputImage("out"))
59   - Substract.SetParameterString("out", str(out_tif))
60   - Substract.SetParameterString("exp", "(im1b1 < {} ? 0 : 1)".format(30))
61   - Substract.UpdateParameters()
62   - Substract.Execute()
63   -
64   -
65   - # Dilatation
66   - dilate_radius = 3
67   - Dilatation = otbApplication.Registry.CreateApplication("BinaryMorphologicalOperation")
68   - Dilatation.SetParameterInputImage("in",Substract.GetParameterOutputImage("out"))
69   - Dilatation.SetParameterString("out", str(out_tif))
70   - Dilatation.SetParameterString("filter","dilate")
71   - Dilatation.SetParameterString("filter.dilate.foreval","1.0")
72   - Dilatation.SetParameterString("filter.dilate.backval","0.0")
73   - Dilatation.SetParameterInt("structype.ball.xradius", dilate_radius)
74   - Dilatation.SetParameterInt("structype.ball.yradius", dilate_radius)
75   - Dilatation.UpdateParameters()
76   - Dilatation.ExecuteAndWriteOutput()
77   -
78 38 return
79 39  
80 40  
... ... @@ -128,9 +88,7 @@ def shapefile_rasterization(raw_img_tif, in_shps, out_tif):
128 88 print('Please enter 1 or 2 shapefiles')
129 89  
130 90 else:
131   - #~ in_shps = [str(i) for i in in_shps]
132 91 tmp_shp = op.join('tmp', next(tempfile._get_candidate_names()) + '.shp')
133   - #~ mask_dir = '/mnt/data/home/baetensl/clouds_detection_git/Data_ALCD/Arles_31TFJ_20171002/Previous_iterations/SAVE_3/In_data/Masks'
134 92 merge_shapefiles.merge_all_types(in_shps, tmp_shp)
135 93  
136 94 Rasterization = otbApplication.Registry.CreateApplication("Rasterization")
... ...
ALCD/layers_creation.py
... ... @@ -115,30 +115,7 @@ def populate_layer(in_shp, out_shp, x_coords, y_coords):
115 115  
116 116 return
117 117  
118   -
119   -
120   -def fill_precomputed_classes():
121   - '''
122   - DEPRECATED
123   - '''
124   - in_tif = '/mnt/data/home/baetensl/clouds_detection_git/Data_ALCD/RailroadValley_11SPC_20170501/In_data/Image/RailroadValley_bands.tif'
125   - out_shp_list = ['/mnt/data/home/baetensl/clouds_detection_git/Various_data/test_out.shp']
126   - empty_shapefile_creation(in_tif, out_shp_list, geometry_type = 'point')
127   -
128   - in_shp = '/mnt/data/home/baetensl/clouds_detection_git/Various_data/test_out.shp'
129   - out_shp = '/mnt/data/home/baetensl/clouds_detection_git/Various_data/filled.shp'
130   - x_coords = [620000, 700000]
131   - y_coords = [4250000, 4280000]
132   - populate_layer(in_shp, out_shp, x_coords, y_coords)
133   -
134   -
135   -
136   -
137   -
138   -
139 118  
140   -
141   -
142 119 def create_no_data_shp(global_parameters, force = False):
143 120 '''
144 121 Create automatically polygons overs the no_data pixels
... ...
ALCD/merge_shapefiles.py
... ... @@ -53,32 +53,6 @@ def merge_shapefiles(in_shp_list, class_list, out_shp):
53 53  
54 54 return
55 55  
56   -
57   -#~ def merge_all_types(mask_dir, out_shp):
58   - #~ ''' Merge all the shapefiles contained in mask_dir, if they
59   - #~ obey a certain nomencalture
60   - #~ DEPRECATED : not use anymore
61   - #~ '''
62   -
63   - #~ in_shp_list = []
64   - #~ class_list = []
65   - #~ names_list = []
66   - #~ names = ["background", "low_clouds", "high_clouds", "shadows", "land", "water", "snow"]
67   - #~ classes = [1,2,3,4,5,6,7]
68   -
69   - #~ for k in range(len(names)):
70   - #~ if op.exists(op.join(mask_dir, (names[k] + '.shp'))):
71   - #~ in_shp_list.append(op.join(mask_dir, (names[k] + '.shp')))
72   - #~ names_list.append(names[k])
73   - #~ class_list.append(classes[k])
74   -
75   - #~ print(in_shp_list)
76   - #~ print(class_list)
77   -
78   - #~ merge_shapefiles(in_shp_list, class_list, out_shp)
79   -
80   -
81   -
82 56  
83 57 def main():
84 58 mask_dir = '/mnt/data/home/baetensl/classification_clouds/Data/Full_orleans/In_data/Masks/'
... ...