MATLAB Answers

how to show the title in the imtool figure?

33 views (last 30 days)
summer
summer on 22 Sep 2014
Answered: Image Analyst on 9 Oct 2014
I want to add some describtion in the imtool figure.But the describtion can not show up when i use title function. figure, imtool(I,[]), title(' show some description.'); Is there some other functions to realize it?

  0 Comments

Sign in to comment.

Answers (2)

Geoff Hayes
Geoff Hayes on 22 Sep 2014
According to the documentation of imtool, if you do
hFigure = imtool(I,[]);
then hFigure is a handle to the figure created by the Image Viewer. If that is the case, then you might be able to manipulate the name of the figure as
set(hFigure,'NumberTitle','off','Name','show some description');

  3 Comments

summer
summer on 8 Oct 2014
Thanks for your answer.And i also want to know how to show the title use title function.Just like this.
if true
% code
figure,imshow(s,[]);
title('title test');
end
Thanks again.
Geoff Hayes
Geoff Hayes on 8 Oct 2014
Summer - for title, you can pass the handle of the axes that you want the title to appear over. I don't have the Image Processing Toolbox, so I'm guessing that you could do something like the following
hFig = figure;
imshow(s);
title(findobj('Parent',hFig,'Type','axes'),'title test');
So we use the findobj function to find the object whose parent is hFig and is of type axes. Here we assume that there is only one axes on the figure.
The above may be overkill, since you could probably just replace it with
title(gca,'title test')
where gca gets the current axes handle. But you seem to be suggesting that that won't work (given your question and code). Note that there was no image in your comment.
summer
summer on 9 Oct 2014
Thanks for your prompt answer.I get more knowledge about "title" function through your answer. And i have added the picure already.I want to add the title which is positioned in the example image to the imtool figure. If i use imshow function to show the image,the title can be add very easily through the code"title('title test')".But if i use imtool function,the title can not to add in the figure like the title in the example image. Thanks again.

Sign in to comment.


Image Analyst
Image Analyst on 9 Oct 2014
Summer: I think these two code snippets should answer all your questions:
% First for a regular figure window.
s = uint8(randi(255, [512,512]));
hFig = figure
imshow(s,[]);
title('Title Test', 'FontSize', 15);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Now for the imtool window.
hToolFig = imtool(s);
set(hToolFig, 'Name', 'This is S in the imtool window');
% Note: close all won't close imtool windows.
% imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.

  0 Comments

Sign in to comment.