12
12
from math import ceil
13
13
import os
14
14
import logging
15
+ import warnings
15
16
16
17
import numpy as np
17
18
@@ -264,8 +265,8 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
264
265
and magnified by the magnification factor.
265
266
266
267
`A` may be a greyscale image (MxN) with a dtype of `float32`,
267
- `float64`, `uint16` or `uint8`, or an RGBA image (MxNx4) with
268
- a dtype of `float32`, `float64`, or `uint8`.
268
+ `float64`, `float128`, ` uint16` or `uint8`, or an RGBA image (MxNx4)
269
+ with a dtype of `float32`, `float64`, `float128 `, or `uint8`.
269
270
270
271
If `unsampled` is True, the image will not be scaled, but an
271
272
appropriate affine transformation will be returned instead.
@@ -361,6 +362,13 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
361
362
a_min , a_max = np .int32 (0 ), np .int32 (1 )
362
363
if inp_dtype .kind == 'f' :
363
364
scaled_dtype = A .dtype
365
+ # Cast to float64
366
+ if A .dtype not in (np .float32 , np .float16 ):
367
+ if A .dtype != np .float64 :
368
+ warnings .warn (
369
+ "Casting input data from '{0}' to 'float64'"
370
+ "for imshow" .format (A .dtype ))
371
+ scaled_dtype = np .float64
364
372
else :
365
373
# probably an integer of some type.
366
374
da = a_max .astype (np .float64 ) - a_min .astype (np .float64 )
@@ -386,7 +394,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
386
394
# of over numbers.
387
395
if self .norm .vmin is not None and self .norm .vmax is not None :
388
396
dv = (np .float64 (self .norm .vmax ) -
389
- np .float64 (self .norm .vmin ))
397
+ np .float64 (self .norm .vmin ))
390
398
vmid = self .norm .vmin + dv / 2
391
399
newmin = vmid - dv * 1.e7
392
400
if newmin < a_min :
0 commit comments