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

Viewer refuses to display images which have too large of an aspect ratio #3430

Closed
jleibs opened this issue Sep 24, 2023 · 0 comments · Fixed by #3520
Closed

Viewer refuses to display images which have too large of an aspect ratio #3430

jleibs opened this issue Sep 24, 2023 · 0 comments · Fixed by #3520
Assignees
Labels
🪳 bug Something isn't working 🔺 re_renderer affects re_renderer itself 📺 re_viewer affects re_viewer itself

Comments

@jleibs
Copy link
Member

jleibs commented Sep 24, 2023

Describe the bug
When logging an image with an extremely high aspect ratio. For example:

rr.experimental.log("image", rr.archetypes.Image(np.ones(shape=(4000, 2, 1))))

We just get an error: Condition failed: 'resolution_in_pixel[0] > 0 && resolution_in_pixel[1] > 0'

To Reproduce
Steps to reproduce the behavior:

rr.experimental.log("image", rr.archetypes.Image(np.ones(shape=(4000, 2, 1))))

Expected behavior
Image should be displayed.

Screenshots
image

Desktop (please complete the following information):

  • OS:

Rerun version
Presumably all versions.

@jleibs jleibs added 🪳 bug Something isn't working 📺 re_viewer affects re_viewer itself labels Sep 24, 2023
jleibs added a commit that referenced this issue Sep 25, 2023
### What
* Part of: #3283

Now that we log IndicatorComponents, removes the check which disables
images on tensors that look like vectors.

This works for small pixel values:
```
import numpy as np
import rerun as rr

rr.init("pixtest", spawn=True)

rr.experimental.log("/", rr.archetypes.AnnotationContext([(1, "red", (255, 0, 0))]))
rr.experimental.log("image", rr.archetypes.SegmentationImage(np.ones(shape=(20, 1, 1)).astype(np.uint8)))
```

![image](https://github.com/rerun-io/rerun/assets/3312232/1501a154-475f-4aea-bd70-faa56bb17ebf)

However, this uncovers a new bug with ultra-wide-aspect images.

If we instead use
```
rr.experimental.log("image", rr.archetypes.SegmentationImage(np.ones(shape=(4000, 1, 1)).astype(np.uint8)))
```
The viewer fails a resolution check. Presumably because we round down to
< 1 pixel width.

![image](https://github.com/rerun-io/rerun/assets/3312232/b0aa5ee7-0636-40f3-ba18-9037bfd29847)

* Filed as: #3430

### 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 [demo.rerun.io](https://demo.rerun.io/pr/3429) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3429)
- [Docs
preview](https://rerun.io/preview/8bf3061e6d9be015ac8c11eb289d04d35acc27ed/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/8bf3061e6d9be015ac8c11eb289d04d35acc27ed/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
@emilk emilk added the 🔺 re_renderer affects re_renderer itself label Sep 25, 2023
@Wumpf Wumpf self-assigned this Sep 28, 2023
Wumpf added a commit that referenced this issue Sep 29, 2023
### What

* Fixes #3430

Changed the way we deal with image previews. They now occupy always the
requested size (previously, they'd expand to a max size) and the image
displayed within may be stretched in rare situations.
Fixed-sized-ness of the preview image is an improvement in thus far as I
think as it makes ui layouting a bit easier and more predictable, but I
had to add a flag to not do so on hovering the preview since we would
have a lot of empty space there otherwise.

Test code:
```python
import rerun as rr
import numpy as np

rr.init("sliver image", spawn=True)

slow_gradient = np.arange(0, 1.0, 1.0 / 1000, dtype=float)
rr.log("image", rr.Image([slow_gradient]))

slow_gradient_rot = slow_gradient.reshape((slow_gradient.shape[0], 1))
rr.log("image2", rr.Image(slow_gradient_rot))
```

-------------


Before with hovering the preview:
horizontal:
<img width="430" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/d8a3a026-3da3-4fb7-a3a7-d041173a3460">
vertical:
<img width="416" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/c47815c6-bd81-43cb-a0a7-33fae3156478">
car:
<img width="480" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/e5dc98e1-e2c1-4d7d-89b7-ec3c8150b0a9">

-------------

After with hovering the preview:
horizontal:
<img width="440" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/a091b943-d5d1-4af6-ac5a-a62a79713e52">
vertical:
<img width="433" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/1701b0d6-ceda-4b99-9727-b6e077121455">
car:
<img width="424" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/b67dbeea-23c9-46f2-a793-de5880c7f0d9">


-------------


I originally also wanted to tackle increasing the default zoom in the
viewport. Had some initial success but found getting the zoom state
correctly set in all situations too fiddely, so gave up on this for now.
This aspect will be need to be re-visited anyways when we drop the
scroll bars as long planned.

### 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 [demo.rerun.io](https://demo.rerun.io/pr/3520) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3520)
- [Docs
preview](https://rerun.io/preview/cd19bd3a7a86d1f01aa1359645777770e5c62ece/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/cd19bd3a7a86d1f01aa1359645777770e5c62ece/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something isn't working 🔺 re_renderer affects re_renderer itself 📺 re_viewer affects re_viewer itself
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants