Skip to content

Refactor ImageItem QImage creation routines#2944

Merged
j9ac9k merged 2 commits intopyqtgraph:masterfrom
pijyoi:refactor-imageitem
Mar 7, 2024
Merged

Refactor ImageItem QImage creation routines#2944
j9ac9k merged 2 commits intopyqtgraph:masterfrom
pijyoi:refactor-imageitem

Conversation

@pijyoi
Copy link
Copy Markdown
Contributor

@pijyoi pijyoi commented Feb 25, 2024

The fast-path QImage creation methods residing within ImageItem can be factored out to be free-standing functions.
This has the following benefits:

  1. Makes the routine stateless, which ensures that it has no side-effects from other methods.
  2. Allows the functionality to be used outside of ImageItem

Some behavior changes:

  1. replaces the use of nextafter with the snippet in Fix UnderflowError in _try_rescale_float when maxVal == 0. #2881 (comment)
  2. doesn't cache the effective lut.
    • Caching the effective lut makes the code stateful.
    • The effective lut computation is relatively small. While the overhead of recomputing the effective lut may be significant for very small images, displaying such small images should be fast enough already.
      • The largest computation that this caching would have saved is for the case "uint16 image and lut with more than 256 entries". This results in an effective lut size of 128KB. However, since luts are usually created with 256 entries, this case would be seldom encountered.
  3. the test of ImageFormat no longer needs to instantiate an ImageItem object for each test. This could be problematic if the CI was flakey to begin with.

@pijyoi pijyoi force-pushed the refactor-imageitem branch from 5e19269 to bf8964c Compare February 25, 2024 11:48
@pijyoi pijyoi force-pushed the refactor-imageitem branch from 67b9690 to 608822a Compare February 25, 2024 15:42
@pijyoi pijyoi force-pushed the refactor-imageitem branch from 608822a to ad7b4e6 Compare February 28, 2024 12:40
@pijyoi pijyoi marked this pull request as ready for review February 28, 2024 12:59
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Mar 7, 2024

Thanks @pijyoi for this PR. ImageItem was getting complicated and there was some good stuff there so I'm a very big 👍🏻 for moving that functionality into free-standing functions.

@j9ac9k j9ac9k merged commit 2c1e97e into pyqtgraph:master Mar 7, 2024
@pijyoi pijyoi deleted the refactor-imageitem branch March 7, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants