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

LSM_generate_true_image

PURPOSE ^

% LSM_generate_true b/w image generates true image from RGB-image on file

SYNOPSIS ^

function [I_true,N1,M1]=LSM_generate_true_image(img_filename,row,col,Ni)

DESCRIPTION ^

% LSM_generate_true b/w image generates true image from RGB-image on file

 I_true=LSM_generate_true_image(img_filename,row,col,Ni)

 img_filename  file name (without path)
 row, col      row and column f window
 Ni            half size of window

 I_true        true image used for generating observed images

 wf 09/2012

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% LSM_generate_true b/w image generates true image from RGB-image on file
0002 %
0003 % I_true=LSM_generate_true_image(img_filename,row,col,Ni)
0004 %
0005 % img_filename  file name (without path)
0006 % row, col      row and column f window
0007 % Ni            half size of window
0008 %
0009 % I_true        true image used for generating observed images
0010 %
0011 % wf 09/2012
0012 %
0013 
0014 function [I_true,N1,M1]=LSM_generate_true_image(img_filename,row,col,Ni)
0015 
0016 % input image
0017 I_ori = imread(['example_data/Images/',img_filename]);
0018 [N1,M1,channels] = size(I_ori);
0019 % guarantee I_true is square with odd number of pixels
0020 N = 2*floor(min(N1,M1)/2)-1;
0021 
0022 if  max([row,col]) < N-Ni &&  min([row,col]) > Ni
0023     
0024     I_orig=I_ori(1:N,1:N);
0025     % if color then make graylevel
0026     if channels == 3
0027         Ig = double(rgb2gray(I_orig));
0028     else
0029         Ig = I_orig;
0030     end
0031     I_ori(row-Ni:row+Ni,col-Ni)=255*ones(1,2*Ni+1);
0032     I_ori(row-Ni:row+Ni,col+Ni)=255*ones(1,2*Ni+1);
0033     I_ori(row-Ni,col-Ni:col+Ni)=255*ones(2*Ni+1,1);
0034     I_ori(row+Ni,col-Ni:col+Ni)=255*ones(2*Ni+1,1);
0035     figure
0036     imshow(I_ori);
0037     
0038     % smooth
0039     
0040     Box = [0 0 1 4 6 4 1 0 0]'/16;
0041     ad = (length(Box)-1)/2;
0042     I_g_r    = conv2(single(Ig),Box);
0043     I_g_rc   = conv2(I_g_r,Box');
0044     
0045     % select window
0046     I_true = uint8(round(I_g_rc(row-Ni+ad:row+Ni+ad,col-Ni+ad:col+Ni+ad)));
0047     
0048 else
0049     display(['wrong window selection']);
0050     stop
0051 end
0052 
0053 
0054 
0055 return

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