imagesc pixels unaligned with x axis for certain data sizes

39 views (last 30 days)
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 Comments
Charlie Black
Charlie Black on 13 Nov 2024 at 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 on 13 Nov 2024 at 2:30
This is grasping, but are you sure you don't have anything shadowing image() that might explain the slightly-off default XData?

Sign in to comment.

Answers (1)

Ashok
Ashok on 25 Nov 2024 at 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 Comments
Charlie Black
Charlie Black on 26 Nov 2024 at 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 on 27 Nov 2024 at 3:38
Happy to know that the issue has been resolved and thanks for sharing the fix.

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!