source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/kovesi/show.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1% SHOW - Displays an image with the right size and colors and with a title.
2%
3% Usage:  show(im, figNo, title)
4%
5% Arguments:  im    - Either a 2 or 3D array of pixel values or the name
6%                     of an image file;
7%             figNo - Optional figure number to display image in. If
8%                     figNo is 0 the current figure or subplot is
9%                     assumed.
10%             title - Optional string specifying figure title
11%
12% The function displays the image, automatically setting the colour map to
13% grey if it is a 2D image, or leaving it as colour otherwise, and setting
14% the axes to be 'equal'.  The image is also displayed as 'TrueSize', that
15% is, pixels on the screen match pixels in the image (if it is possible
16% to fit it on the screen, otherwise MATLAB rescales it to fit).
17%
18% Unless you are doing a subplot (figNo==0) the window is sized to match
19% the image, leaving no border, and hence saving desktop real estate.
20%
21% If figNo is omitted a new figure window is created for the image.  If
22% figNo is supplied, and the figure exists, the existing window is reused to
23% display the image, otherwise a new window is created. If figNo is 0 the
24% current figure or subplot is assumed.
25
26% Copyright (c) 2000-2003 Peter Kovesi
27% School of Computer Science & Software Engineering
28% The University of Western Australia
29% http://www.csse.uwa.edu.au/
30%
31% Permission is hereby granted, free of charge, to any person obtaining a copy
32% of this software and associated documentation files (the "Software"), to deal
33% in the Software without restriction, subject to the following conditions:
34%
35% The above copyright notice and this permission notice shall be included in
36% all copies or substantial portions of the Software.
37%
38% The Software is provided "as is", without warranty of any kind.
39
40% October 2000  Original version
41% March   2003  Tweeks to put figure name in window bar and allow for
42%               subplots
43
44
45function show(im, figNo, Title)
46   
47    warning('off');        % Turn off warnings that might arise if image
48                           % has to be rescaled to fit on screen
49   
50    if nargin <= 2                         
51        if ~isnumeric(im) & ~islogical(im) % Guess that an image name has
52                                           % been supplied
53            Title = im;
54            im = imread(im);
55        else
56            Title = inputname(1);  % Get variable name of image data
57        end
58    end
59   
60    newWindow = 1;
61    if nargin >= 2
62        if figNo               % We have a valid figure number
63            figure(figNo);     % Reuse or create a figure window with
64                               % this number
65            subplot('position',[0 0 1 1]); % Use the whole window
66        else                   
67            newWindow=0;       % figNo == 0
68        end
69    else
70        figNo = figure;        % Create new figure window
71        subplot('position',[0 0 1 1]); % Use the whole window
72    end
73
74    if ndims(im) == 2          % Display as greyscale
75        imagesc(im)
76        colormap('gray');
77    else
78        imshow(im)             % Display as RGB
79    end
80
81    if newWindow           
82        axis('image'), axis('off')
83        set(figNo,'name', ['  ' Title]), truesize(figNo)
84    else                          % Assume we are trying to do a subplot
85        axis('image'), axis('off')
86        title(Title) % Use a title rather than rename the figure       
87    end
88
89    warning('on');  % Restore warnings
90   
91
Note: See TracBrowser for help on using the repository browser.