How to show title and xlabel on the bottom of every image?

4 visualizaciones (últimos 30 días)
Lolipop
Lolipop el 31 de Dic. de 2014
Editada: Chad Greene el 4 de Dic. de 2018
Hi
I'm trying to show images with subplot in uipanel with their name and ordinal number at the bottom of the images and I am using this code:
[I,cmap] = imread('bone-17.gif');
for j=1:4
ax=subplot(2,2,j);
image(I);
colormap(ax,cmap);
axis off;
axis image;
title(img.name(j));
xlabel(ordinal_number,'FontSize',7);
end
but this displays only the title and on the top of images and xlabel isn't showen at all how can I display title and xlabel on the bottom of every image? Or is it possible with one function to do that,something like this in for loop
title(img.name(j),ordinal_number)
Thank you

Respuestas (3)

Chad Greene
Chad Greene el 31 de Dic. de 2014
Editada: Chad Greene el 31 de Dic. de 2014
Try using text. Alternatively, there's the slightly more user-friendly ntitle available on File Exchange, but ntitle only places title inside axes. Here we do both:
I = imread('coins.png');
for k=1:4
ax=subplot(2,2,k);
imagesc(I);
colormap bone
axis off;
axis image;
switch k
case {1,2}
ntitle(['title ',num2str(k)],...
'location','north',...
'backgroundcolor','w');
ntitle(['xlabel ',num2str(k)],...
'location','south',...
'FontSize',7,...
'backgroundcolor','y');
otherwise
text(.5,1,['title ',num2str(k)],...
'horiz','center',...
'vert','bottom',...
'units','normalized')
text(.5,0,['xlabel ',num2str(k)],...
'horiz','center',...
'vert','top',...
'FontSize',7,...
'units','normalized')
end
end
  3 comentarios
Lolipop
Lolipop el 31 de Dic. de 2014
I downloded function ntitle and when I try to run program it has some error
Undefined function 'ntitle' for input arguments of type 'char'.
What should I type in ntitle instead of ...
Chad Greene
Chad Greene el 2 de En. de 2015
Did ntitle get left in your downloads folder, or somewhere Matlab can't find it?

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 1 de En. de 2015
I believe it's because you turned the axis off that the labels don't show up. Why not leave them on and just set all your tick mark labels to null?
  3 comentarios
Image Analyst
Image Analyst el 1 de En. de 2015
Editada: Image Analyst el 1 de En. de 2015
Doesn't this do what you want:
filename = 'kids.tif';
[indexedImage,cmap] = imread(filename);
for k = 1 : 4
ax=subplot(2,2,k);
imshow(indexedImage);
colormap(ax,cmap);
title(filename, 'FontSize', titleFontSize);
% axis off;
axis image;
ordinal_number = sprintf('Image #%d', k);
xlabel(ordinal_number, 'FontSize', axisFontSize);
ylabel('y-axis', 'FontSize', axisFontSize);
end
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
Lolipop
Lolipop el 2 de En. de 2015
Editada: Lolipop el 2 de En. de 2015
Well yes it would work but from some reason my gif images which are black and white won't show..well some of them are showen but some of them are just showen as black picture and with
image
can be showen all
And my question was how to display title and xlabel on the bottom of every image,problem is when pictures are different sizes and sometimes title and xlabel are being hidden because picture is too big

Iniciar sesión para comentar.


Shahid Ameer
Shahid Ameer el 2 de Dic. de 2018
Editada: Chad Greene el 4 de Dic. de 2018
clc;
clear all;
close all;
[I,path]=uigetfile('*.jpg','select a input image');
str=strcat(path,I);
s=imread(str);
num_iter = 10;
delta_t = 1/7;
kappa = 15;
option = 2;
disp('Preprocessing image please wait . . .');
ad = anisodiff(s,num_iter,delta_t,kappa,option);
figure, subplot 121, imshow(s,[]),title('Input image'), subplot 122, imshow(ad,[]),title('After Noise Removal'),l1=30;l2=37;l3=40;l4=42;q1=53;q2=39;q3=36;q4=40;z1=26;z2=16;z3=53;z4=60;
fprintf('\nPress any key \n');
pause;
disp('classifying tumor boundary');
m = zeros(size(ad,1),size(ad,2)); %-- create initial mask
m(90:100,110:135) = 1; % main 2
ad = imresize(ad,.5); %-- make image smaller
m = imresize(m,.5); % for fast computation
figure
subplot(2,2,1); imshow(ad,[]); title('Input Image');
% bounding box start
%hold on
if(strcmp(I,'a1.jpg')||strcmp(I,'a.jpg'))
for aa=1:10
subplot(2,2,2); imshow(ad,[]);title('Locating Bounding box');
rectangle('Position',[l1 l2 l3 l4],'EdgeColor','y'); %a1
pause(0.5);
l1=l1+1;l2=l2+1;l3=l3-2;l4=l4-2;
end;
% rectangle('Position',[40 47 20 22],'EdgeColor','y'); %a1
end;
if(strcmp(I,'b1.jpg')||strcmp(I,'b.jpg'))
for aa=1:10
subplot(2,2,2); imshow(ad,[]);title('Locating Bounding box');
rectangle('Position',[q1 q2 q3 q4],'EdgeColor','y'); %a1
pause(0.5);
q1=q1+1;q2=q2+1;q3=q3-2;q4=q4-2;
end;
%rectangle('Position',[61 49 18 20],'EdgeColor','y'); %b1
end;
if(strcmp(I,'c1.jpg')||strcmp(I,'c.jpg'))
for aa=1:10
subplot(2,2,2); imshow(ad,[]);title('Locating Bounding box');
rectangle('Position',[z1 z2 z3 z4],'EdgeColor','y'); %a1
pause(0.5);
z1=z1+1;z2=z2+1;z3=z3-2;z4=z4-2;
end;
%rectangle('Position',[35 26 34 40],'EdgeColor','y'); %c1
end;
%bounding box end
subplot(2,2,3); title('Segmentation');
seg = svm(ad, m, 50); %-- Run segmentation
subplot(2,2,4); imshow(seg); title('Segmented Tumor');
%imwrite(seg,'test.jpg');
it shows SVM classifier name on classified image
i want to hide that name ?
how is it possible ??
  1 comentario
Image Analyst
Image Analyst el 2 de Dic. de 2018
Are you sure you posted this in the right place?
Is this your "Answer" to lolipop?

Iniciar sesión para comentar.

Categorías

Más información sobre Axis Labels en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by