Setting the position of an image in a figure
27 次查看(过去 30 天)
显示 更早的评论
I have three images in the figure as shown below.
1. I want to display these three images at the center of the figure. How can I do it?
2. I want that automatically the value of mean for each figure is picked from the variable and displayed under each image. How can I do it?
Please explain. Thank you.
0 个评论
采纳的回答
Image Analyst
2016-1-28
Use subplot(), mean2(), and xlabel():
fontSize = 20;
% Make 3 images.
grayImage1 = imread('cameraman.tif');
grayImage2 = imread('moon.tif');
grayImage3 = imread('pout.tif');
% Display image 1 and mean of that image.
subplot(1, 3, 1);
imshow(grayImage1, []);
title('cameraman.tif', 'FontSize', fontSize, 'Interpreter', 'None');
mean1 = mean2(grayImage1);
caption = sprintf('Mean = %.2f', mean1);
xlabel(caption, 'FontSize', fontSize);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Display image 2 and mean of that image.
subplot(1, 3, 2);
imshow(grayImage2, []);
title('moon.tif', 'FontSize', fontSize, 'Interpreter', 'None');
theMean = mean2(grayImage2);
caption = sprintf('Mean = %.2f', theMean);
xlabel(caption, 'FontSize', fontSize);
% Display image 3 and mean of that image.
subplot(1, 3, 3);
imshow(grayImage3, []);
title('pout.tif', 'FontSize', fontSize, 'Interpreter', 'None');
mean3 = mean2(grayImage3);
caption = sprintf('Mean = %.2f', mean3);
xlabel(caption, 'FontSize', fontSize);
3 个评论
Image Analyst
2016-1-28
Right, because subimage() puts stitched images in one axes. To put labels on that, you'd have to use the text() function to put a test string into the overlay of the image.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!