noslice with interpolation 'nearest'

JJ,

In AxesImageBase._draw_unsampled_image, there is a call to _get_unsampled_image(...noslice=True). When using imshow(Z, interpolation='nearest'), this defeats the slicing that makes such a difference when zooming and panning a small chunk of a large image. Changing it to False makes imshow work better; I don't understand why one would ever want noslice=True. Am I missing something? Can we just change it to False? Or remove the noslice option and kwarg entirely?

Eric

Eric,

I should have left more comments about my change.
The issue is that the current slicing algorithm sometimes fails with
"_draw_unsampled_image" which support arbitrary affine transformation
of the image. The slicing gets wrong when the image is significantly
skewed or rotated. So, as a temporary measure, I simply wanted to
disable the slicing until we have a correct algorithm in place.

I guess a quick (still temporary) fix is to check if affine transform
is needed, and do the slicing if not.
Something like below. The condition is not exactly correct, but I
think it would work in most of cases.
I actually didn't test the patch. I'll be out of town until the end of
this week.

On a second thought, I think it should not be difficult to workaround
the slicing thing for arbitrary affine transform. I'll think about the
whole issue again when I get back. If you have a better idea, please
go ahead and implement.

Regards,

-JJ

diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py
index 7c1128f..b65f446 100644
--- a/lib/matplotlib/image.py
+++ b/lib/matplotlib/image.py
@@ -248,9 +248,14 @@ class _AxesImageBase(martist.Artist, cm.ScalarMappable):
         """

+ if self._image_skew_coordinate:
+ no_slice = True
+ else:
+ no_slice = False

···

+
         im, xmin, ymin, dxintv, dyintv, sx, sy = \
             self._get_unsampled_image(self._A, self.get_extent(),
- self.axes.viewLim, noslice=True)
+ self.axes.viewLim, noslice=no_slice)

         if im is None: return # I'm not if this check is required. -JJL

On Tue, Jun 22, 2010 at 8:45 PM, Eric Firing <efiring@...229...> wrote:

JJ,

In AxesImageBase._draw_unsampled_image, there is a call to
_get_unsampled_image(...noslice=True). When using imshow(Z,
interpolation='nearest'), this defeats the slicing that makes such a
difference when zooming and panning a small chunk of a large image. Changing
it to False makes imshow work better; I don't understand why one would ever
want noslice=True. Am I missing something? Can we just change it to False?
Or remove the noslice option and kwarg entirely?

Eric

In r8472, I tried to modify the image slicing so that it works even if
images are rotated and skewed. And the "noslice" option is now gon.
Let me know if it causes any problem.

Regards,

-JJ

···

On Tue, Jun 22, 2010 at 11:05 PM, Jae-Joon Lee <lee.j.joon@...149...> wrote:

Eric,

I should have left more comments about my change.
The issue is that the current slicing algorithm sometimes fails with
"_draw_unsampled_image" which support arbitrary affine transformation
of the image. The slicing gets wrong when the image is significantly
skewed or rotated. So, as a temporary measure, I simply wanted to
disable the slicing until we have a correct algorithm in place.

I guess a quick (still temporary) fix is to check if affine transform
is needed, and do the slicing if not.
Something like below. The condition is not exactly correct, but I
think it would work in most of cases.
I actually didn't test the patch. I'll be out of town until the end of
this week.

On a second thought, I think it should not be difficult to workaround
the slicing thing for arbitrary affine transform. I'll think about the
whole issue again when I get back. If you have a better idea, please
go ahead and implement.

Regards,

-JJ

diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py
index 7c1128f..b65f446 100644
--- a/lib/matplotlib/image.py
+++ b/lib/matplotlib/image.py
@@ -248,9 +248,14 @@ class _AxesImageBase(martist.Artist, cm.ScalarMappable):
"""

+ if self._image_skew_coordinate:
+ no_slice = True
+ else:
+ no_slice = False
+
im, xmin, ymin, dxintv, dyintv, sx, sy = \
self._get_unsampled_image(self._A, self.get_extent(),
- self.axes.viewLim, noslice=True)
+ self.axes.viewLim, noslice=no_slice)

    if im is None: return \# I&#39;m not if this check is required\. \-JJL

On Tue, Jun 22, 2010 at 8:45 PM, Eric Firing <efiring@...229...> wrote:

JJ,

In AxesImageBase._draw_unsampled_image, there is a call to
_get_unsampled_image(...noslice=True). When using imshow(Z,
interpolation='nearest'), this defeats the slicing that makes such a
difference when zooming and panning a small chunk of a large image. Changing
it to False makes imshow work better; I don't understand why one would ever
want noslice=True. Am I missing something? Can we just change it to False?
Or remove the noslice option and kwarg entirely?

Eric

In r8472, I tried to modify the image slicing so that it works even if
images are rotated and skewed. And the "noslice" option is now gon.
Let me know if it causes any problem.

Thanks very much, JJ, that's great!

Eric

···

On 06/26/2010 04:13 PM, Jae-Joon Lee wrote:

Regards,

-JJ