Poor imshow image quality

5 次查看(过去 30 天)
Conrado Neto
Conrado Neto 2020-9-15
回答: DGM 2024-6-3
Hi I am trying to get a figure into a plot using imshow nd the results I get are really poor quality
this is the original figure:
this is what I get:
Increasing the size of the figure, does make the quality slightly better but it is still not any close to the original
the code I ued is:
imshow('Truss.png','border','tight','InitialMagnification',200)
I used border tight, and initial magnification but they dont seem to change anything all, with respect the size and quality
any help is appreciated
thanks
  2 个评论
Ameer Hamza
Ameer Hamza 2020-9-15
The image is drawn over a TiledChartLayout object. This is not the default behavior. There must be some other lines of code before imshow() lines, which are modifying the figure window.
Madhav Thakker
Madhav Thakker 2020-9-23
Hi, can you provide the code before imshow() to get a better idea of what's going on?

请先登录,再进行评论。

回答(1 个)

DGM
DGM 2024-6-3
The image is being drawn into a TiledLayout with the default wide padding and tile spacing. A ton of space is being wasted.
While imshow() normally wastes a ton of space by using the its default loose axes placement, that option is overridden by the placement within the tiledlayout.
The image looks terrible because it's a high-contrast image that's necessarily being downsampled for display in a tiny portion of a particularly-sized window. By default, imshow() uses nearest-neighbor interpolation when scaling images to fit, but this can be changed to bilinear with the 'interpolation' option. The result will still be undersized and slightly blurry, but you can't make an image smaller without losing information.
Your options:
  • Use a larger figure window
  • Don't try to cram so many axes in one figure that you run out of room (do you need more than one?)
  • Be smart about how you arrange your axes (tiling wide images horizontally seems like the worst option)
  • Be smart about how your figure geometry suits the combined effects of the tiling and image aspect ratios
  • Use the available padding/spacing options to make a tighter tiledlayout()
  • Consider using different display interpolation if necessary

Community Treasure Hunt

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

Start Hunting!

Translated by