imshow() poor image quality

조회 수: 29 (최근 30일)
HpW
HpW 2022년 10월 20일
편집: DGM 2022년 10월 20일
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!

채택된 답변

DGM
DGM 2022년 10월 20일
편집: DGM 2022년 10월 20일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Display Image에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by