Home > Matching_SYM_LSM > src > 2D_LSM_62 > 2D_LSM_62_sym_Functions > LSM_62_sym_generate_image.m

LSM_62_sym_generate_image

PURPOSE ^

SYNOPSIS ^

function I_true = LSM_62_sym_generate_image(par,plot_type)

DESCRIPTION ^

% Generate true image for demo simulated
 assumption: I_true \in  [0,255]

 call:
 I_true = LSM_62_sym_generate_image(par,plot_type)

 has a border of BOUND=3 on all sides compared to input,
 for allowing cubic interpolation and shift in [0,1]

 plot_type          in [0,1,2] for controlling output

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function I_true = LSM_62_sym_generate_image(par,plot_type)
0002 %
0003 %% Generate true image for demo simulated
0004 % assumption: I_true \in  [0,255]
0005 %
0006 % call:
0007 % I_true = LSM_62_sym_generate_image(par,plot_type)
0008 %
0009 % has a border of BOUND=3 on all sides compared to input,
0010 % for allowing cubic interpolation and shift in [0,1]
0011 %
0012 % plot_type          in [0,1,2] for controlling output
0013 %
0014 
0015 %% prepare true values
0016 a7_true = par.S_true(1);
0017 a8_true = par.S_true(2);
0018 
0019 Si_true =  1/(par.S_true(1))*[1,-par.S_true(2)];
0020 a7i_true = Si_true(1);
0021 a8i_true = Si_true(2);
0022 
0023 
0024 %% determine image size
0025 % forward
0026 % square f
0027 Nf=par.Nfr+par.BOUND;
0028 bbf    = square_corners(Nf);
0029 bbfr   = square_corners(par.Nfr);
0030 % region f for g
0031 bbfg  = par.Bi_true*bbf;
0032 Ngr   = ceil(max(abs(bbfg(:))));
0033 Ng    = Ngr + par.BOUND;
0034 bbfgf = par.B_true*square_corners(Ng);
0035 % region f for h
0036 bbfh  = par.B_true*bbf;
0037 Nhr   = ceil(max(abs(bbfh(:))));
0038 Nh    = Nhr + par.BOUND;
0039 bbfhf = par.Bi_true*square_corners(Nh);
0040 % required size of image
0041 Nif    = ceil(max(abs([bbfgf(:);bbfhf(:)])))+par.BOUND;
0042 
0043 % backward
0044 % square f
0045 Nf=par.Nfr+par.BOUND;
0046 bbf    = square_corners(Nf);
0047 % region f for g
0048 bbfg  = par.B_true*bbf;
0049 Ngr   = ceil(max(abs(bbfg(:))));
0050 Ng    = Ngr + par.BOUND;
0051 bbfgf = par.Bi_true*square_corners(Ng);
0052 % region f for h
0053 bbfh  = par.Bi_true*bbf;
0054 Nhr   = ceil(max(abs(bbfh(:))));
0055 Nh    = Nhr + par.BOUND;
0056 bbfhf = par.B_true*square_corners(Nh);
0057 % required size of image
0058 Nib    = ceil(max(abs([bbfgf(:);bbfhf(:)])))+par.BOUND;
0059 
0060 Ni = max(Nif,Nib);
0061 
0062 f_min_f=max(255*[a8_true,-a8_true])+5*par.sigma_max+10;  % in [0,255]
0063 f_max_f=min([a7_true*255+a8_true*255,(255-a8_true*255)/a7_true])-5*par.sigma_max-10;
0064 f_min_b=max(255*[a8i_true,-a8i_true])+5*par.sigma_max+10;  % in [0,255]
0065 f_max_b=min([a7i_true*255+a8i_true*255,(255-a8i_true*255)/a7i_true])-5*par.sigma_max-10;
0066 f_min=max(f_min_f,f_min_b);
0067 f_max=min(f_max_f,f_max_b);
0068 
0069 %% artificial image or read in image
0070 if strcmp(par.img_filename(1:6),'square')
0071     
0072     I_true = LSM_generate_square(Ni,Nf,f_min,f_max,par.par);
0073     
0074     if plot_type > 0
0075         figure('name','true image');
0076         colormap('gray')
0077         imagesc(I_true);
0078         axis equal
0079     end
0080 end
0081 if strcmp(par.img_filename(1:6),'waves2')
0082     I_true = LSM_generate_waves2(Ni,f_min,f_max,par.par);
0083     
0084     if plot_type > 0
0085         
0086         figure('name','true image');
0087         colormap('gray')
0088         imagesc(I_true);
0089         axis equal
0090     end
0091 end
0092 if strcmp(par.img_filename(1:6),'MIT.pn')
0093     
0094     % read and generate true image
0095     I_true = LSM_generate_true_image(par.img_filename,par.row,par.col,Ni);
0096     I_true = (double(I_true)*(f_max-f_min)/255 + f_min);
0097     
0098 end
0099 if strcmp(par.img_filename(1:6),'random')
0100     
0101     [fa,~,~] = LSM_generate_random(Ni,f_min,f_max,par.par);
0102     I_true   = reshape(fa(:,1),2*Ni+1,2*Ni+1);
0103     
0104     if plot_type > 0
0105         
0106         figure('name','true image');
0107         colormap('gray')
0108         imagesc(I_true);
0109         axis equal
0110     end
0111 end
0112 
0113 if plot_type > 1
0114     plot_size = max([Ni,Nf,Ng,Nh])+2;
0115     
0116     
0117     figure('name','mean, left and right: boundaries');
0118     subplot(2,3,2)
0119     hold on
0120     plot_quadrangle(square_corners(Ni),'-r')
0121     plot_quadrangle(square_corners(Nf),'-k')
0122     plot_quadrangle(square_corners(par.Nfr),'--k')
0123     plot_quadrangle(bbfgf,'-b')
0124     plot_quadrangle(bbfhf,'-g')
0125     xlim([-plot_size,plot_size])
0126     ylim([-plot_size,plot_size])
0127     axis equal
0128     
0129     subplot(2,3,4)
0130     hold on
0131     plot_quadrangle(square_corners(Ng),'-b')
0132     plot_quadrangle(square_corners(Ngr),'--b')
0133     plot_quadrangle(par.Bi_true*bbfr,'--k')
0134     plot_quadrangle(par.Bi_true*bbf,'-k')
0135     xlim([-plot_size,plot_size])
0136     ylim([-plot_size,plot_size])
0137     
0138     axis equal
0139     
0140     subplot(2,3,6)
0141     hold on
0142     plot_quadrangle(square_corners(Nh),'-g')
0143     plot_quadrangle(square_corners(Nhr),'--g')
0144     plot_quadrangle(par.B_true*bbfr,'--k')
0145     plot_quadrangle(par.B_true*bbf,'-k')
0146     xlim([-plot_size,plot_size])
0147     ylim([-plot_size,plot_size])
0148     
0149     axis equal
0150     
0151 end
0152 
0153 end
0154

Generated on Sun 19-Jul-2020 23:00:25 by m2html © 2005