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