Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit afa6123

Browse filesBrowse files
committed
add test for alpha channel interpolation
1 parent 35fe0a6 commit afa6123
Copy full SHA for afa6123

File tree

Expand file treeCollapse file tree

7 files changed

+55
-44
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+55
-44
lines changed

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,21 +493,23 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
493493
alpha = 1
494494

495495
#resample alpha channel
496-
alpha_channel = A[...,3]
496+
alpha_channel = A[..., 3]
497497
_image.resample(
498-
alpha_channel, output_a, t, _interpd_[self.get_interpolation()],
498+
alpha_channel, output_a, t,
499+
_interpd_[self.get_interpolation()],
499500
self.get_resample(), alpha,
500501
self.get_filternorm(), self.get_filterrad())
501502

502503
#resample rgb channels
503-
A = _rgb_to_rgba(A[...,:3])
504+
A = _rgb_to_rgba(A[..., :3])
504505
_image.resample(
505-
A, output, t, _interpd_[self.get_interpolation()],
506+
A, output, t,
507+
_interpd_[self.get_interpolation()],
506508
self.get_resample(), alpha,
507509
self.get_filternorm(), self.get_filterrad())
508510

509511
#recombine rgb and alpha channels
510-
output[...,3] = output_a
512+
output[..., 3] = output_a
511513

512514
# at this point output is either a 2D array of normed data
513515
# (of int or float)
Binary file not shown.
Loading

‎lib/matplotlib/tests/baseline_images/test_image/image_composite_alpha.svg

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/baseline_images/test_image/image_composite_alpha.svg
+34-39Lines changed: 34 additions & 39 deletions
Loading
Loading
Loading

‎lib/matplotlib/tests/test_image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_image.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ def test_image_interps():
4343
ax3.set_ylabel('bicubic')
4444

4545

46+
@image_comparison(baseline_images=['interp_alpha'],
47+
extensions=['png'], remove_text=True)
48+
def test_alpha_interp():
49+
'Test the interpolation of the alpha channel on RGBA images'
50+
fig, (axl, axr) = plt.subplots(1, 2)
51+
# full green image
52+
img = np.zeros((5, 5, 4))
53+
img[..., 1] = np.ones((5, 5))
54+
# transparent under main diagonal
55+
img[..., 3] = np.tril(np.ones((5, 5), dtype=np.uint8))
56+
axl.imshow(img, interpolation="none")
57+
axr.imshow(img, interpolation="bilinear")
58+
59+
4660
@image_comparison(baseline_images=['interp_nearest_vs_none'],
4761
extensions=['pdf', 'svg'], remove_text=True)
4862
def test_interp_nearest_vs_none():

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.