File tree 2 files changed +22
-6
lines changed
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -178,11 +178,10 @@ def _resample(
178
178
if interpolation == 'antialiased' :
179
179
# don't antialias if upsampling by an integer number or
180
180
# if zooming in more than a factor of 3
181
- shape = list (data .shape )
182
- if image_obj .origin == 'upper' :
183
- shape [0 ] = 0
184
- dispx , dispy = transform .transform ([shape [1 ], shape [0 ]])
185
-
181
+ pos = np .array ([[0 , 0 ], [data .shape [1 ], data .shape [0 ]]])
182
+ disp = transform .transform (pos )
183
+ dispx = np .abs (np .diff (disp [:, 0 ]))
184
+ dispy = np .abs (np .diff (disp [:, 1 ]))
186
185
if ((dispx > 3 * data .shape [1 ] or
187
186
dispx == data .shape [1 ] or
188
187
dispx == 2 * data .shape [1 ]) and
@@ -192,7 +191,6 @@ def _resample(
192
191
interpolation = 'nearest'
193
192
else :
194
193
interpolation = 'hanning'
195
-
196
194
out = np .zeros (out_shape + data .shape [2 :], data .dtype ) # 2D->2D, 3D->3D.
197
195
if resample is None :
198
196
resample = image_obj .get_resample ()
Original file line number Diff line number Diff line change @@ -199,6 +199,24 @@ def test_imshow_upsample3(fig_test, fig_ref):
199
199
axs .imshow (A , interpolation = 'nearest' )
200
200
201
201
202
+ @check_figures_equal (extensions = ['png' ])
203
+ def test_imshow_zoom (fig_test , fig_ref ):
204
+ # should be less than 3 upsample, so should be nearest...
205
+ np .random .seed (19680801 )
206
+ dpi = 100
207
+ A = np .random .rand (int (dpi * 3 ), int (dpi * 3 ))
208
+ for fig in [fig_test , fig_ref ]:
209
+ fig .set_size_inches (2.9 , 2.9 )
210
+ axs = fig_test .subplots ()
211
+ axs .imshow (A , interpolation = 'nearest' )
212
+ axs .set_xlim ([10 , 20 ])
213
+ axs .set_ylim ([10 , 20 ])
214
+ axs = fig_ref .subplots ()
215
+ axs .imshow (A , interpolation = 'antialiased' )
216
+ axs .set_xlim ([10 , 20 ])
217
+ axs .set_ylim ([10 , 20 ])
218
+
219
+
202
220
@check_figures_equal ()
203
221
def test_imshow_pil (fig_test , fig_ref ):
204
222
style .use ("default" )
You can’t perform that action at this time.
0 commit comments