@@ -188,6 +188,7 @@ def __init__(self, ax,
188
188
filternorm = True ,
189
189
filterrad = 4.0 ,
190
190
resample = False ,
191
+ antialiased = True ,
191
192
** kwargs
192
193
):
193
194
"""
@@ -214,6 +215,7 @@ def __init__(self, ax,
214
215
self .set_interpolation (interpolation )
215
216
self .set_resample (resample )
216
217
self .axes = ax
218
+ self ._antialiased = antialiased
217
219
218
220
self ._imcache = None
219
221
@@ -232,6 +234,22 @@ def get_size(self):
232
234
233
235
return self ._A .shape [:2 ]
234
236
237
+ def get_antialiased (self ):
238
+ """
239
+ Get whether down-sampled images are low-pass filtered before
240
+ down-sampling (i.e. when there is more data than pixels).
241
+ """
242
+ return self ._antialiased
243
+
244
+ def set_antialiased (self , antialiased ):
245
+ """
246
+ Set if an anti-aliasing (low-pass) filter is applied to the data
247
+ if the image will down-sample the data (i.e. if the there is
248
+ more data than pixels). If *True*, and the data is down-sampled,
249
+ any user supplied filters are ignored, and a Lanczos filter is
250
+ applied with radius `2 * M_data / M_image`.
251
+ """
252
+
235
253
def set_alpha (self , alpha ):
236
254
"""
237
255
Set the alpha value used for blending - not supported on all backends.
@@ -422,6 +440,10 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
422
440
A_scaled += 0.1
423
441
A_resampled = np .zeros ((out_height , out_width ),
424
442
dtype = A_scaled .dtype )
443
+ if self .get_antialiased () and A .shape [0 ] > out_height :
444
+ self .set_interpolation ('lanczos' )
445
+ self .set_filterrad (2.0 * A .shape [0 ] / out_height )
446
+
425
447
# resample the input data to the correct resolution and shape
426
448
_image .resample (A_scaled , A_resampled ,
427
449
t ,
@@ -819,6 +841,7 @@ def __init__(self, ax,
819
841
filternorm = 1 ,
820
842
filterrad = 4.0 ,
821
843
resample = False ,
844
+ antialiased = True ,
822
845
** kwargs
823
846
):
824
847
@@ -847,6 +870,7 @@ def __init__(self, ax,
847
870
filternorm = filternorm ,
848
871
filterrad = filterrad ,
849
872
resample = resample ,
873
+ antialiased = antialiased ,
850
874
** kwargs
851
875
)
852
876
@@ -1266,6 +1290,7 @@ def __init__(self, bbox,
1266
1290
filternorm = 1 ,
1267
1291
filterrad = 4.0 ,
1268
1292
resample = False ,
1293
+ antialiased = True ,
1269
1294
interp_at_native = True ,
1270
1295
** kwargs
1271
1296
):
@@ -1293,6 +1318,7 @@ def __init__(self, bbox,
1293
1318
filternorm = filternorm ,
1294
1319
filterrad = filterrad ,
1295
1320
resample = resample ,
1321
+ antialiased = antialiased ,
1296
1322
** kwargs
1297
1323
)
1298
1324
0 commit comments