@@ -79,15 +79,16 @@ def _array_to_b64str(img, backend="pil", compression=4):
79
79
return base64_string
80
80
81
81
82
- def _vectorize_zvalue (z ):
82
+ def _vectorize_zvalue (z , mode = 'max' ):
83
+ alpha = 255 if mode == 'max' else 0
83
84
if z is None :
84
85
return z
85
86
elif np .isscalar (z ):
86
- return [z ] * 3 + [255 ]
87
+ return [z ] * 3 + [alpha ]
87
88
elif len (z ) == 1 :
88
- return list (z ) * 3 + [255 ]
89
+ return list (z ) * 3 + [alpha ]
89
90
elif len (z ) == 3 :
90
- return list (z ) + [255 ]
91
+ return list (z ) + [alpha ]
91
92
elif len (z ) == 4 :
92
93
return z
93
94
else :
@@ -382,7 +383,7 @@ def imshow(
382
383
elif img .ndim == 3 and img .shape [- 1 ] in [3 , 4 ] or (img .ndim == 2 and binary_string ):
383
384
rescale_image = True # to check whether image has been modified
384
385
if zmin is not None and zmax is not None :
385
- zmin , zmax = _vectorize_zvalue (zmin ), _vectorize_zvalue (zmax )
386
+ zmin , zmax = _vectorize_zvalue (zmin , mode = 'min' ), _vectorize_zvalue (zmax , mode = 'max' )
386
387
if binary_string :
387
388
if zmin is None and zmax is None : # no rescaling, faster
388
389
img_rescaled = img
@@ -392,6 +393,7 @@ def imshow(
392
393
img , in_range = (zmin [0 ], zmax [0 ]), out_range = np .uint8
393
394
)
394
395
else :
396
+ print (zmin , zmax )
395
397
img_rescaled = np .dstack (
396
398
[
397
399
rescale_intensity (
@@ -409,7 +411,7 @@ def imshow(
409
411
)
410
412
trace = go .Image (source = img_str )
411
413
else :
412
- colormodel = "rgb" if img .shape [- 1 ] == 3 else "rgba "
414
+ colormodel = "rgb" if img .shape [- 1 ] == 3 else "rgba256 "
413
415
trace = go .Image (z = img , zmin = zmin , zmax = zmax , colormodel = colormodel )
414
416
layout = {}
415
417
if origin == "lower" :
0 commit comments