imshow displays blank figure
14 views (last 30 days)
Show older comments
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
Walter Roberson
on 5 Apr 2023
Moved: VBBV
on 11 Apr 2023
imshow has supported string() since about r2017b
Accepted Answer
More Answers (2)
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
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.
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.
See Also
Categories
Find more on Red in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

