Differences between imshow() and image() ?

Hi everyone,
As long as I know, there are two ways of displaying an image on matlab.
One way is by using imshow
imshow('image.png')
And the other one is by using imread() and image()
d=imread('image.png')
image(d)
What are the main differences and pro/cons between them? I do not see much difference but I can not tell.
The only differences I have noticed is that when I use imread() and then image(), the image (or images theirselves if I have putted overlaped) appear upside down
Thanks very much.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Jul. de 2021

0 votos

  • imshow() detects whether the image is RGB or not. If it is not, then it detects the datatype and uses that to load a colormap (e.g., gray(2) for binary images)
  • if the current axes is in its default position that it would get if it were the only axes, then imshow deletes the axes and creates a new one and resizes the figure to be just big enough for the image. I repeat, deletes the axes, not changes properties of the axes. You will lose all customizations you have done on the axes
  • imshow() adds some tools to the window
  • imshow() does not permit Alpha to be configured in the imshow() call: you need to record the handle and set the alpha properties for it
  • image() does not resize the axes -- so if you have a small image in a larger axes, the image will end up magnified
  • image() does not set any particular colormap -- so you get whatever colormap was in effect, which is often parula()
  • image() when Hold is not on, will reset some axes properties, but will not delete the axes
  • image() does not add tools to the window, and so is better suited for cases where the image is being used for text or logos or any carefully constructed user interface
  • image() permits you to configure AlphaData during the image() call

4 comentarios

ErikJon Pérez Mardaras
ErikJon Pérez Mardaras el 19 de Jul. de 2021
Editada: ErikJon Pérez Mardaras el 19 de Jul. de 2021
Thanks a lot for your reply.
That reply has led me to another related question:
What are the main differences between those and poping up an image with uifgiure?
I guess that with uifigure I can include more elements inside the window such as buttons, other windows, other images, and so on.
Am I right? There is more?
Thanks
Walter Roberson
Walter Roberson el 19 de Jul. de 2021
uifigure() is very similar to figure() but with a different implementation technology. It does not display any graphics by itself: it only creates a window that you can use to draw inside.
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras el 19 de Jul. de 2021
Thanks
xingxingcui
xingxingcui el 29 de Jul. de 2025
I add a point for compare:
imshow is a high-level function with relatively large overhead and is generally not used inside loops, whereas image is a low-level function with better performance.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Display Image en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by