[37] | 1 | function [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 | |
---|
| 41 | reverse = 1 ; |
---|
| 42 | spacing = 0 ; |
---|
| 43 | lay = [] ; |
---|
| 44 | |
---|
| 45 | for 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 |
---|
| 54 | end |
---|
| 55 | |
---|
| 56 | if ndims(A) <= 3 |
---|
| 57 | d=1 ; |
---|
| 58 | [Mi,Ni,K] = size(A) ; |
---|
| 59 | else |
---|
| 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 |
---|
| 64 | end |
---|
| 65 | |
---|
| 66 | if isempty(lay) |
---|
| 67 | N = ceil(sqrt(K)) ; |
---|
| 68 | M = ceil(K/N) ; |
---|
| 69 | else |
---|
| 70 | M = lay(1) ; |
---|
| 71 | N = lay(2) ; |
---|
| 72 | K = min(K,M*N) ; |
---|
| 73 | end |
---|
| 74 | |
---|
| 75 | cdata = zeros(Mi*M + spacing*(M-1), Ni*N + spacing*(N-1), d) ; |
---|
| 76 | for 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 ; |
---|
| 91 | end |
---|
| 92 | |
---|
| 93 | H = image(cdata) ; |
---|
| 94 | J = cdata ; |
---|