diff --git a/lantern_scripts/combine.py b/lantern_scripts/combine.py index 7c2035113..cdb3bc758 100755 --- a/lantern_scripts/combine.py +++ b/lantern_scripts/combine.py @@ -71,7 +71,8 @@ if __name__ == "__main__": well_addr = str(well_addr) hdr_well_image = cv2.imread(well_addr, cv2.IMREAD_UNCHANGED) - hdr_fast_image = cv2.imread(well_addr.replace(args.well_dir, args.fast_dir), cv2.IMREAD_UNCHANGED) + if args.fast_dir is not None: + hdr_fast_image = cv2.imread(well_addr.replace(args.well_dir, args.fast_dir), cv2.IMREAD_UNCHANGED) # hdr_well_image = np.uint8(hdr_well_image * 255.0) @@ -79,7 +80,9 @@ if __name__ == "__main__": if args.do_linearization: hdr_well_image = apply_correction((camera_data["b"], camera_data["g"], camera_data["r"]), np.array(hdr_well_image), CORRECTION_CURVE_TYPE) - hdr_fast_image = apply_correction((camera_data["b"], camera_data["g"], camera_data["r"]), np.array(hdr_fast_image), CORRECTION_CURVE_TYPE) + + if args.fast_dir is not None: + hdr_fast_image = apply_correction((camera_data["b"], camera_data["g"], camera_data["r"]), np.array(hdr_fast_image), CORRECTION_CURVE_TYPE) # well_mask_addr = well_addr.replace('/well_expo/', '/well_mask/') @@ -88,15 +91,21 @@ if __name__ == "__main__": # well_mask = well_mask.astype(np.float32) / 255.0 # well_mask[well_mask > 0.1] = 1.0 - weights_well = cut_weighting_function(hdr_well_image, WELL_EXPOSURE) - weights_fast = cut_weighting_function(hdr_fast_image, FAST_EXPOSURE) + + if args.fast_dir is not None: + weights_well = cut_weighting_function(hdr_well_image, WELL_EXPOSURE) + weights_fast = cut_weighting_function(hdr_fast_image, FAST_EXPOSURE) # fast_mask = cv2.imread(well_mask_addr.replace('/well_mask/', '/fast_mask/')) # fast_mask = fast_mask.astype(np.float32) / 255.0 # final_output = weights_well * (hdr_well_image / WELL_EXPOSURE) + weights_fast * (hdr_fast_image / FAST_EXPOSURE) # final_output = final_output / (weights_well+weights_well) - final_output = weights_well * (hdr_well_image / WELL_EXPOSURE) + (hdr_fast_image / FAST_EXPOSURE) + + if args.fast_dir is not None: + final_output = weights_well * (hdr_well_image / WELL_EXPOSURE) + (hdr_fast_image / FAST_EXPOSURE) + else: + final_output = hdr_well_image / WELL_EXPOSURE # final_output = weights_well * (hdr_well_image / WELL_EXPOSURE) output_addr = well_addr.replace(args.well_dir, args.out_dir)