Skip to content

Commit e16211b

Browse files
author
Miquel Massot
committed
Remove save raw image_mean and image_std when plotting already takes care of it
1 parent c8b15d6 commit e16211b

1 file changed

Lines changed: 14 additions & 25 deletions

File tree

src/correct_images/corrector.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
import random
1212
from pathlib import Path
1313

14-
try:
15-
# Try using the v2 API directly to avoid a warning from imageio >= 2.16.2
16-
from imageio.v2 import imwrite
17-
except ImportError:
18-
from imageio import imwrite
19-
2014
import joblib
2115
import matplotlib
2216
import numpy as np
@@ -675,9 +669,7 @@ def get_altitude_and_depth_maps(self):
675669
# Load depth maps
676670
path_depth = self.path_processed / "3d_reconstruction" / "depth_maps"
677671
if not path_depth.exists():
678-
Console.quit(
679-
"Depth maps folder", path_depth, "does not exist."
680-
)
672+
Console.quit("Depth maps folder", path_depth, "does not exist.")
681673
images_to_drop = []
682674
for img_idx, image_path in enumerate(self.camera_image_list):
683675
p = path_depth / os.path.relpath(image_path, self.path_raw)
@@ -691,16 +683,18 @@ def get_altitude_and_depth_maps(self):
691683
if len(images_to_drop) > 0:
692684
if len(images_to_drop) == len(self.camera_image_list):
693685
Console.quit(
694-
"No depth maps found in", path_depth,
695-
"\nLast path checked:", p
686+
"No depth maps found in", path_depth, "\nLast path checked:", p
696687
)
697688
Console.info(
698-
"Dropping", len(images_to_drop), "of", len(self.camera_image_list),
699-
"images for which no depth maps exists."
689+
"Dropping",
690+
len(images_to_drop),
691+
"of",
692+
len(self.camera_image_list),
693+
"images for which no depth maps exists.",
700694
)
701695
for idx in sorted(images_to_drop, reverse=True):
702696
del self.camera_image_list[idx]
703-
assert(len(self.camera_image_list) == len(self.depth_map_list))
697+
assert len(self.camera_image_list) == len(self.depth_map_list)
704698

705699
Console.info("Depth maps loaded")
706700
return
@@ -767,9 +761,13 @@ def generate_attenuation_correction_parameters(self):
767761
Console.info("Computing depth map histogram with", hist_bins.size, "bins")
768762

769763
distance_vector = np.zeros((len(self.depth_map_list), 1))
770-
with tqdm(desc="Computing depth map histogram", total=len(self.depth_map_list)) as pbar:
764+
with tqdm(
765+
desc="Computing depth map histogram", total=len(self.depth_map_list)
766+
) as pbar:
771767
for i, dm_file in enumerate(self.depth_map_list):
772-
dm_np = depth_map.loader(dm_file, self.image_width, self.image_height)
768+
dm_np = depth_map.loader(
769+
dm_file, self.image_width, self.image_height
770+
)
773771
distance_vector[i] = dm_np.mean()
774772
pbar.update(1)
775773

@@ -1035,15 +1033,6 @@ def generate_attenuation_correction_parameters(self):
10351033
image_raw_mean = image_raw_mean.transpose((1, 2, 0))
10361034
image_raw_std = image_raw_std.transpose((1, 2, 0))
10371035

1038-
imwrite(
1039-
Path(self.attenuation_parameters_folder) / "image_raw_mean.png",
1040-
image_raw_mean,
1041-
)
1042-
imwrite(
1043-
Path(self.attenuation_parameters_folder) / "image_raw_std.png",
1044-
image_raw_std,
1045-
)
1046-
10471036
corrections.save_attenuation_plots(
10481037
self.attenuation_parameters_folder,
10491038
img_mean=image_raw_mean,

0 commit comments

Comments
 (0)