- Timestamp:
- Apr 14, 2014, 11:41:21 AM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_imadoc.m
r737 r738 22 22 end 23 23 end 24 % SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'25 % XmlFileName=[fullfile(RootPath,SubDirBase) '.xml'];%new convention: xml at the level of the image folder26 24 if ~exist(XmlFileName,'file') 27 25 XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.xml']; % old convention: xml inside the image folder, case of images or new civ files -
trunk/src/geometry_calib.m
r724 r738 50 50 % Edit the above text to modify the response to help geometry_calib 51 51 52 % Last Modified by GUIDE v2.5 29-Oct-2013 06:46:1052 % Last Modified by GUIDE v2.5 11-Apr-2014 23:10:57 53 53 54 54 % Begin initialization code - DO NOT edit … … 110 110 set(handles.Extrinsic,'Position',[1 Height-40-4-92-75 418 75])% rank 3 111 111 set(handles.PointLists,'Position',[1 Height-40-6-92-75-117 418 117]) % rank 4 112 set(handles.CheckEnableMouse,'Position',[3 Height-40-8-92-75-117-30 20330])% rank 5112 set(handles.CheckEnableMouse,'Position',[3 Height-40-8-92-75-117-30 180 30])% rank 5 113 113 set(handles.PLOT,'Position',[3 Height-394 120 30])% rank 6 114 114 set(handles.Copy,'Position',[151 Height-394 120 30])% rank 6 115 115 set(handles.CLEAR_PTS,'Position',[297 Height-394 120 30])% rank 6 116 116 set(handles.ClearLine,'Position',[297 Height-364 120 30])% rank 6 117 set(handles.CoordLine,'Position',[177 Height-364 120 30])% rank 6 117 118 set(handles.phys_title,'Position',[38 Height-426 125 20])% rank 7 118 119 set(handles.CoordUnit,'Position',[151 Height-426 120 30])% rank 7 … … 124 125 set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'}) 125 126 if exist('inputfile','var')&& ~isempty(inputfile) 126 struct.XmlInputFile=inputfile;127 % struct.XmlInputFile=inputfile; 127 128 [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(inputfile); 128 if ~strcmp(FileExt,'.xml') 129 inputfile=fullfile(RootPath,[SubDir '.xml']);%xml file corresponding to the input file 130 if ~exist(inputfile,'file')% case of civ files , removes the extension for subdir 131 inputfile=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); 132 if ~exist(inputfile,'file') 133 inputfile=[fullfile(RootPath,SubDir,RootFile) '.xml'];%old convention 134 if ~exist(inputfile,'file') 135 inputfile=''; 136 end 137 end 138 end 139 end 129 struct.XmlInputFile=find_imadoc(RootPath,SubDir,RootFile,FileExt); 130 % if ~strcmp(FileExt,'.xml') 131 % inputfile=fullfile(RootPath,[SubDir '.xml']);%xml file corresponding to the input file 132 % if ~exist(inputfile,'file')% case of civ files , removes the extension for subdir 133 % inputfile=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); 134 % if ~exist(inputfile,'file') 135 % inputfile=[fullfile(RootPath,SubDir,RootFile) '.xml'];%old convention 136 % if ~exist(inputfile,'file') 137 % inputfile=''; 138 % end 139 % end 140 % end 141 % end 140 142 set(handles.ListCoord,'Data',[]) 141 if exist( inputfile,'file')142 Heading=loadfile(handles, inputfile);% load data from the xml file143 if exist(struct.XmlInputFile,'file') 144 Heading=loadfile(handles,struct.XmlInputFile);% load data from the xml file 143 145 if isfield(Heading,'Campaign')&& ischar(Heading.Campaign) 144 146 struct.Campaign=Heading.Campaign; … … 214 216 215 217 %% display image with new calibration in the currently opened uvmat interface 216 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers 217 if ~isempty(hhh) 218 delete(hhh); 219 end 220 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points'); 221 if ~isempty(hhh) 222 delete(hhh); 223 end 224 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' 225 set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) 218 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image 226 219 UserData=get(handles.geometry_calib,'UserData'); 227 220 UserData.XmlInputFile=outputfile;%save the current xml file name 228 221 set(handles.geometry_calib,'UserData',UserData) 229 uvmat(' RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates222 uvmat('InputFileREFRESH_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates 230 223 PLOT_Callback(hObject, eventdata, handles) 231 Data=get(handles.ListCoord,'Data'); 232 Data(:,6)=zeros(size(Data,1),1); 233 Data(index,6)=-1;% indicate in the list the point with max deviation (possible mistake) 234 set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake) 235 figure(handles.geometry_calib) 236 set(handles.APPLY,'BackgroundColor',[1 0 0]) 224 set(handles.CoordLine,'string',num2str(index)) 225 Coord=get(handles.ListCoord,'Data'); 226 update_calib_marker(Coord(index,:)); %indicate the point with max deviations from phys coord to calibration 227 figure(handles.geometry_calib)% put the GUI geometry_calib in front 228 set(handles.APPLY,'BackgroundColor',[1 0 0]) % set APPLY button to red color 237 229 end 238 230 … … 338 330 %% store the calibration data, by default in the xml file of the currently displayed image 339 331 UvData=get(hhuvmat.uvmat,'UserData'); 340 NbSlice_j=1;%default341 ZStart=Z_plane;342 ZEnd=Z_plane;343 volume_scan='n';344 if isfield(UvData,'XmlData')345 if isfield(UvData.XmlData,'TranslationMotor')346 NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice;347 ZStart=UvData.XmlData.TranslationMotor.ZStart/10;348 ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10;349 volume_scan='y';350 end351 end332 % NbSlice_j=1;%default 333 % ZStart=Z_plane; 334 % ZEnd=Z_plane; 335 % volume_scan='n'; 336 % if isfield(UvData,'XmlData') 337 % if isfield(UvData.XmlData,'TranslationMotor') 338 % NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice; 339 % ZStart=UvData.XmlData.TranslationMotor.ZStart/10; 340 % ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10; 341 % volume_scan='y'; 342 % end 343 % end 352 344 353 345 answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';... … … 362 354 end 363 355 if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration 364 input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'}; 365 input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}]; 366 answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on'); 367 GeometryCalib.NbSlice=str2double(answer{5}); 368 GeometryCalib.VolumeScan=answer{6}; 369 if isempty(answer) 370 Z_plane=0; %default 371 else 372 Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice); 373 end 374 GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; 375 GeometryCalib.SliceAngle(:,3)=0; 376 GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise) 377 GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise) 378 GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})]; 379 GeometryCalib.RefractionIndex=str2double(answer{4}); 380 end 381 382 383 384 %------------------------------------------------------------------------ 385 % determine the parameters for a calibration by an affine function (rescaling and offset, no rotation) 356 msgbox_uvmat('CONFIRMATION',{['The current image series is assumed by default in the plane of the calib points z=' num2str(Z_plane) ] ; 'can be modified by MenuSetSlice in the upper bar menu of uvmat'}) 357 % input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'}; 358 % input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}]; 359 % answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on'); 360 % GeometryCalib.NbSlice=str2double(answer{5}); 361 % GeometryCalib.VolumeScan=answer{6}; 362 % if isempty(answer) 363 % Z_plane=0; %default 364 % else 365 % Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice); 366 % end 367 GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; 368 % GeometryCalib.SliceAngle(:,3)=0; 369 % GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise) 370 % GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise) 371 % GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})]; 372 % GeometryCalib.RefractionIndex=str2double(answer{4}); 373 end 374 375 %------------------------------------------------------------------------ 376 % --- determine the parameters for a calibration by an affine function (rescaling and offset, no rotation) 386 377 function GeometryCalib=calib_rescale(Coord,handles) 387 378 %------------------------------------------------------------------------ … … 401 392 402 393 %------------------------------------------------------------------------ 403 % determine the parameters for a calibration by a linear transform matrix (rescale and rotation) 404 405 394 % --- determine the parameters for a calibration by a linear transform matrix (rescale and rotation) 406 395 function GeometryCalib=calib_linear(Coord,handles) 407 396 %------------------------------------------------------------------------ … … 432 421 433 422 %------------------------------------------------------------------------ 434 % determine the tsai parameters for a view normal to the grid plane423 % --- determine the tsai parameters for a view normal to the grid plane 435 424 % NOT USED 436 425 function GeometryCalib=calib_normal(Coord,handles) … … 498 487 %------------------------------------------------------------------------ 499 488 function GeometryCalib=calib_3D_linear(Coord,handles) 500 %------------------------------------------------------------------ 489 %------------------------------------------------------------------------ 501 490 path_uvmat=which('uvmat');% check the path detected for source file uvmat 502 491 path_UVMAT=fileparts(path_uvmat); %path to UVMAT … … 708 697 % --- determine the rms of calibration error 709 698 function ErrorRms=error_calib(calib_param,Calib,Coord) 699 %------------------------------------------------------------------------ 710 700 %calib_param: vector of free calibration parameters (to optimise) 711 701 %Calib: structure of the given calibration parameters … … 734 724 ErrorRms=mean(ErrorRms); 735 725 736 % %------------------------------------------------------------------------737 % function XImage_Callback(hObject, eventdata, handles)738 % %------------------------------------------------------------------------739 % update_list(hObject, eventdata,handles)740 %741 % %------------------------------------------------------------------------742 % function YImage_Callback(hObject, eventdata, handles)743 % %------------------------------------------------------------------------744 % update_list(hObject, eventdata,handles)745 726 746 727 %------------------------------------------------------------------------ 747 728 % --- Executes on button press in STORE. 748 729 function STORE_Callback(hObject, eventdata, handles) 730 %------------------------------------------------------------------------ 749 731 Coord=get(handles.ListCoord,'Data'); 750 732 %Object=read_geometry_calib(Coord_cell); … … 761 743 RootPath=get(hhuvmat.RootPath,'String'); 762 744 RootFile=get(hhuvmat.RootFile,'String'); 763 filebase= fullfile(RootPath,RootFile);745 filebase=[fullfile(RootPath,RootFile) '~']; 764 746 while exist([filebase '.xml'],'file') 765 747 filebase=[filebase '~']; … … 778 760 set(handles.ListCoordFiles,'string',listfile); 779 761 end 780 set(handles.ListCoord,'Data',[]) 762 CLEAR_PTS_Callback(hObject, eventdata, handles)% clear the current list and point plots 781 763 782 764 % -------------------------------------------------------------------- … … 786 768 set(handles.ListCoord,'Data',[]) 787 769 PLOT_Callback(hObject, eventdata, handles) 788 789 %------------------------------------------------------------------------ 790 % --- Executes on button press in CLEAR. 770 update_calib_marker([]);%remove circle marker 771 set(handles.APPLY,'backgroundColor',[1 0 0])% set APPLY button to red color: no calibration wanted without points 772 set(handles.CheckEnableMouse,'value',1); %activate mouse to pick new points 773 774 %------------------------------------------------------------------------ 775 % --- Executes on button press in CLEAR LIST 791 776 function CLEAR_Callback(hObject, eventdata, handles) 792 777 %------------------------------------------------------------------------ … … 800 785 choice=get(handles.CheckEnableMouse,'Value'); 801 786 if choice 802 set(handles.CheckEnableMouse,'BackgroundColor',[1 1 0])803 787 huvmat=findobj(allchild(0),'tag','uvmat'); 804 788 if ishandle(huvmat) 805 789 hhuvmat=guidata(huvmat); 790 set(hhuvmat.MenuRuler,'checked','off')%desactivate ruler 806 791 if get(hhuvmat.CheckEditObject,'Value') 807 set(hhuvmat.CheckEditObject,'Value',0)808 uvmat('CheckEditObject_Callback',hhuvmat.CheckEditObject,[],hhuvmat)792 set(hhuvmat.CheckEditObject,'Value',0) 793 uvmat('CheckEditObject_Callback',hhuvmat.CheckEditObject,[],hhuvmat) 809 794 end 810 end 811 else 812 set(handles.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7]) 795 set(hhuvmat.MenuRuler,'checked','off')%desactivate ruler 796 end 813 797 end 814 798 … … 841 825 set(handles.ListCoord,'Data',Coord) 842 826 set(handles.APPLY,'BackgroundColor',[1 0 1]) 827 set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid spurious points 843 828 844 829 %------------------------------------------------------------------------ … … 858 843 set(handles.ListCoord,'Data',Coord) 859 844 set(handles.APPLY,'BackgroundColor',[1 0 1]) 845 set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid spurious points 860 846 861 847 % ----------------------------------------------------------------------- … … 1002 988 PLOT_Callback(hObject, eventdata, handles) 1003 989 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1004 1005 % figure(10) 1006 % hold off 1007 % imagesc(Amod) 1008 % hold on 1009 % plot(Tmod(:,1),Tmod(:,2),'+') 990 set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid spurious points 1010 991 1011 992 … … 1085 1066 PLOT_Callback(handles.geometry_calib, [], handles) 1086 1067 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1068 set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid modifications by default 1087 1069 1088 1070 % ----------------------------------------------------------------------- … … 1104 1086 loadfile(handles,fileinput) 1105 1087 end 1088 set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid modifications by default 1106 1089 1107 1090 % ----------------------------------------------------------------------- … … 1116 1099 listfile=[listfile;{inputfile}];%update the list of coord files 1117 1100 end 1118 set(handles.ListCoordFiles,' string',listfile);1101 set(handles.ListCoordFiles,'String',listfile); 1119 1102 1120 1103 … … 1243 1226 menu=get(h_menu_coord,'String'); 1244 1227 choice=get(h_menu_coord,'Value'); 1228 option=''; 1245 1229 if iscell(menu) 1246 1230 option=menu{choice}; 1247 else1248 option='px'; %default1249 1231 end 1250 1232 Coord=get(handles.ListCoord,'Data'); … … 1252 1234 if isequal(option,'phys') 1253 1235 Coord_plot=Coord(:,1:3); 1254 elseif ise qual(option,'px')||isequal(option,'')1236 elseif isempty(option);%optionoption,'px')||isequal(option,'') 1255 1237 Coord_plot=Coord(:,4:5); 1256 1238 else 1257 msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank , pxor phys ')1239 msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank or phys ') 1258 1240 end 1259 1241 end … … 1290 1272 if ~isempty(eventdata.Indices) 1291 1273 iline=eventdata.Indices(1);% selected line number 1292 Data=get(handles.ListCoord,'Data'); 1293 Data(:,6)=zeros(size(Data,1),1); 1294 Data(iline,6)=-1;% mark the selected line 1295 set(handles.ListCoord,'Data',Data) 1296 update_calib_marker(Data(iline,:)) 1274 set(handles.CoordLine,'String',num2str(iline)) 1275 Data=get(handles.ListCoord,'Data'); 1276 update_calib_marker(Data(iline,:)) 1297 1277 end 1298 1278 … … 1316 1296 %------------------------------------------------------------------------ 1317 1297 function ListCoord_KeyPressFcn(hObject, eventdata, handles) 1298 iline=str2num(get(handles.CoordLine,'String')); 1318 1299 xx=double(get(handles.geometry_calib,'CurrentCharacter'));%get the keyboard character 1319 if ismember(xx,[ 30 31 127])% arrow upward, downward, or delete1300 if ismember(xx,[28 29 30 31])% directional arrow 1320 1301 Coord=get(handles.ListCoord,'Data'); 1321 ind=find(Coord(:,6));%find the marker '+' for line selection1322 Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark1323 1302 switch xx 1324 1303 case 30 % arrow upward 1325 Coord(ind-1,6)=1;1304 iline=iline-1; 1326 1305 case 31% arrow downward 1327 Coord(ind+1,6)=1; 1328 case 127% remove line 1329 Coord(ind,:)=[]; 1330 PLOT_Callback(hObject,eventdata,handles) 1331 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1332 otherwise 1333 end 1334 set(handles.ListCoord,'Data',Coord); 1306 iline=iline+1; 1307 end 1308 if iline>=1 && iline<=size(Coord,1) 1309 set(handles.CoordLine,'String',num2str(iline)) 1310 update_calib_marker(Coord(iline,1:5))% show the point corresponding to the selected line 1311 end 1335 1312 else 1336 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1313 set(handles.APPLY,'BackgroundColor',[1 0 1])% paint APPLY in magenta to indicate that the table content has be modified 1337 1314 end 1338 1315 … … 1341 1318 % --- update the plot of calibration points 1342 1319 %------------------------------------------------------------------------ 1320 % draw a circle around the point defined by the input coordinates Coord as given by line in the table Listcoord 1343 1321 function update_calib_marker(Coord) 1344 %% update the plot on uvmat 1322 1323 %% read config on uvmat 1345 1324 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle 1346 hplot=findobj(huvmat,'Tag','PlotAxes');%main plotting axis of uvmat 1347 hhh=findobj(hplot,'Tag','calib_marker'); 1348 1349 h_menu_coord=findobj(huvmat,'Tag','TransformName'); 1350 menu=get(h_menu_coord,'String'); 1351 choice=get(h_menu_coord,'Value'); 1325 hhuvmat=guidata(huvmat); 1326 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker'); 1327 if numel(Coord)<5 1328 if ~isempty(hhh) 1329 delete(hhh)%delete the circle marker in case of no valid input 1330 end 1331 return 1332 end 1333 menu=get(hhuvmat.TransformName,'String'); 1334 choice=get(hhuvmat.TransformName,'Value'); 1335 option=''; 1352 1336 if iscell(menu) 1353 1337 option=menu{choice}; 1354 e lse1355 option='px'; %default 1356 end1357 if isequal(option,'phys') 1338 end 1339 1340 %% read appropriate coordinates (px or phys) in the table ListCoord 1341 if isequal(option,'phys') % use phys coord 1358 1342 XCoord=Coord(1); 1359 1343 YCoord=Coord(2); 1360 elseif ise qual(option,'px')|| isequal(option,'')1344 elseif isempty(option)% use coord in pixels 1361 1345 XCoord=Coord(4); 1362 1346 YCoord=Coord(5); 1363 1347 else 1364 msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank, px or phys ') 1365 end 1366 if isempty(XCoord)||isempty(YCoord) 1367 if ~isempty(hhh) 1368 delete(hhh)%delete the circle marker 1369 end 1348 msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank or phys ') 1370 1349 return 1371 1350 end 1372 xlim=get(hplot,'XLim'); 1373 ylim=get(hplot,'YLim'); 1374 ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/20;%defines the size of the circle marker 1351 1352 %% adjust the plot limits if needed 1353 xlim=get(hhuvmat.PlotAxes,'XLim'); 1354 ylim=get(hhuvmat.PlotAxes,'YLim'); 1355 ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/25;%defines the size of the circle marker 1356 check_xlim=0; 1357 if XCoord>xlim(2) 1358 xlim=xlim+XCoord-xlim(2)+ind_range;% translate plot limit 1359 check_xlim=1; 1360 elseif XCoord<xlim(1) 1361 xlim=xlim-XCoord+xlim(1)-ind_range;% translate plot limit 1362 check_xlim=1; 1363 end 1364 if check_xlim 1365 set(hhuvmat.PlotAxes,'XLim',xlim); 1366 set(hhuvmat.num_MaxX,'String',num2str(xlim(2))); 1367 set(hhuvmat.num_MinX,'String',num2str(xlim(1))); 1368 end 1369 check_ylim=0; 1370 if YCoord>ylim(2) 1371 ylim=ylim+YCoord-ylim(2)+ind_range;% translate plot limit 1372 check_ylim=1; 1373 elseif YCoord<ylim(1) 1374 ylim=ylim-YCoord+ylim(1)-ind_range;% translate plot limit 1375 check_ylim=1; 1376 end 1377 if check_ylim 1378 set(hhuvmat.PlotAxes,'YLim',ylim); 1379 set(hhuvmat.num_MaxY,'String',num2str(ylim(2))); 1380 set(hhuvmat.num_MinY,'String',num2str(ylim(1))); 1381 end 1382 1383 %% plot a circle around the selected point 1375 1384 if isempty(hhh) 1376 1385 set(0,'CurrentFig',huvmat) 1377 set(huvmat,'CurrentAxes',h plot)1386 set(huvmat,'CurrentAxes',hhuvmat.PlotAxes) 1378 1387 rectangle('Curvature',[1 1],... 1379 1380 1388 'Position',[XCoord-ind_range/2 YCoord-ind_range/2 ind_range ind_range],'EdgeColor','m',... 1389 'LineStyle','-','Tag','calib_marker'); 1381 1390 else 1382 1391 set(hhh,'Position',[XCoord-ind_range/2 YCoord-ind_range/2 ind_range ind_range]) … … 1389 1398 1390 1399 Coord=get(handles.ListCoord,'Data'); 1391 i nd=find(Coord(:,6));%find the marker '-' for line selection1392 if isempty(i nd)1400 iline=str2num(get(handles.CoordLine,'String')); 1401 if isempty(iline) 1393 1402 msgbox_uvmat('WARNING','no line suppressed, select a line in the table') 1394 1403 else 1395 answer=msgbox_uvmat('INPUT_Y-N',['suppress line ' num2str(i nd) '?']);1404 answer=msgbox_uvmat('INPUT_Y-N',['suppress line ' num2str(iline) '?']); 1396 1405 if isequal(answer,'Yes') 1397 Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark 1398 Coord(ind,:)=[]; 1399 PLOT_Callback(hObject,eventdata,handles) 1400 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1401 set(handles.ListCoord,'Data',Coord); 1402 end 1403 end 1406 Coord(iline,:)=[]; 1407 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1408 set(handles.ListCoord,'Data',Coord); 1409 set(handles.CoordLine,'String','') 1410 PLOT_Callback(hObject,eventdata,handles) 1411 update_calib_marker([]);%remove circle marker 1412 end 1413 end 1414 -
trunk/src/mouse_motion.m
r714 r738 403 403 if isnumeric(data.Coord)&&~isempty(data.Coord) 404 404 if test_transform 405 406 YCoord=(data.Coord(:,2));405 XCoord=(data.Coord(:,1)); 406 YCoord=(data.Coord(:,2)); 407 407 else 408 XCoord=(data.Coord(:,4));409 YCoord=(data.Coord(:,5));408 XCoord=(data.Coord(:,4)); 409 YCoord=(data.Coord(:,5)); 410 410 end 411 411 xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 412 412 if ~isempty(xy) 413 413 xlim=get(CurrentAxes,'XLim'); 414 ind_range_x=abs((xlim(2)-xlim(1))/50);414 % ind_range_x=abs((xlim(2)-xlim(1))/50); 415 415 ylim=get(CurrentAxes,'YLim'); 416 ind_range_y=abs((ylim(2)-ylim(1))/50); 417 ind_range=sqrt(ind_range_x*ind_range_y); 418 index_point=find((XCoord<xy(1,1)+ind_range) & (XCoord>xy(1,1)-ind_range) & ...%flagx=1 for the vectors with x position selected by the mouse 419 (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse 416 ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/25;%defines the size of the circle marker 417 % ind_range_y=abs((ylim(2)-ylim(1))/50); 418 % ind_range=sqrt(ind_range_x*ind_range_y); 419 index_point=find((XCoord<xy(1,1)+ind_range/2) & (XCoord>xy(1,1)-ind_range/2) & ...%flagx=1 for the vectors with x position selected by the mouse 420 (YCoord<xy(1,2)+ind_range/2) & (YCoord>xy(1,2)-ind_range/2),1);%find the first calibration point in the neighborhood of the mouse 420 421 if ~isempty(index_point) 421 pointershape='arrow';% default pointer is an arrow 422 pointershape='arrow';% default pointer is an arrow 422 423 end 423 424 hh=findobj('Tag','calib_points');%look for handle of calibration points 424 if ~isempty(hh) && ~isempty(get(hh,'UserData')) %&& get(hh_geometry_calib.CheckEnableMouse,'Value')425 %set(hh,'UserData',index_point)425 if ~isempty(hh) && ~isempty(get(hh,'UserData')) %&& get(hh_geometry_calib.CheckEnableMouse,'Value') 426 %set(hh,'UserData',index_point) 426 427 index_point=get(hh,'UserData'); 427 428 XCoord(index_point)=xy(1,1); … … 429 430 set(hh,'XData',XCoord) 430 431 set(hh,'YData',YCoord) 431 end432 end 432 433 if ~isempty(index_point) 433 Data=get(h_ListCoord,'Data'); 434 Data(:,6)=zeros(size(Data,1),1); 435 Data(index_point,6)=-1;%mrk the point on the GUI geometry_calib 436 set(h_ListCoord,'Data',Data); 434 set(hh_geometry_calib.CoordLine,'String',num2str(index_point)) 435 % Data=get(h_ListCoord,'Data'); 436 % Data(:,6)=zeros(size(Data,1),1); 437 % Data(index_point,6)=-1;%mrk the point on the GUI geometry_calib 438 % set(h_ListCoord,'Data',Data); 437 439 hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle) 438 440 if ~isempty(hhh) 439 441 set(hhh,'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range]) 440 442 else 441 442 'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',...443 'LineStyle','-','Tag','calib_marker');443 rectangle('Curvature',[1 1],... 444 'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range],'EdgeColor','m',... 445 'LineStyle','-','Tag','calib_marker'); 444 446 end 445 447 end -
trunk/src/mouse_up.m
r714 r738 349 349 %% finalising ruler 350 350 if test_ruler && ~isempty(xy) 351 set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat351 %set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat 352 352 xy=get(hcurrentaxes,'CurrentPoint');% get the current mouse coordinates 353 353 RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates -
trunk/src/proj_field.m
r735 r738 920 920 921 921 %% extrema along each axis 922 testXMin=0; 923 testXMax=0; 924 testYMin=0; 925 testYMax=0; 926 if isfield(ObjectData,'RangeX') 922 testXMin=0;% test if min of X coordinates defined on the projection object, =0 by default 923 testXMax=0;% test if max of X coordinates defined on the projection object, =0 by default 924 testYMin=0;% test if min of Y coordinates defined on the projection object, =0 by default 925 testYMax=0;% test if max of Y coordinates defined on the projection object, =0 by default 926 if isfield(ObjectData,'RangeX') % rangeX defined by the projection object 927 927 XMin=min(ObjectData.RangeX); 928 928 XMax=max(ObjectData.RangeX); 929 testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has t owdistinct elements)930 testXMax=1;% range restriction along X931 end 932 if isfield(ObjectData,'RangeY') 929 testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has two distinct elements) 930 testXMax=1;% max of X coordinates defined on the projection object 931 end 932 if isfield(ObjectData,'RangeY') % rangeY defined by the projection object 933 933 YMin=min(ObjectData.RangeY); 934 934 YMax=max(ObjectData.RangeY); 935 935 testYMin=YMax>YMin;%=1 if YMin defined (i.e. RangeY has tow distinct elements) 936 testYMax=1; 936 testYMax=1;% max of Y coordinates defined on the projection object 937 937 end 938 938 width=0;%default width of the projection band … … 1371 1371 end 1372 1372 end 1373 else % case with interpolation 1373 else % case with interpolation on a grid 1374 1374 if NbDim==2 %2D case 1375 1375 if isequal(ProjMode{icell},'interp_tps') … … 1383 1383 Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)}); 1384 1384 Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)}); 1385 xcorner=[min(Coord{NbDim}) max(Coord{NbDim}) max(Coord{NbDim}) min(Coord{NbDim})]-ObjectData.Coord(1,1);% corner absissa of the original grid with respect to the new origin 1386 ycorner=[min(Coord{NbDim-1}) min(Coord{NbDim-1}) max(Coord{NbDim-1}) max(Coord{NbDim-1})]-ObjectData.Coord(1,2);% corner ordinates of the original grid 1387 xcor_new=xcorner*cos(PlaneAngle(3))+ycorner*sin(PlaneAngle(3));%coordinates of the corners in new frame 1388 ycor_new=-xcorner*sin(PlaneAngle(3))+ycorner*cos(PlaneAngle(3)); 1389 if testXMin 1390 xcor_new=max(xcor_new,XMin); 1391 end 1392 if testXMax 1393 xcor_new=min(xcor_new,XMax); 1394 end 1395 if testYMin 1396 ycor_new=max(ycor_new,YMin); 1397 end 1398 if testYMax 1399 ycor_new=min(ycor_new,YMax); 1400 end 1401 coord_x_proj=min(xcor_new):DX:max(xcor_new); 1402 coord_y_proj=min(ycor_new):DY:max(ycor_new); 1385 if ~(testXMin && testYMin)% % if the range of the projected coordinates is not fully defined by the projection object, find the extrema of the projected field 1386 xcorner=[min(Coord{NbDim}) max(Coord{NbDim}) max(Coord{NbDim}) min(Coord{NbDim})]-ObjectData.Coord(1,1);% corner absissa of the original grid with respect to the new origin 1387 ycorner=[min(Coord{NbDim-1}) min(Coord{NbDim-1}) max(Coord{NbDim-1}) max(Coord{NbDim-1})]-ObjectData.Coord(1,2);% corner ordinates of the original grid 1388 xcor_new=xcorner*cos(PlaneAngle(3))+ycorner*sin(PlaneAngle(3));%coordinates of the corners in new frame 1389 ycor_new=-xcorner*sin(PlaneAngle(3))+ycorner*cos(PlaneAngle(3)); 1390 if ~testXMin 1391 XMin=min(xcor_new); 1392 end 1393 if ~testXMax 1394 XMax=max(xcor_new); 1395 end 1396 if ~testYMin 1397 YMin=min(ycor_new); 1398 end 1399 if ~testYMax 1400 YMax=max(ycor_new); 1401 end 1402 end 1403 coord_x_proj=XMin:DX:XMax; 1404 coord_y_proj=YMin:DY:YMax; 1403 1405 ProjData.(AYName)=[coord_y_proj(1) coord_y_proj(end)]; %record the new (projected ) y coordinates 1404 1406 ProjData.(AXName)=[coord_x_proj(1) coord_x_proj(end)]; %record the new (projected ) x coordinates -
trunk/src/set_object.m
r729 r738 36 36 function varargout = set_object(varargin) 37 37 38 % Last Modified by GUIDE v2.5 1 1-Feb-2014 20:08:1738 % Last Modified by GUIDE v2.5 13-Apr-2014 19:31:58 39 39 40 40 % Begin initialization code - DO NOT REFRESH … … 594 594 set(handles.num_RangeY_2,'BackgroundColor',[1 1 1]) 595 595 596 %------------------------------------------------------------------------ 597 % --- Executes on button press in MenuCoord. 598 function MenuCoord_Callback(hObject, eventdata, handles) 599 %------------------------------------------------------------------------ 596 % --- Executes on button press in ExportCoord. 597 function ExportCoord_Callback(hObject, eventdata, handles) 598 global Coord 599 Coord=get(handles.Coord,'Data'); 600 evalin('base','global Coord')%make Coord global in the workspace 601 display('object coordinates:') 602 evalin('base','Coord') %display Coord in the workspace 603 commandwindow; %brings the Matlab command window to the front 604 600 605 %---------------------------------------------------- 601 606 function num_RangeY_1_Callback(hObject, eventdata, handles) … … 785 790 set(handles.Coord,'Data',Coord); 786 791 end 792 793 794 795 -
trunk/src/uvmat.m
r735 r738 3811 3811 3812 3812 %% delete drawn objects if the output CooordUnit is different from the previous one 3813 if ~strcmp(CoordUnit,CoordUnitPrev)3813 if ~strcmp(CoordUnit,CoordUnitPrev) 3814 3814 set(handles.CheckFixLimits,'Value',0) 3815 % set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])3816 3815 hother=findobj('Tag','proj_object');%find all the proj objects 3817 3816 for iobj=1:length(hother) … … 4544 4543 UvData.ProjObject(IndexObj)=[]; 4545 4544 end 4546 if ~isempty(list_str) 4547 list_str(IndexObj)=[]; 4548 end 4549 % end 4545 if numel(list_str)>=IndexObj 4546 list_str(IndexObj)=[]; 4547 end 4550 4548 set(huvmat,'UserData',UvData); 4551 4549 set(hlist_object,'String',list_str) … … 4837 4835 %------------------------------------------------------------------------ 4838 4836 %% desactivate concurrent tools 4837 set(handles.MenuRuler,'checked','off')%desactivate ruler 4839 4838 hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');% search the GUI geometric calibration 4840 4839 if ishandle(hgeometry_calib) … … 4945 4944 function MenuCalib_Callback(hObject, eventdata, handles) 4946 4945 %------------------------------------------------------------------------ 4947 4946 %% suppress the second field if exists 4947 if get(handles.SubField,'Value') 4948 set(handles.SubField,'Value',0) 4949 SubField_Callback(hObject, eventdata, handles) 4950 end 4948 4951 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4949 4952 4950 %suppress competing options 4953 %% suppress competing tools 4954 set(handles.MenuRuler,'checked','off')%desactivate ruler 4951 4955 set(handles.CheckZoom,'Value',0) 4952 4956 set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) 4953 set(handles.ListObject,'Value',1) 4954 % initiate display of GUI geometry_calib 4957 set(handles.ListObject,'Value',1) 4958 4959 %% initiate display of the GUI geometry_calib 4955 4960 data=[]; %default 4956 4961 if isfield(UvData,'CoordType') … … 4964 4969 set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action 4965 4970 4971 4972 % -------------------------------------------------------------------- 4973 % --- set the slice plane ro the set of slice planes when volume scan is used 4974 function MenuSetSlice_Callback(hObject, eventdata, handles) 4975 % -------------------------------------------------------------------- 4976 %% suppress the second input field if exists 4977 if get(handles.SubField,'Value') 4978 set(handles.SubField,'Value',0) 4979 SubField_Callback(hObject, eventdata, handles) 4980 end 4981 4982 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4983 check=0; 4984 if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'GeometryCalib')&& isfield(UvData.XmlData{1}.GeometryCalib,'SliceCoord') 4985 GeometryCalib=UvData.XmlData{1}.GeometryCalib; 4986 SliceCoord=GeometryCalib.SliceCoord; 4987 else 4988 msgbox_uvmat('ERROR','3D geometric calibration needed before defining slices') 4989 return 4990 end 4991 NbSlice_j=1;%default 4992 Z=SliceCoord(:,3); 4993 % index=index(ind_dim); 4994 %set the Z position of the reference plane used for calibration 4995 if isequal(max(Z),min(Z))%Z constant 4996 Z_plane=Z(1); 4997 GeometryCalib.NbSlice=1; 4998 GeometryCalib.SliceCoord=[0 0 Z_plane]; 4999 end 5000 ZStart=SliceCoord(1,3);% first Z coordinate present in the calibration file 5001 ZEnd=SliceCoord(end,3);% last Z coordinate present in the calibration file 5002 volume_scan='n'; 5003 if isfield(UvData,'XmlData') 5004 if isfield(UvData.XmlData{1},'TranslationMotor') 5005 NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice; 5006 ZStart=UvData.XmlData.TranslationMotor.ZStart/10; 5007 ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10; 5008 volume_scan='y'; 5009 end 5010 end 5011 input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'}; 5012 input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}]; 5013 answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on'); 5014 GeometryCalib.NbSlice=str2double(answer{5}); 5015 GeometryCalib.VolumeScan=answer{6}; 5016 if isempty(answer) 5017 Z_plane=0; %default 5018 else 5019 Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice); 5020 end 5021 GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; 5022 GeometryCalib.SliceAngle(:,3)=0; 5023 GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise) 5024 GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise) 5025 GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})]; 5026 GeometryCalib.RefractionIndex=str2double(answer{4}); 5027 5028 %% store the result in the xml file used for calibration 5029 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 5030 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%name of the xml file for calibration 5031 [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(FileName); 5032 XmlFile=find_imadoc(RootPath,SubDir,RootFile,FileExt); 5033 errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file 5034 if ~strcmp(errormsg,'') 5035 msgbox_uvmat('ERROR',errormsg); 5036 end 5037 5038 %% display image with new calibration in the currently opened uvmat interface 5039 set(handles.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image 5040 InputFileREFRESH_Callback(hObject,eventdata,handles); %file input with xml reading in uvmat, show the image in phys coordinates 4966 5041 4967 5042 %----------------------------------------------------------------------- … … 5234 5309 function MenuRuler_Callback(hObject, eventdata, handles) 5235 5310 %------------------------------------------------------------------------ 5236 set(handles.CheckZoom,'Value',0) 5237 CheckZoom_Callback(handles.uvmat, [], handles) 5238 set(handles.MenuRuler,'checked','on') 5239 UvData=get(handles.uvmat,'UserData'); 5240 UvData.MouseAction='ruler'; 5241 set(handles.uvmat,'UserData',UvData); 5311 if strcmp(get(handles.MenuRuler,'checked'),'on') 5312 set(handles.MenuRuler,'checked','off')%desactivate if activated 5313 else 5314 set(handles.MenuRuler,'checked','on')%activate if selected 5315 set(handles.CheckZoom,'Value',0) 5316 CheckZoom_Callback(handles.uvmat, [], handles) 5317 UvData=get(handles.uvmat,'UserData'); 5318 UvData.MouseAction='ruler'; 5319 set(handles.uvmat,'UserData',UvData); 5320 end 5242 5321 5243 5322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 5453 5532 end 5454 5533 5455 5534 % -------------------------------------------------------------------- 5456 5535 % --- Executes on button press in CheckTable. 5536 % -------------------------------------------------------------------- 5457 5537 function CheckTable_Callback(hObject, eventdata, handles) 5458 5538 if get(handles.CheckTable,'Value')
Note: See TracChangeset
for help on using the changeset viewer.