source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vlutil/toolbox/imarray.m @ 86

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

Added original make3d

File size: 2.3 KB
Line 
1function [H,J] = imarray(A,varargin)
2% IMARRAY  Display array of images
3%   IMARRAY(A) plots the array of images A. A can be either a M*N*K
4%   array, storing one intensity image per layer, or a M*N*3*K array,
5%   storing one RGB image per layer.
6%
7%   H=IMARRAY(...) returns the handle H of the axis where the image is
8%   plotted.
9%
10%   [H,J]=IMARRAY(...) returns the plotted image J as well.
11%
12%   The function accepts the following option-value pairs:
13%
14%   'Spacing' [0]
15%     Orlates the images with a black border of the specified width.
16%   
17%   IMARRAYSC(A, 'Spacing', spacing) is another way of specifying the
18%   spacing.
19%
20%   See also IMARRAYSC().
21
22% AUTORIGHTS
23% Copyright (C) 2006 Andrea Vedaldi
24%       
25% This file is part of VLUtil.
26%
27% VLUtil is free software; you can redistribute it and/or modify
28% it under the terms of the GNU General Public License as published by
29% the Free Software Foundation; either version 2, or (at your option)
30% any later version.
31%
32% This program is distributed in the hope that it will be useful,
33% but WITHOUT ANY WARRANTY; without even the implied warranty of
34% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
35% GNU General Public License for more details.
36%
37% You should have received a copy of the GNU General Public License
38% along with this program; if not, write to the Free Software Foundation,
39% Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
40
41reverse = 1 ;
42spacing = 0 ;
43lay     = [] ;
44
45for k=1:2:length(varargin) 
46  switch varargin{k}
47    case 'Layout'
48      lay=varargin{k+1} ;
49    case 'Spacing'
50      sp=varargin{k+1} ;
51    otherwise
52      error(['Unknown parameter ''', varargin{k}, '''']) ;
53  end
54end
55
56if ndims(A) <= 3
57  d=1 ;
58  [Mi,Ni,K] = size(A) ;
59else
60  [Mi,Ni,d,K] = size(A) ;
61  if(d ~= 3)
62    error(['A should be either M*N*K or M*N*3*K']);
63  end
64end
65
66if isempty(lay)
67  N = ceil(sqrt(K)) ;
68  M = ceil(K/N) ;
69else
70  M = lay(1) ;
71  N = lay(2) ;
72  K = min(K,M*N) ;
73end
74
75cdata = zeros(Mi*M + spacing*(M-1), Ni*N + spacing*(N-1), d) ;
76for k=1:K
77  p = k - 1 ;
78  i = floor(p/N) ;
79  if reverse
80    i = M-1 - i ;
81  end
82  j = mod(p,N) ;
83  irng = i*(Mi+spacing) + (0:Mi-1) + 1 ;
84  jrng = j*(Ni+spacing) + (0:Ni-1) + 1 ;
85  if(d == 1)
86    J = A(:,:,k) ;
87  else
88    J = A(:,:,:,k) ;
89  end
90  cdata(irng,jrng,:) = J ;
91end
92
93H = image(cdata) ;
94J = cdata ;
Note: See TracBrowser for help on using the repository browser.