0001 function [img_data, n_images]= get_img_data(img)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 if isstr(img) && strcmp(img,'UNIT_TEST'); do_unit_test; return; end
0019
0020 if ~strcmp( img(1).type, 'image' );
0021 error('get_img_data expects an image type object');
0022 return;
0023 end
0024
0025 try
0026 img_data= [img.elem_data];
0027 catch
0028 img_data= [img.node_data];
0029 end
0030
0031 if size(img_data,1)==1; img_data=img_data';end
0032
0033 n_images= size(img_data,2);
0034
0035 try
0036 c2f= img.fwd_model.coarse2fine;
0037 catch
0038 return;
0039 end
0040
0041 if size(img_data,1)==size(c2f,2)
0042 img_data=c2f * img_data;
0043 end
0044
0045
0046 function do_unit_test
0047 img=calc_jacobian_bkgnd(mk_common_model('a2c0',8));
0048 unit_test_cmp('elem_01', get_img_data(img), ones(64,1) )
0049
0050 imgk = img; imgk.elem_data = img.elem_data';
0051 unit_test_cmp('elem_02', get_img_data(imgk), ones(64,1) )
0052
0053 imgk = img; imgk(2) = img;
0054 unit_test_cmp('elem_03', get_img_data(imgk), ones(64,2) )
0055
0056
0057
0058
0059 imgk(1).elem_data = imgk(1).elem_data*[1,2];
0060 unit_test_cmp('elem_04', get_img_data(imgk(1)), ones(64,1)*[1,2] )
0061 unit_test_cmp('elem_05', get_img_data(imgk), ones(64,1)*[1,2,1] )
0062
0063 nd =ones(size(img.fwd_model.nodes,1),1);
0064 imgn = rmfield(img,'elem_data'); imgn.node_data=nd;
0065 unit_test_cmp('node_01', get_img_data(imgn), nd)
0066
0067 i2 = mk_common_model('b2c0',8); fmdl2= i2.fwd_model;
0068 c2f = mk_coarse_fine_mapping(fmdl2, img.fwd_model);
0069 img.fwd_model.coarse2fine = c2f;
0070 unit_test_cmp('c2f_01', get_img_data(img), c2f*ones(64,1))
0071
0072