imagesc pixels unaligned with x axis for certain data sizes

40 visualizaciones (últimos 30 días)
Charlie Black
Charlie Black el 12 de Nov. de 2024 a las 13:53
Comentada: Ashok el 27 de Nov. de 2024 a las 3:38
Hello,
I am using imagesc to plot data (a 2D FFT). I found that when my data size is greater than 1024 indices, the pixel size does not match the x axis. Things look fine at a size of [3 1000] and [3 1024] but out of phase at [3 1025] and [3 1251]. This started after my workstation was updated to Win11. Prior to that, things worked fine no matter what the data size.
What could be causing this and does anyone know what a fix could be?
xleng = 1251;
figure
imagesc(rand([3 xleng]))
Below is an image with xlen set to 1000, showing the pixels in phase with the x axis
Below is an image with xlen set to 1251, showing the pixels out of phase with the x axis
Finally, here is a clip of my 2DFFT dataset, showing how the pixel bins are out of phase with size [360 1251]
  3 comentarios
Charlie Black
Charlie Black el 13 de Nov. de 2024 a las 1:35
Yeah, when I try this on other PCs at my workplace (Win 10 and newly Win 11 machines) it works fine, and I get the result you showed. This is somehow unique to my install/machine.
FWIW, I get this when I run
xleng = 1251;
figure
imagesc(rand([3 xleng]))
xlim([1245 xleng])
DGM
DGM el 13 de Nov. de 2024 a las 2:30
This is grasping, but are you sure you don't have anything shadowing image() that might explain the slightly-off default XData?

Iniciar sesión para comentar.

Respuestas (1)

Ashok
Ashok el 25 de Nov. de 2024 a las 6:20
I could replicate the issue in R2021a but not in R2021b. Just a heads up, my current system runs Windows 11 and doesn't support hardware OpenGL.
Running the opengl info command right after opening MATLAB gave these outputs:
R2021a:
R2021b:
As seen in the above images, the HardwareSupportLevelis sometimes set to 'full' in R2021a even though the system doesn't support hardware OpenGL, leading to a similar issue.
Switching to software rendering by runningthe following command in the MATLAB command window seems to fix the rendering issue.
opengl software
Alternatively, one can start MATLAB with software OpenGL selected by runningmatlab -softwareopengl in the windows command line. To save software OpenGL for future sessions, use the following command in the MATLAB command window.
opengl('save', 'software')
For more information on low-level graphics issues, check out this documentation page: 
  2 comentarios
Charlie Black
Charlie Black el 26 de Nov. de 2024 a las 21:25
Thanks for digging into this! Very helpful. I will say, the issue seems to have resolved itself after I reinstalled GPU drivers. FWIW, here is my output for opengl info.
Version: '4.6.0 Compatibility Profile Context 22.20.20.06.231106'
Vendor: 'ATI Technologies Inc.'
Renderer: 'AMD Radeon RX 640'
RendererDriverVersion: '31.0.12020.6006'
RendererDriverReleaseDate: '06-Nov-2023'
MaxTextureSize: 16384
Visual: 'Visual 0x1a, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 8 samples)'
Software: 'false'
HardwareSupportLevel: 'full'
SupportsGraphicsSmoothing: 1
SupportsDepthPeelTransparency: 1
SupportsAlignVertexCenters: 1
Extensions: {246×1 cell}
MaxFrameBufferSize: 16384
Even with HardwareSupportLevel as Full, it still seems to work now. I am not sure what the root cause was initially, but if I ever run into problems again, I will try switching to software rendering. Interesting that 2021a will default to that even though it does not support it.
Ashok
Ashok el 27 de Nov. de 2024 a las 3:38
Happy to know that the issue has been resolved and thanks for sharing the fix.

Iniciar sesión para comentar.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by