GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix image interpolation by tacaswell · Pull Request #8966 · matplotlib/matplotlib

Conversation

@tacaswell

@tacaswell tacaswell commented Jul 30, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

  • re-visit rotate image and get rid of black pixels on edge
  • drop attempt to fix python2
  • add comments about ringing into test code
  • look into scaling to a bit less than full range to prevent speckles near vmin/vmax
  • test flat cases near vmin or vmax\
  • regenerate all test images with current defaults

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jul 30, 2017
@tacaswell tacaswell added this to the 2.1 (next point release) milestone Jul 30, 2017
@anntzer

anntzer commented Jul 31, 2017

Copy link
Copy Markdown
Contributor

In rotate_image.png, the edge of the image seems to follow the middle of the dashes more closely in the original version.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dopplershift
dopplershift approved these changes Jul 31, 2017
View reviewed changes

@dopplershift dopplershift left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 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

@dopplershift dopplershift Jul 31, 2017

Copy link
Copy Markdown
Contributor

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread 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

@dopplershift dopplershift Jul 31, 2017

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tacaswell tacaswell mentioned this pull request Aug 2, 2017
Incorrect imshow extent in PDF backend #8981
Closed
@tacaswell
tacaswell force-pushed the fix_image_interpolation branch from a883cd2 to 2db0d6a Compare August 6, 2017 23:26
@tacaswell

tacaswell commented Aug 6, 2017

Copy link
Copy Markdown
Member Author

I anticipate re-writing history here before it gets merged.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented Aug 6, 2017

Copy link
Copy Markdown
Member Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented Aug 7, 2017

Copy link
Copy Markdown
Member Author

I am actually comfertable that the edges are the correct behavior. If you look at the zoomed in bottom 3x3 area

so

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).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell
tacaswell force-pushed the fix_image_interpolation branch from c511460 to db19f9f Compare August 7, 2017 02:39
@tacaswell tacaswell changed the title [WIP] Fix image interpolation Fix image interpolation Aug 7, 2017
@tacaswell
tacaswell force-pushed the fix_image_interpolation branch from 1962d84 to 1e160aa Compare August 7, 2017 19:07
@tacaswell

tacaswell commented Aug 7, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Todos:

  • re-visit rotate image and get rid of black pixels on edge
  • drop attempt to fix python2
  • add comments about ringing into test code
  • look into scaling to a bit less than full range to prevent speckles near vmin/vmax
  • test flat cases near vmin or vmax\
  • regenerate all test images with current defaults
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell tacaswell mentioned this pull request Aug 7, 2017
Fix imshow edges #8300
Closed
@phobson phobson added the status: needs revision label Aug 14, 2017
@tacaswell tacaswell mentioned this pull request Aug 15, 2017
Image interpolation wrong for pixel values exceeding vmax #8631
Closed
@tacaswell tacaswell modified the milestone: 2.1 (next point release) Aug 29, 2017
tacaswell added 4 commits August 28, 2017 23:11
@tacaswell
FIX: re-work image interpolation
12c27f3
 - 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).
@tacaswell
TST: update rotated image test
63da377
@tacaswell
TST: update test images
2509030
 - update to mpl20 style
 - re-generate as needed
 - bump threshold on pngsuite test
@tacaswell
TST: update masked interpolation images
ec43d0e
 - bump to mpl20 style
@tacaswell
tacaswell force-pushed the fix_image_interpolation branch from 1e160aa to ec43d0e Compare August 29, 2017 03:14
@tacaswell
TST: add comment to test about ringing
856556f
@tacaswell tacaswell added this to the 2.1 (next point release) milestone Aug 29, 2017
@tacaswell
FIX: handle degenerate case of all equal values
b5238ac
@tacaswell

tacaswell commented Aug 30, 2017

Copy link
Copy Markdown
Member Author
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

[im.set_clim(0, 1.00000005) for im in ims_b]

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell tacaswell added status: needs review and removed status: needs revision labels Aug 30, 2017
dopplershift
dopplershift approved these changes Aug 30, 2017
View reviewed changes
@tacaswell
FIX: make image.set_clim mark the figure as stale
346bb1a
Push the stale flag down into the ScalarMappable so that it gets
applied to all ScalarMappable sub-classes (ex Collections).
@tacaswell
tacaswell force-pushed the fix_image_interpolation branch from 8186243 to 346bb1a Compare August 31, 2017 03:46
@tacaswell
TST: add flat-field test
1aebff1
@efiring
efiring merged commit b1b9404 into matplotlib:master Aug 31, 2017
@tacaswell
tacaswell deleted the fix_image_interpolation branch August 31, 2017 11:26
This was referenced Aug 31, 2017
imshow() pixelization in matplotlib 2.0.2 but not in 2.0.0 #8723
Closed
2D Normalization & Colormapping for ScalerMappables #8738
Closed
@tacaswell tacaswell mentioned this pull request Sep 24, 2017
check imshow performance #8143
Closed
@afvincent afvincent mentioned this pull request Oct 17, 2017
Different result, slower runtime of heatmap between 2.0.0 and 2.0.1 #8947
Closed
@QuLogic QuLogic removed Documentation status: needs review labels Oct 20, 2017
@jklymak jklymak mentioned this pull request Dec 30, 2017
imshow doesn't properly display some images #10072
Closed
@tacaswell tacaswell mentioned this pull request Feb 23, 2018
imshow in 2.1: color resolution depends on outliers? #10567
Closed
@QuLogic QuLogic mentioned this pull request Apr 29, 2020
Axes.imshow draws invalid color at value is 0 when max of 'X' not equal to vmax #16910
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@dopplershift dopplershift dopplershift approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Projects

None yet

Milestone

v2.1

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@tacaswell @anntzer @dopplershift @efiring @QuLogic @phobson
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.