Imtile resolution changes with figure height

31 visualizzazioni (ultimi 30 giorni)
Jason
Jason il 13 Nov 2025 alle 17:58
Commentato: Jason il 14 Nov 2025 alle 16:10
Hello, Im using imtile to create a montage from an array of images
out=imtile(IMarray,'GridSize',[r c]);
I display this on a fig via:
fig = uifigure('Name',['Montage ',char(tl)]);
fig.HandleVisibility='on';
fig.Position = [300 200 figW figH];
m = uimenu(fig,Label="My Save As");
m.MenuSelectedFcn = @app.mysavefunc;
app.figMontage=fig; % assign to public property so can be accessed
g = uigridlayout(fig);
%Create 3 x 2 Grid Layout
g.RowHeight = {'9x','1x','1x','1x'}; % g.RowHeight = {'6x','6x','1x','1x'};
g.ColumnWidth = {'1x','1x','1x','16x','0.8x'}; %g.ColumnWidth = {'1x','8x'};
%add UIAXES to 1st 2 rows, 1st 2columns
app.axMontage = uiaxes(g);
app.axMontage.Layout.Row = [1,2];
app.axMontage.Layout.Column = [1 5];
myImagesc(app,app.axMontage,out); axis(app.axMontage,'image'); drawnow;
So Ive noticed when y figure is 1500 x 600, the images look a lot better than when the figure is only 300 high - even though with the 300 height figure, the montage completely fits
  2 Commenti
DGM
DGM circa 23 ore fa
Modificato: DGM circa 21 ore fa
It might be worth noting that the default behavior for imtile() sets the tile size to the geometry of the first image. If your images vary in size and you don't want any of them downsampled in the operations internal to imtile(), then you need to explicitly set ThumbnailSize in the call to imtile().
It's not really obvious from the example if your images do vary, but I figured I'd throw that out there.
Like Matt said though, even if there isn't any downsampling happening in the output of imtile(), if the composite image size exceeds the displayed size, then it must be downsampled for display.
Depending on what tool you're using to display the composite image (imshow() vs image()/imagesc()), the display interpolation is likely nearest-neighbor. That tends to accentuate aliasing in images with small features and hard edges. While imshow() supports bilinear display interpolation, it's not the default. See imshow. It might help ease some of the appearance, but if the image is being downsampled for display, it doesn't change the fact that it's being downsampled.
Jason
Jason circa 17 ore fa
Thanks, see my reply to Matt.

Accedi per commentare.

Risposta accettata

Matt J
Matt J il 13 Nov 2025 alle 23:22
So Ive noticed when y figure is 1500 x 600, the images look a lot better than when the figure is only 300 high - even though with the 300 height figure, the montage completely fits
The montage will always fit, independently of the height of the figure. However, as the figure dimensions gets smaller, it forces the renderer to downsample your image to make it occupy fewer pixels, and that will of course degrade the appearance of the image.
  3 Commenti
Matt J
Matt J circa 13 ore fa
Modificato: Matt J circa 13 ore fa
You can do,
g.RowHeight = {400,'1x','1x','1x'};
though keep in mind that this sets the first row to 400 logical pixels, not hardware pixels. On Windows systems, a logical pixel is always 1/96 inches,
Maybe you should consider imresizing by a smaller factor, e.g., to 800x800 and using a different interpolation method as @DGM mentions. Then you don't have to worry so much about how visual quality depends on the figure size.

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by