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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for rendering canvas-visuals to an RGB image #6334
Comments
Thank you for the feedback! I've looked at #6114 and can see the overlap. My bad for not looking more thouroughly before... I think that resizing the canvas and reseting the camera would be more straight forward than cropping the black canvas. The approach above has worked pretty well for me so far (however maybe there are special cases which im not considering) I guess since the deprecation was postponed its not very urgent however would still be great to have a feature like this. I agree that having a size-argument would make sense, how about making this an optional argument and by-default export at the datas "native" resolution. Would there be interested in a pull request that implements something like this (e.g a new method to the window class next to screenshot i.e. to_rgb or something like this) ? I could give it a try. Or is there already somebody working on a feature like this or a more sophisticated version? (I saw something mentioned here https://forum.image.sc/t/saving-image-from-napari/50379/30) |
what did you mean by native resolution for 3d rendering? For 2d it is clear but not for 3d. |
hmm so the way it is set up above it would reset the camera angle to the default state i.e (0, 0, 90). so "native" in this case would probably mean yx extent, but yes it is much less clear for the 3d case |
Such an API is hugely desired from many sides. It would be nice being able to use the API headless, without launching the Napari GUI, and if possible avoid depending on Qt (just render the image as array). This discussion has some overlap with Also, such an API should keep in mind the link between data and the rendering process. Some data formats store visualization parameter presets. Developers read these presets and pass them to a visualization API (like this). It would be good to coordinate naming of rendering parameters between data formats and implementors of visualization tools. As example, NGFF-Zarr stores OMERO rendering parameters, which resemble quite a lot Napari's |
This issue has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/retrieving-burned-displayed-image-data-in-napari/92149/2 |
馃殌 Feature
Implement a method to render the canvas as an RGB image directly.
Motivation
There are often cases where I would want to export the canvas as an RGB image at its native resolution. The current screenshot option in napari is useful, but it requires the user to manually adjust the canvas or crop the images afterwards, which can be cumbersome and often not very fast. It is also not easily possible (and in some cases impossible) to export the canvas-visuals at their native resolution. By using the viewer.window.resize method this can be mitigated a bit, however this is constrained by minimal and maximal viewer size, which is related to scaling and dock-widgets and so on.
Pitch
I would like to propose the implementation of a method or an additional argument to the screenshot method, to directly render the canvas as an RGB image at the datas native resolution. I have experimented with some options all of which would require access to the canvas attribute, so implementing it as a plugin is not possible since the access to this will be removed in 0.5.0.
The simplest way I found to do this was to resize the canvas, then calling the canvas.render(), or viewer.window.screenshot(canvas_only=True) method and save the image as an RGB.
Of course this is a failrly naive implementation and one would have to think about how to handle 3d data, very large images, overlays and so on. But I think it could be extremely useful to have a feature like this (in any form what so ever).
Alternatives
The text was updated successfully, but these errors were encountered: