Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5986b5b

Browse files
committed
Added the interp_at_native keyword argument to BboxImage in order to
let the user specify that the image should be treated in a Photoshop-like manner (interpolation only used if the image is being displayed at a non- native resolution). The flag is by default enabled, which matches previous behavior of matplotlib.
1 parent 683cede commit 5986b5b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

lib/matplotlib/image.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,13 +1030,21 @@ def __init__(self, bbox,
10301030
filternorm=1,
10311031
filterrad=4.0,
10321032
resample = False,
1033+
interp_at_native=True,
10331034
**kwargs
10341035
):
10351036

10361037
"""
10371038
cmap is a colors.Colormap instance
10381039
norm is a colors.Normalize instance to map luminance to 0-1
10391040
1041+
interp_at_native is a flag that determines whether or not interpolation should
1042+
still be applied when the image is displayed at its native resolution. A common
1043+
use case for this is when displaying an image for annotational purposes; it is
1044+
treated similarly to Photoshop (interpolation is only used when displaying the
1045+
image at non-native resolutions).
1046+
1047+
10401048
kwargs are an optional list of Artist keyword args
10411049
"""
10421050

@@ -1052,6 +1060,7 @@ def __init__(self, bbox,
10521060
)
10531061

10541062
self.bbox = bbox
1063+
self.interp_at_native = interp_at_native
10551064

10561065
def get_window_extent(self, renderer=None):
10571066
if renderer is None:
@@ -1127,6 +1136,10 @@ def make_image(self, renderer, magnification=1.0):
11271136

11281137
numrows, numcols = self._A.shape[:2]
11291138

1139+
if not self.interp_at_native and widthDisplay==numcols and heightDisplay==numrows:
1140+
print "setting interpolation to zero"
1141+
im.set_interpolation(0)
1142+
11301143
# resize viewport to display
11311144
rx = widthDisplay / numcols
11321145
ry = heightDisplay / numrows

0 commit comments

Comments
 (0)