imshow() poor image quality

36 visualizaciones (últimos 30 días)
HpW
HpW el 20 de Oct. de 2022
Editada: DGM el 20 de Oct. de 2022
Hello
I have a GUI which is being used to display images. I have images in PNG format with resolution 3301x2550.
I have a simple GUI with 1 axes (axes1) and i am loading the images as follows:
myImage = imread(filename);
axes(handles.axes1);
imshow(myImage);
axis image;
When this loads in the GUI, however, the image quality is not good - here is an example. On the left is the image in the GUI, and on the right is the image loaded normally in windows at a similar magnitification - Note how the left image quality is significantly degraded
Is there a way I can get a better quality image in the GUI?
thanks!

Respuesta aceptada

DGM
DGM el 20 de Oct. de 2022
Editada: DGM el 20 de Oct. de 2022
Two things:
First, by default, imshow() uses nearest-neighbor interpolation for display. Things with fine features will be subject to this sort of aliasing.
% generate a grid of 1px wide lines
w = 301;
x = mod(1:w,10) == 1;
A = x | x';
% show the image
imshow(A)
In recent versions, you can specify a continuous display interpolant. While this may help for some images, images with regular patterns may still show some less-severe interference patterns.
% show the image with non-default display interpolation
imshow(A,'interpolation','bilinear')
Second, one has to ask why it's important that imshow() produces high-quality and accurate image displays. It's typically used for viewing.
Cases where it might be justified:
  • Overlaying objects from plot(), contour(), patch() atop the image and then saving the figure/axes
Cases where people want to but really shouldn't:
  • Displaying the image and then saving the figure/axes in order to save a copy of the image (use imwrite())
  • Combining one or more images in the same figure and then saving the composite image (just composite them directly)
In cases where it's necessary to save the figure with a displayed image, tools like export_fig() (File Exchange) support antialiasing options which may help reduce the impact of any display limitations.

Más respuestas (0)

Categorías

Más información sobre Display Image en Help Center y File Exchange.

Etiquetas

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