Ignore:
Timestamp:
Dec 23, 2010, 8:09:20 AM (13 years ago)
Author:
sommeria
Message:

bug in civ corrected: civ2 was not lauched for Windows system
various bugs corrections and cleaning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r158 r159  
    10991099function MenuDetectGrid_Callback(hObject, eventdata, handles)
    11001100%------------------------------------------------------------------------
     1101%% initiate the grid
    11011102CalibData=get(handles.geometry_calib,'UserData');%get information stored on the GUI geometry_calib
    11021103grid_input=[];%default
     
    11051106end
    11061107[T,CalibData.grid,white_test]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T
    1107 
    11081108set(handles.geometry_calib,'UserData',CalibData)%store the phys grid parameters for later use
    11091109
    1110 %read the four last point coordinates in pixels
     1110%% read the four last point coordinates in pixels
    11111111Coord_cell=get(handles.ListCoord,'String');%read list of coordinates on geometry_calib
    11121112data=read_geometry_calib(Coord_cell);
    11131113nbpoints=size(data.Coord,1); %nbre of calibration points
    11141114if nbpoints~=4
    1115     msgbox_uvmat('ERROR','four points must be selected by the mouse, beginning by the new x axis, to delimitate the phs grid area')
     1115    msgbox_uvmat('ERROR','four points must have be selected by the mouse, beginning by the new x axis, to delimitate the phys grid area')
    11161116    return
    11171117end
     
    11301130end
    11311131
    1132 %read the current image, displayed in the GUI uvmat
     1132%% read the current image, displayed in the GUI uvmat
    11331133huvmat=findobj(allchild(0),'Name','uvmat');
    11341134UvData=get(huvmat,'UserData');
    11351135A=UvData.Field.A;
    11361136npxy=size(A);
    1137 %linear transform on the current image
    1138 X=[CalibData.grid.x_0 CalibData.grid.x_1 CalibData.grid.x_0 CalibData.grid.x_1]';%corner absissa in the phys coordinates
    1139 Y=[CalibData.grid.y_0 CalibData.grid.y_0 CalibData.grid.y_1 CalibData.grid.y_1]';%corner ordinates in the phys coordinates
    1140 
    1141 %calculate transform matrices:
     1137X=[CalibData.grid.x_0 CalibData.grid.x_1 CalibData.grid.x_0 CalibData.grid.x_1]';%corner absissa in the phys coordinates (cm)
     1138Y=[CalibData.grid.y_0 CalibData.grid.y_0 CalibData.grid.y_1 CalibData.grid.y_1]';%corner ordinates in the phys coordinates (cm)
     1139
     1140%calculate transform matrices for plane projection
    11421141% reference: http://alumni.media.mit.edu/~cwren/interpolator/ by Christopher R. Wren
    11431142B = [ X Y ones(size(X)) zeros(4,3)        -X.*corners_X -Y.*corners_X ...
     
    11461145D = [ corners_X , corners_Y ];
    11471146D = reshape (D', 8 , 1 );
    1148 %l = inv(B' * B) * B' * D;
    11491147l = (B' * B)\B' * D;
    11501148Amat = reshape([l(1:6)' 0 0 1 ],3,3)';
    11511149C = [l(7:8)' 1];
    11521150
    1153 %GeometryCalib.CalibrationType='tsai';
    1154 %GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    1155 % GeometryCalib.f=1;
    1156 % GeometryCalib.dpx=1;
    1157 % GeometryCalib.dpy=1;
    1158 % GeometryCalib.sx=1;
    1159 % GeometryCalib.Cx=0;
    1160 % GeometryCalib.Cy=0;
    1161 % GeometryCalib.kappa1=0;
    1162 % GeometryCalib.Tx=Amat(1,3);
    1163 % GeometryCalib.Ty=Amat(2,3);
    1164 % GeometryCalib.Tz=1;
    1165 % GeometryCalib.R=[Amat(1,1),Amat(1,2),0;Amat(2,1),Amat(2,2),0;C(1),C(2),0];
    1166 %
    1167 % [Amod,Rangx,Rangy]=phys_Ima(A-min(min(A)),GeometryCalib,0);
    1168 
     1151% transform grid image into 'phys' coordinates
    11691152GeometryCalib.fx_fy=[1 1];
    11701153GeometryCalib.Tx_Ty_Tz=[Amat(1,3) Amat(2,3) 1];
    11711154GeometryCalib.R=[Amat(1,1),Amat(1,2),0;Amat(2,1),Amat(2,2),0;C(1),C(2),0];
     1155GeometryCalib.CoordUnit='cm';
    11721156path_uvmat=which('uvmat');% check the path detected for source file uvmat
    11731157path_UVMAT=fileparts(path_uvmat); %path to UVMAT
     
    11881172Rangx=DataOut.AX;
    11891173Rangy=DataOut.AY;
    1190 % GeometryCalib.dpx=1;
    1191 % GeometryCalib.dpy=1;
    1192 % GeometryCalib.sx=1;
    1193 % GeometryCalib.Cx=0;
    1194 % GeometryCalib.Cy=0;
    1195 % GeometryCalib.kappa1=0;
    1196 % GeometryCalib.Tx=Amat(1,3);
    1197 % GeometryCalib.Ty=Amat(2,3);
    1198 % GeometryCalib.Tz=1;
    1199 % GeometryCalib.R=[Amat(1,1),Amat(1,2),0;Amat(2,1),Amat(2,2),0;C(1),C(2),0];
    1200 %
    1201 % [Amod,Rangx,Rangy]=phys_Ima(A-min(min(A)),GeometryCalib,0);
    1202 
    12031174if white_test
    1204     Amod=double(Amod);%will look for image maxima
     1175    Amod=double(Amod);%case of white grid markers: will look for image maxima
    12051176else
    1206     Amod=-double(Amod);%will look for image minima
     1177    Amod=-double(Amod);%case of black grid markers: will look for image minima
    12071178end
    12081179% figure(12) %display corrected image
     
    12101181% image(Rangx,Rangy,uint8(255*Amod/Amax))
    12111182
     1183%% detection of local image extrema in each direction
    12121184Dx=(Rangx(2)-Rangx(1))/(npxy(2)-1); %x mesh in real space
    12131185Dy=(Rangy(2)-Rangy(1))/(npxy(1)-1); %y mesh in real space
     
    12301202    x_shift=0;
    12311203    y_shift=0;
    1232     %if ind_x_max+2<=2*ind_range_x+1 && ind_x_max-2>=1
    12331204    if ind_x_max+2<=numel(x_profile) && ind_x_max-2>=1
    12341205        Atop=x_profile(ind_x_max-2:ind_x_max+2);
Note: See TracChangeset for help on using the changeset viewer.