Skip to content

Commit

Permalink
Fix for working with 32 bit images with raw_data
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon committed Nov 8, 2024
1 parent 8a0b732 commit 4496d54
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion datalab/datalab_session/analysis/raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ def raw_data(input: dict):
max_size = input.get('max_size', 500)
image = Image.fromarray(image_data)
newImage = image.resize((max_size, max_size), Image.LANCZOS)
scaled_array = np.asarray(newImage).astype(np.float16)
bitpix = abs(int(sci_hdu.header.get('BITPIX', 16)))
match bitpix:
case 8:
datatype = np.uint8
case 16:
datatype = np.float16
case 32:
datatype = np.float32
scaled_array = np.asarray(newImage).astype(datatype)
scaled_array_flipped = np.flip(scaled_array, axis=0)

return {'data': scaled_array_flipped.flatten().tolist(),
Expand Down

0 comments on commit 4496d54

Please sign in to comment.