source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vlutil/toolbox/imarraysc.m @ 37

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

Added original make3d

File size: 2.4 KB
Line 
1function [H,J] = imarraysc(A, varargin)
2% IMARRAYSC  Scale and display an array of images
3%   H = IMARRAYSC(A) behaves as IMARRAY(A), but scales the range
4%   of each image to fill the interval [0,1].
5%
6%   In addition to the option-value paris accepted by IMARRAY(),
7%   the function accepts also:
8%
9%   'CLim' [[]]
10%     If not empty, use the specified intensity range.
11%
12%   See also IMARRAY().
13
14% AUTORIGHTS
15% Copyright (C) 2006 Andrea Vedaldi
16%       
17% This file is part of VLUtil.
18%
19% VLUtil is free software; you can redistribute it and/or modify
20% it under the terms of the GNU General Public License as published by
21% the Free Software Foundation; either version 2, or (at your option)
22% any later version.
23%
24% This program is distributed in the hope that it will be useful,
25% but WITHOUT ANY WARRANTY; without even the implied warranty of
26% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27% GNU General Public License for more details.
28%
29% You should have received a copy of the GNU General Public License
30% along with this program; if not, write to the Free Software Foundation,
31% Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32
33reverse=1 ;
34spacing=0 ;
35clim=[] ;
36
37% Parse
38if(length(varargin)>1 && isnumeric(varargin{1}))
39  spacing=varargin{1} ;
40  varargin = { varargin{2:end} } ;
41end
42
43lay=[] ;
44
45for k=1:2:length(varargin) 
46  switch lower(varargin{k})
47    case 'layout'
48      lay=varargin{k+1} ;
49    case 'spacing'
50      spacing=varargin{k+1} ;
51    case 'clim'
52      clim=varargin{k+1} ;
53    otherwise
54      error(['Unknown option ''', varargin{k}, '''']) ;
55  end
56end
57
58if ndims(A) <= 3
59  d = 1 ;
60  [Mi,Ni,K] = size(A) ;
61else
62  [Mi,Ni,d,K] = size(A) ;
63  if(d ~= 3)
64    error(['A should be either M*N*K or M*N*3*K']);
65  end
66end
67
68if isempty(lay)
69  N = ceil(sqrt(K)) ;
70  M = ceil(K/N) ;
71else
72  M = lay(1) ;
73  N = lay(2) ;
74  K = min(K,M*N) ;
75end
76
77cdata = zeros(Mi*M + spacing*(M-1), Ni*N + spacing*(N-1), d ) ;
78
79for k=1:K
80  p = k - 1 ;
81  i = floor(p/N) ;
82  if reverse
83    i = M-1 - i ;
84  end
85  j = mod(p,N) ;
86  irng = i*(Mi+spacing) + (0:Mi-1) + 1 ;
87  jrng = j*(Ni+spacing) + (0:Ni-1) + 1 ;
88  if d == 1
89    J = A(:,:,k) ;
90  else
91    J = A(:,:,:,k) ;
92  end
93  if isempty( clim )
94    J = J - min(J(:)) ;
95    m = max(J(:)) ;
96    if(m > eps)
97      J = J / m ;
98    end
99  end
100  cdata(irng,jrng,:) = J ;
101end
102
103if ~isempty(clim)
104  H = imagesc(cdata,clim) ;
105else
106  H = imagesc(cdata) ;
107end
108
109J = cdata ;
Note: See TracBrowser for help on using the repository browser.