Skip to content

Commit 51fcae4

Browse files
authored
Use same factor for all images (#82)
1 parent 1a58f4c commit 51fcae4

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

scripts/process_dm.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,16 @@ def extract_image_number(s):
122122
j = extract_image_number(fn)
123123
img = np.array(Image.open(fn))
124124

125-
if img.dtype != np.uint16:
126-
# cast to 16 bit uint16
127-
img = rescale_intensity(img, out_range='uint16')
128-
129125
h = {'ImageGetTime': timestamp, 'ImageExposureTime': exposure_time}
130126
buffer.append((j, img, h))
131127

128+
if img.dtype != np.uint16:
129+
max_val = max(img.max() for _, img, _ in buffer)
130+
min_val = min(img.min() for _, img, _ in buffer)
131+
for item in buffer:
132+
# cast to 16 bit uint16
133+
item[1] = rescale_intensity(item[1], out_range='uint16', in_range=(min_val, max_val))
134+
132135
img_conv = ImgConversion(buffer=buffer,
133136
osc_angle=osc_angle,
134137
start_angle=start_angle,

0 commit comments

Comments
 (0)