summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/stella/dispimg.m
blob: 4e419a089e13e7e4c28c88d119f9cb0f9446940c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
% function dispimg(g,fmt,lgd,cmap) display multiple images in one figure. 
% Input:
%    g = a cell and fmt is a 1x2 vector specifying the layout.
%    lgd = a string cell for the title of each image. 
%    cmap = the colormap (default is the gray, -1 for the inverted gray).
%    ishori = a vector of 1/0 to display real and imag parts horizontally / vertically

% Stella X. Yu, 2000.

function dispimg(g,fmt,lgd,cmap,ishori);

cellg = iscell(g);
if cellg,
    num_fig = length(g);
else
    num_fig = size(g,3);
end;

if nargin<2 | isempty(fmt),
    m = ceil(sqrt(num_fig));
    n = ceil(num_fig / m);
else
    m = fmt(1);
    n = fmt(2);
end

if nargin<3 | isempty(lgd),
    lgd = 1:num_fig;
end 
if isnumeric(lgd),
   lgd = cellstr(num2str(lgd(:),3)); 
end
i = size(lgd);
if i(1)==1,
   lgd = [lgd, cell(1,num_fig-i(2))];
else
   lgd = [lgd; cell(num_fig-i(1),1)];
end

if nargin<5 | isempty(ishori),
   ishori = ones(num_fig,1);
end
ishori(end+1:num_fig) = ishori(end);

for k=1:num_fig,
    subplot(m,n,k);
    if cellg,
        showim(g{k},[],ishori(k));
    else
        showim(g(:,:,k),[],ishori(k));
    end
    title(lgd{k});
end

if nargin<4 | isempty(cmap),
   cmap = gray;
end
if length(cmap)==1,
   if cmap==1,
      cmap = gray;
   else
      cmap = flipud(gray);
   end
end
colormap(cmap);