採用された回答

Yongjian Feng
Yongjian Feng 2021 年 11 月 25 日
編集済み: Yongjian Feng 2021 年 11 月 25 日

0 投票

Add a title to each subplot, after you call subplot:
title('Horse')

2 件のコメント

new_user
new_user 2021 年 11 月 25 日
subplot(2,2,3), title ('Bicycle');
imshow(readimage(imds,tricycle));
like this?
Yongjian Feng
Yongjian Feng 2021 年 11 月 25 日
Yeah, instead of ',', use ';'.
subplot(2,2,3);
title ('Bicycle');
imshow(readimage(imds,tricycle));

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 11 月 25 日

0 投票

Another option, other than title(), is to put the filename in text in the overlay
rgbImage = imread(filename);
imshow(rgbImage);
text(10, 10, filename, 'Color', 'r', 'FontSize', 20, 'VerticalAlignment', 'top');

2 件のコメント

new_user
new_user 2021 年 11 月 25 日
figure
subplot(2,2,1)
imshow(readimage(imds,horse));
how to edit this line to add yours??
Image Analyst
Image Analyst 2021 年 11 月 25 日
I'm sure you figured it out by now, but it would go something like this:
fontSize = 20;
folder = pwd;
imds = imageDatastore(folder, "FileExtensions",[".jpg",".tif"])
numImages = length(imds.Files)
plotRows = ceil(sqrt(numImages))
for k = 1 : numImages
thisFile = imds.Files{k}
[f, baseFileName, ext] = fileparts(thisFile);
thisImage = imread(thisFile);
subplot(plotRows, plotRows, k);
imshow(thisImage);
title(baseFileName, 'FontSize', fontSize);
text(10, 10, baseFileName, 'Color', 'r', ...
'BackgroundColor', 'y', 'FontSize', fontSize, 'VerticalAlignment', 'top')
end
g = gcf;
g.WindowState = 'maximized'
I show the name both as a title and in the overlay.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

質問済み:

2021 年 11 月 25 日

コメント済み:

2021 年 11 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by