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

LSM_62_sym_generate_noisy_observing_images

PURPOSE ^

% LSM_62_sym_generate_noisy_observing_images

SYNOPSIS ^

function [g,h,std_i_g,std_i_h,par] = LSM_62_sym_generate_noisy_observing_images(g_true,h_true,par)

DESCRIPTION ^

% LSM_62_sym_generate_noisy_observing_images

 add noise to true images

 call:
 [g,h] = LSM_62_sym_generate_noisy_observing_images...
                    (g_true,h_true,vg,vh,plot_type)

 g_true,h_true     true images (square), in [0:255]
 plot_type         in [0,1,2] controlling output

 g,h               % noisy images, in [0:255]
 std_i_g, std_i_h      % standard deviations of cubic interpolation error

 wf 12/2019

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% LSM_62_sym_generate_noisy_observing_images
0002 %
0003 % add noise to true images
0004 %
0005 % call:
0006 % [g,h] = LSM_62_sym_generate_noisy_observing_images...
0007 %                    (g_true,h_true,vg,vh,plot_type)
0008 %
0009 % g_true,h_true     true images (square), in [0:255]
0010 % plot_type         in [0,1,2] controlling output
0011 %
0012 % g,h               % noisy images, in [0:255]
0013 % std_i_g, std_i_h      % standard deviations of cubic interpolation error
0014 %
0015 % wf 12/2019
0016 
0017 function [g,h,std_i_g,std_i_h,par] = LSM_62_sym_generate_noisy_observing_images...
0018     (g_true,h_true,par)
0019 
0020 %% generate first image
0021 Mg = size(g_true,1);
0022 gv = min(255,max(0,round(g_true(:) +...
0023     randn(Mg^2,1).*sqrt(par.vg(round(g_true(:))+1)))));
0024 g = reshape(gv,Mg,Mg);
0025 
0026 %% generate second image
0027 Mh = size(h_true,1);
0028 hv = min(255,max(0,round(h_true(:) +...
0029     randn(Mh^2,1).*sqrt(par.vh(round(h_true(:))+1)))));
0030 h = reshape(hv,Mh,Mh);
0031 
0032 %% determine standard deviation of double bicubic interpolation error
0033 diff_g   = conv2(g,par.Diff_filter,'valid');
0034 diff_h   = conv2(h,par.Diff_filter,'valid');
0035 std_i_g  = std(diff_g(:));
0036 std_i_h  = std(diff_h(:));
0037 
0038 %% plots
0039 if par.plot_type > 1
0040     figure('Name','generated true images')
0041     
0042     subplot(3,3,7);imshow(double(g)/255);title('g');axis equal
0043     %         xlim([-plot_size,plot_size])
0044     %         ylim([-plot_size,plot_size])
0045     subplot(3,3,9);imshow(double(h)/255);title('h');axis equal
0046     %         xlim([-plot_size,plot_size])
0047     %         ylim([-plot_size,plot_size])
0048     colormap(gray)
0049     
0050     std_g_and_h = std([g(:);h(:)]-[g_true(:);h_true(:)])
0051 end
0052 end
0053

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