0001 function r_img = mk_mosaic(rimg, sep, vh, n_col)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 if nargin==1 && ischar(rimg) && strcmp(rimg, 'UNIT_TEST'), do_unit_test, return, end
0025
0026
0027 [npy,npx,jnk] = size(rimg);
0028 n_frames = size(rimg,3);
0029 n_levels = size(rimg,4);
0030
0031 if nargin < 2
0032 sep = 0;
0033 end
0034 if nargin < 3
0035 vh = [];
0036 end
0037 if nargin < 4
0038 n_col = 0;
0039 end
0040 vert_rows = 0;
0041 if nargin > 2 && ~isempty(vh)
0042 img_cols = n_frames * max( vh(:,1) );
0043 img_rows = max( vh(:,2) );
0044 else
0045
0046
0047
0048
0049 vert_rows = ceil( sqrt(n_frames / n_levels) );
0050 if n_col > 0
0051 img_cols = n_col;
0052 else
0053 img_cols = ceil( n_frames/vert_rows );
0054 end
0055 img_rows = ceil(n_frames*n_levels/img_cols);
0056 img_rows = ceil(img_rows/n_levels)*n_levels;
0057 end
0058
0059 r_img = NaN*ones(img_rows*npy + (img_rows-1)*sep, ...
0060 img_cols*npx + (img_cols-1)*sep );
0061
0062 idxx= (-npx:-1)+1;
0063 idxy= (-npy:-1)+1;
0064 imno= 1;
0065 for img_no = 1:n_frames
0066 for lev_no = 1:n_levels
0067 if ~isempty(vh)
0068 i_col= n_frames*(vh( lev_no, 1)-1) + img_no;
0069 i_row= vh( lev_no, 2);
0070 else
0071 i_col= rem( img_no-1, img_cols) + 1;
0072 i_row= (ceil( img_no / img_cols) -1) * n_levels + lev_no ;
0073 end
0074
0075 r_img(i_row*npy + idxy + sep*(i_row-1), ...
0076 i_col*npx + idxx + sep*(i_col-1)) = rimg(:,:,img_no,lev_no);
0077 imno= imno + 1;
0078 end
0079 end
0080
0081 function do_unit_test
0082 img=calc_jacobian_bkgnd(mk_common_model('n3r2',[16,2]));
0083 img.calc_colours.npoints= 16;
0084 img.elem_data=toeplitz(1:size(img.fwd_model.elems,1),1);
0085 img.elem_data = img.elem_data(:,[1,1]);
0086 levels=[inf,inf,1,1,1;
0087 0,inf,inf,2,1;
0088 0,1,inf, 3,1];
0089 rimg= calc_slices( img, levels(:,1:3) );
0090 msk = mk_mosaic(rimg, 0, levels(:,4:5));
0091 subplot(3,1,1)
0092 imagesc(msk), axis equal tight
0093
0094 msk = mk_mosaic(rimg);
0095 subplot(3,1,2)
0096 imagesc(msk), axis equal tight
0097