Changeset 159 for trunk/src/geometry_calib.m
- Timestamp:
- Dec 23, 2010, 8:09:20 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r158 r159 1099 1099 function MenuDetectGrid_Callback(hObject, eventdata, handles) 1100 1100 %------------------------------------------------------------------------ 1101 %% initiate the grid 1101 1102 CalibData=get(handles.geometry_calib,'UserData');%get information stored on the GUI geometry_calib 1102 1103 grid_input=[];%default … … 1105 1106 end 1106 1107 [T,CalibData.grid,white_test]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T 1107 1108 1108 set(handles.geometry_calib,'UserData',CalibData)%store the phys grid parameters for later use 1109 1109 1110 % read the four last point coordinates in pixels1110 %% read the four last point coordinates in pixels 1111 1111 Coord_cell=get(handles.ListCoord,'String');%read list of coordinates on geometry_calib 1112 1112 data=read_geometry_calib(Coord_cell); 1113 1113 nbpoints=size(data.Coord,1); %nbre of calibration points 1114 1114 if 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') 1116 1116 return 1117 1117 end … … 1130 1130 end 1131 1131 1132 % read the current image, displayed in the GUI uvmat1132 %% read the current image, displayed in the GUI uvmat 1133 1133 huvmat=findobj(allchild(0),'Name','uvmat'); 1134 1134 UvData=get(huvmat,'UserData'); 1135 1135 A=UvData.Field.A; 1136 1136 npxy=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: 1137 X=[CalibData.grid.x_0 CalibData.grid.x_1 CalibData.grid.x_0 CalibData.grid.x_1]';%corner absissa in the phys coordinates (cm) 1138 Y=[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 1142 1141 % reference: http://alumni.media.mit.edu/~cwren/interpolator/ by Christopher R. Wren 1143 1142 B = [ X Y ones(size(X)) zeros(4,3) -X.*corners_X -Y.*corners_X ... … … 1146 1145 D = [ corners_X , corners_Y ]; 1147 1146 D = reshape (D', 8 , 1 ); 1148 %l = inv(B' * B) * B' * D;1149 1147 l = (B' * B)\B' * D; 1150 1148 Amat = reshape([l(1:6)' 0 0 1 ],3,3)'; 1151 1149 C = [l(7:8)' 1]; 1152 1150 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 1169 1152 GeometryCalib.fx_fy=[1 1]; 1170 1153 GeometryCalib.Tx_Ty_Tz=[Amat(1,3) Amat(2,3) 1]; 1171 1154 GeometryCalib.R=[Amat(1,1),Amat(1,2),0;Amat(2,1),Amat(2,2),0;C(1),C(2),0]; 1155 GeometryCalib.CoordUnit='cm'; 1172 1156 path_uvmat=which('uvmat');% check the path detected for source file uvmat 1173 1157 path_UVMAT=fileparts(path_uvmat); %path to UVMAT … … 1188 1172 Rangx=DataOut.AX; 1189 1173 Rangy=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 1203 1174 if white_test 1204 Amod=double(Amod);% will look for image maxima1175 Amod=double(Amod);%case of white grid markers: will look for image maxima 1205 1176 else 1206 Amod=-double(Amod);% will look for image minima1177 Amod=-double(Amod);%case of black grid markers: will look for image minima 1207 1178 end 1208 1179 % figure(12) %display corrected image … … 1210 1181 % image(Rangx,Rangy,uint8(255*Amod/Amax)) 1211 1182 1183 %% detection of local image extrema in each direction 1212 1184 Dx=(Rangx(2)-Rangx(1))/(npxy(2)-1); %x mesh in real space 1213 1185 Dy=(Rangy(2)-Rangy(1))/(npxy(1)-1); %y mesh in real space … … 1230 1202 x_shift=0; 1231 1203 y_shift=0; 1232 %if ind_x_max+2<=2*ind_range_x+1 && ind_x_max-2>=11233 1204 if ind_x_max+2<=numel(x_profile) && ind_x_max-2>=1 1234 1205 Atop=x_profile(ind_x_max-2:ind_x_max+2);
Note: See TracChangeset
for help on using the changeset viewer.