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 scaling for large dynamic range ints#10133

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
dopplershift merged 1 commit intomatplotlib:masterfromjklymak:fix-image-scaling
Jan 15, 2018

Conversation

jklymak
Copy link
Member

PR Summary

Thisfixes#10072.

The problem was that for a uint32 image, the dynamic range was too high for a float32 to properly represent. Simply changing to float64 fixes the issue. I suppose someone could use a unit64 image, but...

Test coming: code:

importmatplotlib.pyplotaspltimportnumpyasnpimg=np.load('/Users/jklymak/downloads/test_image.npy')img=np.array([[1,2,3], [1,2,10000000000]],dtype=np.uint32)#Display full imageplt.imshow(img,interpolation='nearest')plt.clim(0,5.)plt.show()

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer
Copy link
Contributor

That's not going to help the efforts on trying to reduce the memory footprint of imshow... (#6952,#8143, etc.). Not a blocker, but should be kept in mind.

@jklymak
Copy link
MemberAuthor

Yeah, understood. This is the dumbest solution.

I don't quite understand why this rescaling is necessary, despite the nice comments....

@jklymak
Copy link
MemberAuthor

OK, I only used the bigger float64 if the amin-amax > 1e8.

@anntzer
Copy link
Contributor

I think(?) you probably care more about maxabs/minabs.

@jklymak
Copy link
MemberAuthor

Hmmm, not at all sure, because I once understood all the low-level reps of floats etc, but not so good at it anymore. Happy if someone wants to pick this up and do it better.

But, I think the error comes in when we do:

ifa_min!=a_max:
A_scaled/= ((a_max-a_min)/0.8)

and the resulting float doesn't preserve all the bits in theunit32.

@jklymakjklymak added this to thev2.1.2 milestoneDec 30, 2017
@tacaswell
Copy link
Member

This is a reasonable approach.

The scaling is to be able to track the over/under pixels and get around ringing in the interpolations.

@tacaswell
Copy link
Member

Discussed this on the phone call. Will investigate

  • delaying conversion to float as long as possible
  • avoiding float128 due to platform-dependence
  • add a test
jklymak reacted with thumbs up emoji

@jklymak
Copy link
MemberAuthor

Test added, and changes requested above made... Thanks!

Copy link
Contributor

@dopplershiftdopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Working and slow is better than broken and fast. Happy to merge a future PR that keeps things working and makes it faster.

@dopplershiftdopplershift merged commitb511bb2 intomatplotlib:masterJan 15, 2018
@jklymakjklymak deleted the fix-image-scaling branchJanuary 15, 2018 21:06
jklymak added a commit that referenced this pull requestJan 16, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

@dopplershiftdopplershiftdopplershift approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v2.1.2
Development

Successfully merging this pull request may close these issues.

imshow doesn't properly display some images
4 participants
@jklymak@anntzer@tacaswell@dopplershift

[8]ページ先頭

©2009-2025 Movatter.jp