Borrar filtros
Borrar filtros

Setting the position of an image in a figure

39 visualizaciones (últimos 30 días)
Navdeep Sony
Navdeep Sony el 28 de En. de 2016
Comentada: Navdeep Sony el 29 de En. de 2016
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.

Respuesta aceptada

Image Analyst
Image Analyst el 28 de En. de 2016
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 comentarios
Image Analyst
Image Analyst el 28 de En. de 2016
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.
Navdeep Sony
Navdeep Sony el 29 de En. de 2016
Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by