File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -178,11 +178,10 @@ def _resample(
178178 if interpolation == 'antialiased' :
179179 # don't antialias if upsampling by an integer number or
180180 # 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 ]))
186185 if ((dispx > 3 * data .shape [1 ] or
187186 dispx == data .shape [1 ] or
188187 dispx == 2 * data .shape [1 ]) and
@@ -192,7 +191,6 @@ def _resample(
192191 interpolation = 'nearest'
193192 else :
194193 interpolation = 'hanning'
195-
196194 out = np .zeros (out_shape + data .shape [2 :], data .dtype ) # 2D->2D, 3D->3D.
197195 if resample is None :
198196 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):
199199 axs .imshow (A , interpolation = 'nearest' )
200200
201201
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+
202220@check_figures_equal ()
203221def test_imshow_pil (fig_test , fig_ref ):
204222 style .use ("default" )
You can’t perform that action at this time.
0 commit comments