@@ -413,14 +413,12 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
413413 raise ValueError ("Invalid dimensions, got %s" % (A .shape ,))
414414
415415 alpha = self .get_alpha ()
416- if alpha is None :
417- alpha = 1.0
418416
419417 output = np .zeros ((out_height , out_width , 4 ), dtype = A .dtype )
420418
421419 _image .resample (
422420 A , output , t , _interpd_ [self .get_interpolation ()],
423- self .get_resample (), alpha ,
421+ self .get_resample (), alpha if alpha is not None else 1 ,
424422 self .get_filternorm () or 0.0 , self .get_filterrad () or 0.0 )
425423
426424 if created_rgba_mask :
@@ -445,7 +443,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
445443 # and the pixels that Agg is telling us to ignore (relavent
446444 # to non-affine transforms)
447445 # Use half alpha as the threshold for pixels to mask.
448- out_mask = out_mask | (hid_output [..., 3 ] < .5 )
446+ out_mask = out_mask | (hid_output [..., 3 ] == 0 )
449447 output = np .ma .masked_array (
450448 hid_output [..., 0 ],
451449 out_mask )
@@ -463,9 +461,12 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
463461
464462 # Apply alpha *after* if the input was greyscale without a mask
465463 if A .ndim == 2 or created_rgba_mask :
464+ alpha_channel = output [:, :, 3 ]
465+ alpha_channel [:] = np .asarray (
466+ np .asarray (alpha_channel , np .float32 ) * hid_output [..., 3 ],
467+ np .uint8 )
466468 alpha = self .get_alpha ()
467469 if alpha is not None and alpha != 1.0 :
468- alpha_channel = output [:, :, 3 ]
469470 alpha_channel [:] = np .asarray (
470471 np .asarray (alpha_channel , np .float32 ) * alpha ,
471472 np .uint8 )
0 commit comments