Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Fix imshow edges#8300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletionslib/matplotlib/image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -390,8 +390,6 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
mask = A.mask
# ~A.mask # masked data
A = rgba
output = np.zeros((out_height, out_width, 4),
dtype=A.dtype)
alpha = 1.0
created_rgba_mask = True
else:
Expand All@@ -414,15 +412,13 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
elif A.shape[2] != 4:
raise ValueError("Invalid dimensions, got %s" % (A.shape,))

output = np.zeros((out_height, out_width, 4), dtype=A.dtype)

alpha = self.get_alpha()
if alpha is None:
alpha = 1.0

output = np.zeros((out_height, out_width, 4), dtype=A.dtype)

_image.resample(
A, output, t, _interpd_[self.get_interpolation()],
self.get_resample(), alpha,
self.get_resample(), alpha if alpha is not None else 1,
self.get_filternorm() or 0.0, self.get_filterrad() or 0.0)

if created_rgba_mask:
Expand All@@ -447,7 +443,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
# and the pixels that Agg is telling us to ignore (relavent
# to non-affine transforms)
# Use half alpha as the threshold for pixels to mask.
out_mask = out_mask | (hid_output[..., 3]< .5)
out_mask = out_mask | (hid_output[..., 3]== 0)
output = np.ma.masked_array(
hid_output[..., 0],
out_mask)
Expand All@@ -465,9 +461,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,

# Apply alpha *after* if the input was greyscale without a mask
if A.ndim == 2 or created_rgba_mask:
alpha_channel = output[:, :, 3]
alpha = self.get_alpha()
if alpha is not None and alpha != 1.0:
alpha_channel = output[:, :, 3]
alpha_channel[:] = np.asarray(
np.asarray(alpha_channel, np.float32) * alpha,
np.uint8)
Expand Down
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletionslib/matplotlib/tests/test_image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@
from numpy.testing import (
assert_array_equal, assert_array_almost_equal, assert_allclose)
from matplotlib.testing.noseclasses import KnownFailureTest
from copy importcopy
from copy importdeepcopy
from numpy import ma
import matplotlib.image as mimage
import matplotlib.colors as colors
Expand DownExpand Up@@ -155,6 +155,7 @@ def test_imsave():

assert_array_equal(arr_dpi1, arr_dpi100)

@cleanup
def test_imsave_color_alpha():
# Test that imsave accept arrays with ndim=3 where the third dimension is
# color and alpha without raising any exceptions, and that the data is
Expand DownExpand Up@@ -698,7 +699,7 @@ def test_mask_image_over_under():
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = 10*(Z2 - Z1) # difference of Gaussians

palette =copy(plt.cm.gray)
palette =deepcopy(plt.cm.gray)
palette.set_over('r', 1.0)
palette.set_under('g', 1.0)
palette.set_bad('b', 1.0)
Expand DownExpand Up@@ -761,7 +762,7 @@ def test_imshow_endianess():
remove_text=True, style='default')
def test_imshow_masked_interpolation():

cm =copy(plt.get_cmap('viridis'))
cm =deepcopy(plt.get_cmap('viridis'))
cm.set_over('r')
cm.set_under('b')
cm.set_bad('k')
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp