How to show title and xlabel on the bottom of every image?
이전 댓글 표시
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
답변 (3개)
Chad Greene
2014년 12월 31일
편집: Chad Greene
2014년 12월 31일
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
Chad Greene
2014년 12월 31일
A note: try not to use i or j as variables. It can occasionally cause problems because by default they equal the imaginary unit.
Lolipop
2014년 12월 31일
Chad Greene
2015년 1월 2일
Did ntitle get left in your downloads folder, or somewhere Matlab can't find it?
Image Analyst
2015년 1월 1일
0 개 추천
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
Lolipop
2015년 1월 1일
Image Analyst
2015년 1월 1일
편집: Image Analyst
2015년 1월 1일
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]);

Shahid Ameer
2018년 12월 2일
편집: Chad Greene
2018년 12월 4일
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
Image Analyst
2018년 12월 2일
Are you sure you posted this in the right place?
Is this your "Answer" to lolipop?
카테고리
도움말 센터 및 File Exchange에서 Title에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!