Commit 09687d287fbca515cb71680efb2915b95591c55f

Authored by Louis Baetens
1 parent a1b79a92
Exists in master

REFAC removed the unused libraries

PCC/alcd_labellisation_posttreatment.py
1 1 #!/usr/bin/python
2 2 # -*- coding: utf-8 -*-
3 3  
4   -import sys
5   -import os
  4 +
6 5 import os.path as op
7   -import glob
8   -import random
9   -import numpy as np
10   -import matplotlib.pyplot as plt
11   -import matplotlib
12 6 import json
13 7 import otbApplication
14   -import csv
15 8  
16 9  
17 10 def binary_label_dilatation(binary_label_tif, out_tif, radius, regularization = True):
... ...
PCC/all_run_pcc.py
... ... @@ -16,15 +16,12 @@ import find_chain_directory_paths
16 16 import comparison
17 17 import metrics_grapher
18 18 import png_converter
19   -import pixels_features_analysis
20 19  
21 20  
22 21 def create_directories(comparison_parameters):
23 22 '''
24 23 Create the directories for the code to work with
25   - '''
26   - paths_configuration = json.load(open(op.join('..', 'paths_configuration.json')))
27   -
  24 + '''
28 25 print(" Creation of the directories")
29 26 main_dir = comparison_parameters["user_choices"]["main_dir"]
30 27  
... ...
PCC/comparison.py
1 1 #!/usr/bin/python
2 2 # -*- coding: utf-8 -*-
3 3  
4   -import sys
5 4 import os
6 5 import os.path as op
7 6 import otbApplication
8 7 import numpy as np
9   -from PIL import Image, ImageDraw, ImageFont
10   -import pandas as pd
  8 +from PIL import Image
11 9 import glob
12 10 import json
13   -import shutil
14   -import time
15   -import find_chain_directory_paths
  11 +
16 12  
17 13  
18 14 def compute_comparative_image(reference_tif, to_compare_tif, out_tif, binary = True):
... ... @@ -173,7 +169,6 @@ def compare_all(comparison_parameters, binary_classif = True, reference_algo = '
173 169  
174 170  
175 171 # Get the output of the ALCD algo
176   - ref_dir = comparison_parameters["processing"][reference_algo]["sub_dir"]
177 172 ref_name = comparison_parameters["processing"][reference_algo]["prefix"]
178 173 print(ref_name)
179 174  
... ...
PCC/find_chain_directory_paths.py
1 1 #!/usr/bin/python
2 2 # -*- coding: utf-8 -*-
3 3  
4   -import sys
5   -import os
  4 +
6 5 import os.path as op
7 6 import glob
8   -import shutil
9 7 import json
10 8  
11 9  
... ...
PCC/masks_conversion.py
1 1 #!/usr/bin/python
2 2 # -*- coding: utf-8 -*-
3 3  
4   -import sys
5   -import os
6 4 import os.path as op
7 5 import otbApplication
8   -import numpy as np
9 6 import shutil
10   -import glob
11 7 import time
12 8 import subprocess
13   -import find_chain_directory_paths
14 9 import alcd_labellisation_posttreatment
15   -
  10 +import json
16 11  
17 12 def binar2decimal(nb):
18 13 '''
... ... @@ -74,7 +69,7 @@ def maja_class_selection_expression(class_nb, valid_bits, invalid_bits, binary_s
74 69 layer_expression = '( (im1b1 == {}'.format(str(valid_int[0]))
75 70 for val in valid_int[1:]:
76 71 layer_expression = layer_expression + ' or ' + 'im1b1 == {}'.format(str(val))
77   - # the class_nb is attributed to the valid pixels
  72 + # the class_nb is attributed to the valid pixels
78 73 layer_expression = layer_expression + ") ? {} : 0)".format(class_nb)
79 74 return layer_expression
80 75  
... ... @@ -460,7 +455,7 @@ def superimpose_realign(reference_tif, in_tif, out_tif):
460 455 # copy the tmp to the src one, to erase it
461 456 shutil.copy(tmp_tif, to_translate)
462 457  
463   - # superimpose the in_tif
  458 + # superimpose the in_tif
464 459 Superimpose = otbApplication.Registry.CreateApplication("Superimpose")
465 460 Superimpose.SetParameterString("inr", str(reference_tif))
466 461 Superimpose.SetParameterString("inm", str(in_tif))
... ...
PCC/metrics_grapher.py
1 1 #!/usr/bin/python
2 2 # -*- coding: utf-8 -*-
3 3  
4   -import os
5 4 import os.path as op
6 5 import json
7 6 import glob
... ...
PCC/pixels_features_analysis.py
1 1 #!/usr/bin/python
2 2 # -*- coding: utf-8 -*-
3 3  
4   -import sys
5   -import os
6 4 import os.path as op
7 5 import glob
8   -import random
9 6 import numpy as np
10 7 import matplotlib.pyplot as plt
11   -import matplotlib
12 8 import json
13 9 import otbApplication
14   -import csv
15 10 from matplotlib.lines import Line2D
16 11  
17 12 def extract_class_band(raw_img, band_to_extract, diff_img, diff_class_nb, alcd_labeled_img='', alcd_class_nb = 0):
... ...
PCC/statistics_synthesis.py
1 1 #!/usr/bin/python
2 2 # -*- coding: utf-8 -*-
3 3  
4   -import sys
5   -import os
6 4 import os.path as op
7 5 import glob
8   -import random
9 6 import numpy as np
10 7 import matplotlib.pyplot as plt
11   -import matplotlib.cbook as cbook
12   -import matplotlib
13 8 import json
14   -import otbApplication
15 9 import csv
16 10 from matplotlib.lines import Line2D
17 11 import datetime
... ... @@ -284,8 +278,6 @@ def plot_all_metrics(paths_configuration, comparison_parameters, locations, alcd
284 278 positions_sen2cor = positions[1]
285 279 positions_fmask = positions[2]
286 280  
287   - means = []
288   -
289 281 # Get the data of all the stats
290 282 if alcd_algo == "alcd_dilat":
291 283 data_maja, means_maja, stds_maja = get_data_and_means(maja_stats)
... ... @@ -481,7 +473,7 @@ def plot_all_metrics(paths_configuration, comparison_parameters, locations, alcd
481 473 plt.xticks(([t + width for t in ticks_positions]), ticks_names)
482 474  
483 475 # legend customization
484   - custom_lines = [Line2D([0], [0], color=colors[k], lw=4) for k in range(len(all_legend_names))]
  476 + custom_lines = [Line2D([0], [0], color=colors[j], lw=4) for j in range(len(all_legend_names))]
485 477 if plot_type == 'boxplot':
486 478 custom_lines.append(Line2D([0], [0], color='w', markerfacecolor = 'r', marker='o'))
487 479 all_legend_names.append('Means')
... ...