Home > detect > WBCmn.m

WBCmn

PURPOSE ^

% 0. PARAMETERS

SYNOPSIS ^

function WBCmn(prefix,start_im_no,end_im_no,im_digit_ct,os_index)

DESCRIPTION ^

% 0.  PARAMETERS
 prefix = 'clpapc1bl#1'; %'clp7bl';
 start_im_no = 001;
 end_im_no = 020;
 im_digit_ct = 3 ;
 os_index = 0;

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function WBCmn(prefix,start_im_no,end_im_no,im_digit_ct,os_index)
0002 %% 0.  PARAMETERS
0003 % prefix = 'clpapc1bl#1'; %'clp7bl';
0004 % start_im_no = 001;
0005 % end_im_no = 020;
0006 % im_digit_ct = 3 ;
0007 % os_index = 0;
0008 reg_model = 0;
0009 max_stable_moveT = 500;
0010 
0011 if ( os_index == 0 )
0012     reg_prog = 'V:\toolbox\MotionNorm\icp\gdbicp.exe';
0013 end
0014 if ( os_index == 1 )
0015     reg_prog = '/v1/toolbox/MotionNorm/icp/gdbicp.exe';
0016 end
0017 
0018 
0019 
0020 mkdir('MN');
0021 %% 1.  RUN REGISTRATION CODE
0022 for i=(start_im_no):(end_im_no)
0023 
0024     % 2.1  call registration program
0025     im_num = get_image_num_string ( start_im_no, im_digit_ct );
0026     im0 = [prefix im_num '.bmp'];
0027 
0028     fid = fopen ( im0, 'r' );
0029     if ( fid < 1 )
0030         continue;
0031     else
0032         fclose ( fid );
0033     end
0034 
0035     im_num = get_image_num_string ( i, im_digit_ct );
0036     im1 = [prefix im_num '.bmp'];
0037     fid = fopen ( im1, 'r' );
0038     if ( fid < 1 )
0039         continue;
0040     else
0041         fclose ( fid );
0042     end
0043 
0044     in1 = getimagenameonly ( im1 );
0045     in0 = getimagenameonly ( im0 );
0046 
0047     fn = ['mosaic_' in1 '_to_' in0 '.xform'];
0048     m = gettransform_model ( fn );
0049 
0050     com = [reg_prog ' ' im1 ' ' im0 ' -model ' num2str(reg_model)];
0051 
0052 
0053     % 2.2  read the translation recovered from the registration program
0054     in1 = getimagenameonly ( im1 );
0055     in0 = getimagenameonly ( im0 );
0056 
0057     fn = ['mosaic_' in1 '_to_' in0 '.xform'];
0058     m = gettransform_model ( fn );
0059     disp(fn);
0060     fid = fopen ( fn, 'r' );
0061     if ( fid < 1 )
0062         system (com);
0063     else
0064         fclose ( fid );
0065     end
0066 
0067 
0068     % now translate everything
0069     m = gettransform_model ( fn );
0070 
0071     if ( ( m == 2 ) || ( m == 5 ) )
0072         [ b, a, t, c ] = gettransform_quad ( fn );
0073     end
0074 
0075     if ( ( m == 0 ) || ( m == 4 ) )
0076         [ b, a, t, c ] = gettransform_similar ( fn );
0077     end
0078 
0079     if ( m == -1 )
0080         continue;
0081     end
0082 
0083     fnT = o2_getimagename ( prefix, i, im_digit_ct, 'bmp' );
0084     im = imread ( char ( fnT ) );
0085     [R,C] = size ( im );
0086     outIm = zeros ( R, C, 'uint8' );
0087 
0088     for x = 1:C
0089         for y = 1:R
0090             [x1,y1] = transform_quad ( x, y, b, a, t, c );
0091             x1 = round ( x1 );
0092             y1 = round ( y1 );
0093 
0094             if ( ( x1 >= 1 ) && ( x1 <= C ) && ( y1 >= 1 ) && ( y1 <= R ) )
0095                 outIm(y1,x1) = im(y,x);
0096             end
0097         end
0098     end
0099     
0100     
0101     fnT = o2_getimagename ( prefix, i, im_digit_ct, 'mn.png' );
0102     fnT = strcat('MN/',fnT);
0103     imwrite ( outIm, fnT );
0104 end
0105 
0106 % end

Generated on Thu 17-Mar-2011 14:45:51 by m2html © 2005