From 68ca173ad7ed3f544185767474b081d145fca52c Mon Sep 17 00:00:00 2001 From: Matthew Kutugata Date: Fri, 15 Nov 2024 12:04:13 -0500 Subject: [PATCH] update to raw2png --- src/raw2png.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/raw2png.py b/src/raw2png.py index 8d184b4..2b794f7 100644 --- a/src/raw2png.py +++ b/src/raw2png.py @@ -36,17 +36,10 @@ def select_raw_files(raw_files, selection_mode, sample_number): def process_image(raw_file, im_height, im_width, bit_depth, output_dir): nparray = np.fromfile(raw_file, dtype=np.uint16).astype(np.uint16) org_reshaped = nparray.reshape((im_height, im_width)) - image_data = org_reshaped.astype(np.float32) / 65535. - - # Convert image data to the appropriate bit depth and integer format for color conversion - if bit_depth == 8: - image_data = (image_data * 255).astype(np.uint8) - else: - image_data = (image_data * 65535).astype(np.uint16) - + # Save the image output_file = output_dir / f"{raw_file.stem}_{bit_depth}bit.png" - cv2.imwrite(str(output_file), image_data, [cv2.IMWRITE_PNG_COMPRESSION, 1]) + cv2.imwrite(str(output_file), org_reshaped, [cv2.IMWRITE_PNG_COMPRESSION, 1]) print(f"Saved image to {output_file} with {bit_depth}-bit depth") def parse_arguments():