-
Notifications
You must be signed in to change notification settings - Fork 616
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
How to render canvas with original pixel values? #2543
Comments
Your GPU uses 8-bit RGBA values and I don't think there is any way to change that. Additionally, the default That said, even if you get your data in the GPU as some floating point representation, the drawn pixels are still 8 or 10 bit integers. @rougier can correct me on this. I would guess that even if you could tell the If you're only using vispy to perform some type of interpolation on an image then I would recommend using a different library like scipy or scikit-image. Again, someone please correct me if I'm missing something here. |
Thank you for the explanation. My actual application scenario is more complicated, which is to put the Mesh and its corresponding color on the canvas and render them from different perspectives. This all works fine except the final output is changed to int8, which unfortunately, is a very serious problems for me. |
Not that I need to know every detail of your use case, but now I'm curious: let's say you could get the floating point colors back (normalized RGB/A in the range 0 to 1), what are you doing with them after that? |
Sure, I am glad to share the details if you have any idea of solving the problem. Actually, it is not color, it is more like pixel intensity range from 0.x ~ 7.x (float32). And its 'color' channel is 6, so now I just divide them into 2 to render it. The output is used as one of the input to train the neural network. |
What do you mean by this? You mentioned a mesh. So you're drawing a mesh with a texture or per-vertex "color"? What are you dividing into 2? I don't do any ML myself, but don't you need to give an integer version of your dataset anyway so it can easily classify things as one thing or another? |
Sorry for the divergency, 'color' channel doesn't matter, it is not important, it is just The thing is I would like to keep the pixel intensity unchanged after rendering from 0.x to 7.x . It is not about classification task, so value itself matters more. There is a similar application here mesh.py if you are interested. But they are using normal images, so it is not a big deal for them. |
It didn't work well because of the loss of precision or because you couldn't figure out how to scale the integers to get near the original values? I was wondering if as an extreme workaround you could encode the values into the 3 RGB channels, even if temporarily for the |
If there is no other possible solution, I think this hack may work. I just hope there is an official solution to render the image with higher precision. |
I think @rougier isn't available, but he'd probably know best. It mostly comes down to this utility function: Line 620 in c366456
Which uses the OpenGL function: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glReadPixels.xhtml But while this supports other types, I'm not sure that means anything for the precision. It is all just a representation of what's on the GPU...I think 🤷♂️ |
Thank you. Yes, unfortunately, It is precision doesn't change, it is just int8 scale back to float. |
Sorry, I was not available. I'm not sure to fully understand but I think your problem is related to the format of the framebuffer (i.e. the screen) that is using byte representation. It might be possible to have float framebuffer but it depends on your GPU and I'm quite sure this is not part of the GL ES 2.0 so not obvious solution. You could however create a offsscreen framebuffer and use this framebuffer to be copied on screen. |
I do not fully understand your solution, but I will search on that direction. Thank you. |
Here is a thread that might help: https://groups.google.com/g/vispy/c/QH33cVZAg8U |
For example, this is the code from Gallery.
Since my image is float64/float32, I want to keep the same pixel values unchanged after render. Instead of turning it into int8, is there any way to do it? Thanks.
The text was updated successfully, but these errors were encountered: