-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix image interpolation #8966
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix image interpolation #8966
Conversation
In rotate_image.png, the edge of the image seems to follow the middle of the dashes more closely in the original version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on the approach--interpolating before doing any other transforms makes sense to me. I'm also a little concerned about the change to rotate_image
, but no clue what's going wrong.
Caught a couple typos in the comments.
lib/matplotlib/image.py
Outdated
|
||
# we are done with A_scaled now, remove from namespace to be sure! | ||
del A_scaled | ||
# un-scale the resampled data to approximatly the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approximatly -> approximate
lib/matplotlib/image.py
Outdated
self.get_filterrad() or 0.0) | ||
# we are done with the mask, delete from namespace to be sure! | ||
del mask | ||
# Agg tells us a pixel has no value not setting a value into it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a word missing in this comment.
a883cd2
to
2db0d6a
Compare
I anticipate re-writing history here before it gets merged. |
I see some failures locally that I do not understand, let see if we see them on travis. Still have to sort out those edge effects. History will get re-written at least once more before this is ready to merge. |
I am actually comfertable that the edges are the correct behavior. If you look at the zoomed in bottom 3x3 area you can see that the out of range area is against the edge, the bottom right is the highest value which is equal to vmax of the norm. It is correct, from the interpolations point of view, that the pixel past the last point (which it view as being at the center of that pixel) are of greater value (which are then correctly marked as out of range). |
c511460
to
db19f9f
Compare
1962d84
to
1e160aa
Compare
Todos:
|
- interpolate raw, not normed, data - should reduce memory footprint, only 1 or 2 copies of input data - this will change many tests in small ways - down-casting input data before interpolation was causing issues with numerical precision so work in no less than the input float type - Numpy 1.7 does not support `np.nanmin` and `np.nanmax` on masked arrays (instead of returning a number it returns a MaskedIterator).
- update to mpl20 style - re-generate as needed - bump threshold on pngsuite test
- bump to mpl20 style
1e160aa
to
ec43d0e
Compare
from copy import copy
import matplotlib.image as mimage
def interpolation_grid(data, vmin=None, vmax=None):
cm = copy(plt.get_cmap('viridis'))
cm.set_over('r')
cm.set_under('b')
cm.set_bad('k')
fig, ax_grid = plt.subplots(3, 6, sharex=True, sharey=True)
ret = []
for interp, ax in zip(sorted(mimage._interpd_), ax_grid.ravel()):
ax.set_title(interp)
im = ax.imshow(data, cmap=cm, interpolation=interp)
ax.axis('off')
im.set_clim(vmin, vmax)
ret.append(im)
return ret
ims_a = interpolation_grid([[0, 1], [1, 0]], 0, 1)
ims_b = interpolation_grid(np.tile([[0, 1], [1, 0]], (10, 10)), 0, 1) I am satisfied that the speckles are edge effects on the higher-order interpolators
That is the smallest upper limit that shows the speckles on my system which gives us an idea of the level of the numeric instability. I don't think that it is worth playing games to stay just under it as I suspect it will vary between systems. If we do anything about this we should bump the Autoscales out a bit. |
Push the stale flag down into the ScalarMappable so that it gets applied to all ScalarMappable sub-classes (ex Collections).
8186243
to
346bb1a
Compare
This is an attempt at #8631 and #6952
I expect this to fail. Already updated a bunch of images that had minor changes. There are a few with big changes that I still need to look into.
look into scaling to a bit less than full range to prevent speckles near vmin/vmax