imshow displays blank figure

14 views (last 30 days)
rose
rose on 5 Apr 2023
Edited: Image Analyst on 12 Apr 2023
img = imread("image.png");
imshow(img);
When I run this simple script I get just a blank figure, with no errors.
  • The image exists(95,2 kB) and the path is correct
  • Ubuntu 20.04.6 LTS and MatLab 2023a
  • Graphics/Drivers:
VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
Kernel driver in use: i915
--
3D controller: NVIDIA Corporation GM108M [GeForce 940MX] (rev a2)
Kernel driver in use: nouveau
I tried with different images as well.
What could cause the blank figure?
  3 Comments
VBBV
VBBV on 5 Apr 2023
Moved: VBBV on 11 Apr 2023
Check whether figure windows are showing outputs correctly. If you still get the same problem,then it is something todo with VGA
Walter Roberson
Walter Roberson on 5 Apr 2023
Moved: VBBV on 11 Apr 2023
imshow has supported string() since about r2017b

Sign in to comment.

Accepted Answer

rose
rose on 5 Apr 2023
Ok solved. I just had to start matlab like that
$ matlab -softwareopengl
  1 Comment
DGM
DGM on 6 Apr 2023
You can accept your own answer so that it may better help the next person.

Sign in to comment.

More Answers (2)

Image Analyst
Image Analyst on 5 Apr 2023
Try with a built-in demo image:
img = imread("peppers.png");
imshow(img);
Do you still get a white axes?
  2 Comments
Image Analyst
Image Analyst on 12 Apr 2023
Edited: Image Analyst on 12 Apr 2023
@rose if you're absolutely 100% sure that you copied or typed those two lines character for character and you still got a white image, then you need to call tech support because those two lines definitely should not give a white image. Something is not installed correctly.

Sign in to comment.


DGM
DGM on 5 Apr 2023
Edited: DGM on 5 Apr 2023
Without knowing what the image is or how exactly the figure appears, I'm going to go out on a limb and guess that it's possibly an indexed image with a short color table. If so, then you need to read the colormap and use it accordingly.
inpict = imread('t4.png'); % read only the index array
imshow(inpict) % display the indices as if they were gray levels
[inpict map] = imread('t4.png'); % read the index array and colormap
imshow(inpict,map) % use the map to display the image
If this is the case, then depending on what you intend to do with the image, you'll either have to carry around the map to use with it, or you'll have to convert it to rgb using ind2rgb().
If the image is not an indexed image (i.e. if the map returned by imread() is empty), then it would be useful to know if the builtin images work. If they do, it would be helpful to have an example of the images which don't work.
  1 Comment
rose
rose on 5 Apr 2023
Edited: rose on 5 Apr 2023
I tried it but does't work either.
Ok after restarting I got these errors:
1) Startup:
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x59480b0, isOwner false, <5c366b5f, 6e1892b4>[count 0, qsz 0, owner <NULL>]]]
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
... 2 more
2) Runtime error (I only got it on the first run. For the rest I just get blank figures, with no error messages)
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.
How is that possible with the graphics I have?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!