필터 지우기
필터 지우기

how do I show the images name on top of each picture

조회 수: 4 (최근 30일)
new_user
new_user 2021년 11월 25일
댓글: Image Analyst 2021년 11월 25일

채택된 답변

Yongjian Feng
Yongjian Feng 2021년 11월 25일
편집: Yongjian Feng 2021년 11월 25일
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일
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.

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by