From 1a58f4c1d7d9a820d0eca5880e7df0278c5d00b2 Mon Sep 17 00:00:00 2001 From: Stef Smeets Date: Wed, 29 Nov 2023 09:06:42 +0000 Subject: [PATCH] Fix casting to uint16 (#81) --- scripts/process_dm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/process_dm.py b/scripts/process_dm.py index 1de82c9b..7691be97 100644 --- a/scripts/process_dm.py +++ b/scripts/process_dm.py @@ -2,6 +2,7 @@ from pathlib import Path import numpy as np +from skimage.exposure import rescale_intensity from PIL import Image from instamatic.processing.ImgConversionDM import ImgConversionDM as ImgConversion @@ -123,7 +124,7 @@ def extract_image_number(s): if img.dtype != np.uint16: # cast to 16 bit uint16 - img = (2**16 - 1) * (img - img.min()) / (img.max() - img.min()) + img = rescale_intensity(img, out_range='uint16') h = {'ImageGetTime': timestamp, 'ImageExposureTime': exposure_time} buffer.append((j, img, h))