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 image vlim clipping again#17636

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

Merged

Conversation

tacaswell
Copy link
Member

PR Summary

We use the Agg resampling routines to resample the user supplied data
to the number of pixels we need in the final rendering. The Agg
routines require that the input be in the range [0, 1] and it
aggressively clips input and output to that range. Thus, we rescale
the user data to [0, 1], pass it to the resampling routine and then
rescale the result back to the original range. The resampled (shape
wise) data is than passed to the user supplied norm to normalize the
data to [0, 1] (again), and then onto the color map to get to RBGA.

Due to float precision, the first re-scaling does not round-trip
exactly in all casses. The error is extremely small (8-16 orders of
magnitude smaller than the data) but for values that are exactly equal
to the user supplied vmin or vmax this can be enough to push the data
out of the "valid" gamut and be marked as "over" or "under". The
colormaps default to using the top/bottom color for the over/under
color so this is not visible, however if the user sets the over/under
colors of the cmap this issue will be visible.

closes#16910

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant

We use the Agg resampling routines to resample the user supplied datato the number of pixels we need in the final rendering.  The Aggroutines require that the input be in the range [0, 1] and itaggressively clips input and output to that range.  Thus, we rescalethe user data to [0, 1], pass it to the resampling routine and thenrescale the result back to the original range.   The resampled (shapewise) data is than passed to the user supplied norm to normalize thedata to [0, 1] (again), and then onto the color map to get to RBGA.Due to float precision, the first re-scaling does not round-tripexactly in all casses.  The error is extremely small (8-16 orders ofmagnitude smaller than the data) but for values that are exactly equalto the user supplied vmin or vmax this can be enough to push the dataout of the "valid" gamut and be marked as "over" or "under".  Thecolormaps default to using the top/bottom color for the over/undercolor so this is not visible, however if the user sets the over/undercolors of the cmap this issue will be visible.closesmatplotlib#16910
There are 7 pixels in the bi-linear interpolation that have changed byat most 1 bit per channel.
@tacaswelltacaswell added this to thev3.4.0 milestoneJun 15, 2020
@anntzer
Copy link
Contributor

postci

@tacaswelltacaswell modified the milestones:v3.4.0,v3.3.0Jun 15, 2020
@jklymakjklymak merged commitc3b37ca intomatplotlib:masterJun 15, 2020
@tacaswelltacaswell deleted the fix_image_vlim_clipping_again branchJune 15, 2020 20:36
tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestSep 11, 2020
closesmatplotlib#18415We need to special case when rescaling the user input forinterpolation with LogNorm.  The issue is that due to the inherentprecision limits of floating point math we can end up with errors onthe order if 1e-18 of the overall data range when rescaling.  If thebottom vlim is close to 0 and the top is order 10e20 than this errorcan result in the rescaled vmin being negative which then fails whenwe (temporarily) change the vmin/vmax on the norm.We started adjusting the vmin/vmax to work around the same issue withfloat precision inmatplotlib#17636 /3dea5c7 to make sure that values exactlyequal to the limits did not move across the boundary and geterroneously mapped is over/under.Long term we may want to add the ability for the norms to suggest totheir clients what the constraints on the vmin/vmax are, buthard-coding a special case for LogNorm is the pragmatic solution.
@tacaswelltacaswell mentioned this pull requestSep 11, 2020
2 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.3.0
Development

Successfully merging this pull request may close these issues.

Axes.imshow draws invalid color at value is 0 when max of 'X' not equal to vmax
3 participants
@tacaswell@anntzer@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp