@@ -413,14 +413,12 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
413
413
raise ValueError ("Invalid dimensions, got %s" % (A .shape ,))
414
414
415
415
alpha = self .get_alpha ()
416
- if alpha is None :
417
- alpha = 1.0
418
416
419
417
output = np .zeros ((out_height , out_width , 4 ), dtype = A .dtype )
420
418
421
419
_image .resample (
422
420
A , output , t , _interpd_ [self .get_interpolation ()],
423
- self .get_resample (), alpha ,
421
+ self .get_resample (), alpha if alpha is not None else 1 ,
424
422
self .get_filternorm () or 0.0 , self .get_filterrad () or 0.0 )
425
423
426
424
if created_rgba_mask :
@@ -445,7 +443,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
445
443
# and the pixels that Agg is telling us to ignore (relavent
446
444
# to non-affine transforms)
447
445
# 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 )
449
447
output = np .ma .masked_array (
450
448
hid_output [..., 0 ],
451
449
out_mask )
@@ -463,9 +461,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
463
461
464
462
# Apply alpha *after* if the input was greyscale without a mask
465
463
if A .ndim == 2 or created_rgba_mask :
464
+ alpha_channel = output [:, :, 3 ]
466
465
alpha = self .get_alpha ()
467
466
if alpha is not None and alpha != 1.0 :
468
- alpha_channel = output [:, :, 3 ]
469
467
alpha_channel [:] = np .asarray (
470
468
np .asarray (alpha_channel , np .float32 ) * alpha ,
471
469
np .uint8 )
0 commit comments