Skip to content
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

Floating-point image data range seems to be assumed to be at least 0-255. #4624

Open
kpreid opened this issue Dec 29, 2023 · 3 comments
Open
Labels
🪵 Log & send APIs Affects the user-facing API for all languages ui concerns graphical user interface

Comments

@kpreid
Copy link
Collaborator

kpreid commented Dec 29, 2023

Describe the bug
When an archetypes::Image is logged, if the pixel values do not reach at least 255.0, then none of them will be displayed with full brightness in the viewer. It seems that there is an auto-ranging/auto-exposure feature (logging very large values causes the rest of the image to darken) but it never uses a maximum less than 255.0.

This is contrary to typical usage (in my personal experience in computer graphics and GIS) of floating-point pixel formats, where if there is an assumed 100% brightness value, then that value is 1.0.

To Reproduce
Steps to reproduce the behavior:

  1. Log an archetypes::Image whose data contains a datatypes::TensorBuffer::F16 with values in the 0.0 - 1.0 range.
  2. Observe that in the viewer it appears black, yet the pixel data is displayed on hover.
  3. Try again with a larger range such as 0.0 - 100.0.
  4. Observe that in the viewer the image appears dim.

Expected behavior
The auto-ranging should select a range that either matches the data, or has an assumed maximum of 1.0.

I'm not sure what would be best to do with the alpha component — which should generally not be auto-scaled since "opaque" is semantically different from "all X% transparent". I haven't investigated Rerun's current behavior with it.

Screenshots
image

Desktop (please complete the following information):

  • OS: macOS Sonoma 14.2.1 (23C71)

Rerun version
rerun-cli 0.11.0 [rustc 1.75.0 (82e1608df 2023-12-21), LLVM 17.0.6] x86_64-apple-darwin

@kpreid kpreid added 👀 needs triage This issue needs to be triaged by the Rerun team 🪳 bug Something isn't working labels Dec 29, 2023
@emilk
Copy link
Member

emilk commented Dec 30, 2023

The heuristics here might need tweaking, and should probably be done in conjunction with actually exposing the image range in the UI, i.e.:

The reason for the current default is that it is also quite common to load an image and then convert it to float (perhaps as a side-effect of something else). It would then be weird if Rerun showed the same image differently just because you converted bytes to floats. For instance:

  img = cv2.cvtColor(cv2.imread("img.png", cv2.IMREAD_UNCHANGED), cv2.COLOR_BGRA2RGB)

  rr.log("img_1", rr.Image(img))
  rr.log("img_2", rr.Image(img.astype("float32")))
  rr.log("img_3", rr.Image(1.0 * img)
  rr.log("img_4", rr.Image(0.5 * img)

It's reasonable to expect the first three images to have the same appearance in Rerun. It it is also quite reasonable to expect the last two images to have a different apprearance (img_4 being darker than img_3).

@kpreid
Copy link
Collaborator Author

kpreid commented Dec 30, 2023

The reason for the current default is that it is also quite common to load an image and then convert it to float (perhaps as a side-effect of something else). …

That makes sense.

The heuristics here might need tweaking, and should probably be done in conjunction with actually exposing the image range in the UI, i.e.:

Several thoughts:

  • But any heuristic is sometimes wrong, so will there be a way to specify a recommended range when logging?

  • In the case I was experimenting with, the data in question is natively HDR, so the optimal data display is not necessarily scaling to fit the entire min-max range, but might clip some extremes. That might be reasonably handled solely by interactive adjustment, though.

  • Once there are range controls in the viewer, it could detect when an image is displaying very-low-contrast values of any kind and display a “data may be illegible, change scale?” prompt somewhere. Actually, that might be a nice feature to apply to many domains: consider “all your 3D data is currently off this side of the viewport →".

@emilk
Copy link
Member

emilk commented Dec 31, 2023

will there be a way to specify a recommended range when logging?

There will! This is part of our Blueprint work, where ultimately everything that can be specified in the GUI can also be specified at log time.

@emilk emilk added ui concerns graphical user interface 🪵 Log & send APIs Affects the user-facing API for all languages and removed 🪳 bug Something isn't working 👀 needs triage This issue needs to be triaged by the Rerun team labels Jan 9, 2024
Wumpf added a commit that referenced this issue Oct 1, 2024
…de) (#7549)

### What

* Fixes #6106
* Fixes #2341
* NOT included here is image ranges, this PR is only about things
affecting colormaps (#4624)

Depth images (and their clouds):


https://github.com/user-attachments/assets/949ffb14-38e9-452d-a84f-695104f146c8

Tensors:


https://github.com/user-attachments/assets/eea3b38f-e4c7-4b97-9cc3-2fc6104ed6b7


Noteworth ripple effects & considerations in this PR:
* turns out depth image constructor on Python missed a lot of
parameters, fixed that
* went with a new `ValueRange` component rather than reusing `Range1D`
because the semantics (and names in the ui) of the later were just too
unclear
   * we need a tagged component mechanism really badly!
* decided against putting this on the tensor view as some notes
indicated was the plan
* ended up refactoring a few interesting things around image/tensor
handling:
* colormap is no longer part of `ImageInfo`, we already didn't use it
for hashing it. Having now a range made it even more clear that this
doesn't belong there
* `finite_range` on tensor & image is now always present, using the
datatypes' finite range as fallback. The `None` case handling was
awkward at best and non-existant (error out) usually

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7549?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7549?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7549)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪵 Log & send APIs Affects the user-facing API for all languages ui concerns graphical user interface
Projects
None yet
Development

No branches or pull requests

2 participants