@@ -361,7 +361,10 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
361
361
# If the image is greyscale, convert to RGBA with the
362
362
# correct alpha channel for resizing
363
363
rgba = np .empty ((A .shape [0 ], A .shape [1 ], 4 ), dtype = A .dtype )
364
- rgba [..., 0 :3 ] = np .expand_dims (A , 2 )
364
+ rgba [..., 0 ] = A # normalized data
365
+ rgba [..., 1 ] = A < 0 # under data
366
+ # TODO, ask the norm or colormap what this threshold should be
367
+ rgba [..., 2 ] = A > 1 # over data
365
368
if A .dtype .kind == 'f' :
366
369
rgba [..., 3 ] = ~ A .mask
367
370
else :
@@ -393,8 +396,13 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
393
396
if created_rgba_mask :
394
397
# Convert back to a masked greyscale array so
395
398
# colormapping works correctly
399
+ hid_output = output
396
400
output = np .ma .masked_array (
397
- output [..., 0 ], output [..., 3 ] < 0.5 )
401
+ hid_output [..., 0 ], hid_output [..., 3 ] < 0.5 )
402
+ # relabel under data
403
+ output [hid_output [..., 1 ] > .5 ] = - 1
404
+ # relabel over data
405
+ output [hid_output [..., 2 ] > .5 ] = 2
398
406
399
407
output = self .to_rgba (output , bytes = True , norm = False )
400
408
0 commit comments