source: trunk/src/geometry_calib.m @ 12

Last change on this file since 12 was 12, checked in by gostiaux, 11 years ago

The files from uvmat.2.2.beta that differed from the current version have been updated.
Now the /raid/soft/UVMAT/src should be operational

File size: 39.2 KB
Line 
1%'geometry_calib': performs geometric calibration from a set of reference points
2%
3% function varargout = geometry_calib(varargin)
4%
5%A%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
6%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
7%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
8%     This file is part of the toolbox UVMAT.
9%
10%     UVMAT is free software; you can redistribute it and/or modify
11%     it under the terms of the GNU General Public License as published by
12%     the Free Software Foundation; either version 2 of the License, or
13%     (at your option) any later version.
14%
15%     UVMAT is distributed in the hope that it will be useful,
16%     but WITHOUT ANY WARRANTY; without even the implied warranty of
17%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
19%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
20
21function varargout = geometry_calib(varargin)
22% GEOMETRY_CALIB M-file for geometry_calib.fig
23%      GEOMETRY_CALIB, by itself, creates a MenuCoord GEOMETRY_CALIB or raises the existing
24%      singleton*.
25%
26%      H = GEOMETRY_CALIB returns the handle to a MenuCoord GEOMETRY_CALIB or the handle to
27%      the existing singleton*.
28%
29%      GEOMETRY_CALIB('CALLBACK',hObject,eventData,handles,...) calls the local
30%      function named CALLBACK in GEOMETRY_CALIB.M with the given input arguments.
31%
32%      GEOMETRY_CALIB('Property','Value',...) creates a MenuCoord GEOMETRY_CALIB or raises the
33%      existing singleton*.  Starting from the left, property value pairs are
34%      applied to the GUI before geometry_calib_OpeningFunction gets called.  An
35%      unrecognized property name or invalid value makes property application
36%      stop.  All inputs are passed to geometry_calib_OpeningFcn via varargin.
37%
38%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
39%      instance to run (singleton)".
40%
41% See also: GUIDE, GUIDATA, GUIHANDLES
42
43% Edit the above text to modify the response to help geometry_calib
44
45% Last Modified by GUIDE v2.5 05-Jan-2010 23:22:04
46
47% Begin initialization code - DO NOT edit
48gui_Singleton = 1;
49gui_State = struct('gui_Name',       mfilename, ...
50                   'gui_Singleton',  gui_Singleton, ...
51                   'gui_OpeningFcn', @geometry_calib_OpeningFcn, ...
52                   'gui_OutputFcn',  @geometry_calib_OutputFcn, ...
53                   'gui_LayoutFcn',  [] , ...
54                   'gui_Callback',   []);
55if nargin & isstr(varargin{1})
56    gui_State.gui_Callback = str2func(varargin{1});
57end
58
59if nargout
60    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
61else
62    gui_mainfcn(gui_State, varargin{:});
63end
64% End initialization code - DO NOT edit
65
66
67% --- Executes just before geometry_calib is made visible.
68%INPUT:
69%handles: handles of the geometry_calib interface elements
70% PlotHandles: set of handles of the elements contolling the plotting
71% parameters on the uvmat interface (obtained by 'get_plot_handle.m')
72function geometry_calib_OpeningFcn(hObject, eventdata, handles, handles_uvmat,pos,inputfile)
73
74% Choose default command line output for geometry_calib
75handles.output = hObject;
76
77% Update handles structure
78guidata(hObject, handles);
79movegui(hObject,'east');% position the GUI ton the right of the screen
80if exist('handles_uvmat','var') %& isfield(data,'ParentButton')
81     set(hObject,'DeleteFcn',{@closefcn,handles_uvmat})%
82end
83%set the position of the interface
84if exist('pos','var')& length(pos)>2
85    pos_gui=get(hObject,'Position');
86    pos_gui(1)=pos(1);
87    pos_gui(2)=pos(2);
88    set(hObject,'Position',pos_gui);
89end
90inputxml='';
91if exist('inputfile','var')& ~isempty(inputfile)
92    [Path,Name,ext]=fileparts(inputfile);
93    form=imformats(ext([2:end]));
94    if ~isempty(form)% if the input file is an image
95        struct.XmlInputfile=inputfile;
96        set(hObject,'UserData',struct)
97        [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(inputfile);
98        inputxml=[fullfile(Pathsub,RootFile) '.xml'];
99    end   
100end
101set(handles.ListCoord,'String',{''})
102if exist(inputxml,'file')
103    loadfile(handles,inputxml)% load the point coordiantes existing in the xml file
104end
105
106set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
107%set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function on uvmat interface when geometry_calib is on top
108%htable=uitable(10,5)
109%set(htable,'ColumnNames',{'x','y','z','X(pixels)','Y(pixels)'})
110
111% --- Outputs from this function are returned to the command line.
112function varargout = geometry_calib_OutputFcn(hObject, eventdata, handles)
113% varargout  cell array for returning output args (see VARARGOUT);
114% hObject    handle to figure
115% eventdata  reserved - to be defined in a future version of MATLAB
116% handles    structure with handles and user data (see GUIDATA)
117
118% Get default command line output from handles structure
119varargout{1} = handles.output;
120varargout{2}=handles;
121
122%------------
123function Phi_Callback(hObject, eventdata, handles)
124
125
126
127
128%--------------------------------------------------
129%read input xml file and update the edit boxes
130function loadfile(handles,fileinput)
131
132%read the input xml file
133t=xmltree(fileinput);
134s=convert(t);%convert to matlab structure
135%read data currently displayed on the interface
136PointCoord=[];
137Coord_cell=get(handles.ListCoord,'String');
138data=read_geometry_calib(Coord_cell);
139%data=read_geometry_calib(handles);
140Coord=[]; %default
141if isfield(data,'Coord')
142    Coord=data.Coord;
143end
144TabChar_0=get(handles.ListCoord,'String');
145nbcoord_0=size(TabChar_0,1);
146if isequal(get(handles.edit_append,'Value'),2) %edit mode  A REVOIR
147    val=get(handles.ListCoord,'Value')-1;
148else
149   val=length(TabChar_0);
150end
151nbcoord=0;
152
153%case of calibration (ImaDoc) input file
154hcalib=get(handles.calib_type,'parent');
155CalibData=get(hcalib,'UserData');
156CalibData.XmlInput=fileinput;
157if isfield(s,'Heading')
158    CalibData.Heading=s.Heading;
159end
160
161set(hcalib,'UserData',CalibData);%store the heading in the interface 'UserData'
162if isfield(s,'GeometryCalib')
163    Calib=s.GeometryCalib;
164    if isfield(Calib,'CalibrationType')
165        CalibrationType=Calib.CalibrationType;
166        switch CalibrationType
167            case 'linear'
168                set(handles.calib_type,'Value',2)
169            case 'tsai'
170                set(handles.calib_type,'Value',3)
171        end
172    end
173    if isfield(Calib,'SourceCalib')
174        if isfield(Calib.SourceCalib,'PointCoord')
175            PointCoord=Calib.SourceCalib.PointCoord;
176        end
177    end
178    nbcoord=length(PointCoord);
179    if ~isfield(Calib,'ErrorRms')&~isfield(Calib,'ErrorMax') %old convention of Gauthier (cord in mm)
180        for i=1:length(PointCoord)
181          line=str2num(PointCoord{i});
182          Coord(i+val,4:5)=line(4:5);%px x
183          Coord(i+val,1:3)=line(1:3)/10;%phys x
184        end
185    else
186        for i=1:length(PointCoord)
187          line=str2num(PointCoord{i});
188          Coord(i,4:5)=line(4:5);%px x
189          Coord(i,1:3)=line(1:3);%phys x
190       end
191    end
192end
193%case of xml files of points
194if isfield(s,'Coord')
195    PointCoord=s.Coord;
196    nbcoord=length(PointCoord);
197     %case of image coordinates
198    if isfield(s,'CoordType')& isequal(s.CoordType,'px')
199        for i=1:nbcoord
200           line=str2num(PointCoord{i});
201           Coord(i+val,4:5)=line(1:2);
202        end
203     %case of  physical coordinates
204    else
205        for i=1:nbcoord
206           line=str2num(PointCoord{i});
207           Coord(i+val,1:3)=line(1:3);
208           nbcolumn=size(Coord,2);
209           if nbcolumn<5
210               Coord(i+val,nbcolumn+1:5)=zeros(1,5-nbcolumn);
211           end
212        end
213     end
214end
215CoordCell={};
216for iline=1:size(Coord,1)
217    for j=1:5
218        CoordCell{iline,j}=num2str(Coord(iline,j),4);
219    end
220end       
221Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
222set(handles.ListCoord,'Value',1)
223set(handles.ListCoord,'String',Tabchar)
224
225
226%----------------------------------------------------
227% executed when closing: set the parent interface button to value 0
228function closefcn(gcbo,eventdata,handles_uvmat)
229huvmat=findobj(allchild(0),'Name','uvmat');
230if exist('handles_uvmat','var')
231    set(handles_uvmat.cal,'Value',0)
232    uvmat('cal_Callback',huvmat,[],handles_uvmat);
233%     set(parent_button,'Value',0)%put unactivated buttons to green
234%     set(parent_button,'BackgroundColor',[0 1 0]);
235end
236
237
238% % --- Executes on button press in MenuCoord.
239% function MenuCoord_Callback(hObject, eventdata, handles)
240
241%
242% % --- Executes on button press in delete.
243% function delete_Callback(hObject, eventdata, handles)
244% SetData=get(gcbf,'UserData');%get the interface data
245% IndexObj=SetData.IndexObj;
246% delete_object(IndexObj);
247
248
249%------------------------------------------------------------------
250% --- Executes on button press in calibrate_lin.
251function APPLY_Callback(hObject, eventdata, handles)
252%------------------------------------------------------------------
253calib_cell=get(handles.calib_type,'String');
254val=get(handles.calib_type,'Value');
255calib_type=calib_cell{val};
256Coord_cell=get(handles.ListCoord,'String');
257Object=read_geometry_calib(Coord_cell);
258
259if isequal(calib_type,'rescale')
260    GeometryCalib=calib_rescale(Object.Coord);
261elseif isequal(calib_type,'linear')
262    GeometryCalib=calib_linear(Object.Coord);
263elseif isequal(calib_type,'tsai')
264    GeometryCalib=calib_tsai(Object.Coord);
265end
266unitlist=get(handles.CoordUnit,'String');
267unit=unitlist{get(handles.CoordUnit,'value')};
268GeometryCalib.CoordUnit=unit;
269
270huvmat=findobj(allchild(0),'Name','uvmat');
271hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
272RootPath='';
273RootFile='';
274if ~isempty(hhuvmat.RootPath)& ~isempty(hhuvmat.RootFile)
275    testhandle=1;
276    RootPath=get(hhuvmat.RootPath,'String');
277    RootFile=get(hhuvmat.RootFile,'String');
278    filebase=fullfile(RootPath,RootFile);
279    outputfile=[filebase '.xml'];
280else
281    question={'save the calibration data and point coordinates in'};
282    def={fullfile(RootPath,['ObjectCalib.xml'])};
283    options.Resize='on';
284    answer=inputdlg(question,'save average in a new file',1,def,options);
285    outputfile=answer{1};
286end
287testappend=0;
288if exist(outputfile,'file');%=1 if the output file already exists, 0 else
289    t=xmltree(outputfile); %read the file
290    backupfile=outputfile;
291    testexist=2;
292    while testexist==2
293        backupfile=[backupfile '~'];% make a backup name by adding  ~ to the xml file name
294        testexist=exist(backupfile,'file');
295    end
296    [success,message]=copyfile(outputfile,backupfile);%make backup   
297    t=xmltree(outputfile); %read the file
298    uid=find(t,'ImaDoc');
299    if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup)
300        if isequal(success,1)
301            delete(outputfile)
302        else
303            msgbox_uvmat('ERROR',['error in the backup of the existing xml file: ' message])
304            return
305        end
306    else
307        uid_calib=find(t,'ImaDoc/GeometryCalib');
308        testappend=1;
309        if isempty(uid_calib)
310            [t,uid_calib]=add(t,1,'element','GeometryCalib');
311        else %if GeometryCalib already exists, delete its content
312            uid_child=children(t,uid_calib);
313            t=delete(t,uid_child);
314%             testappend=1;
315        end
316    end
317end
318if ~testappend %create a new xml file for calibration data
319    t=xmltree;
320    t=set(t,1,'name','ImaDoc');
321    [t,uid_calib]=add(t,1,'element','GeometryCalib');
322end
323% hgrid=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata
324% imagename=get(hgrid,'UserData');
325% if exist(imagename,'file')
326%     GeometryCalib.SourceCalib.ImageCalib=imagename;
327% end
328GeometryCalib.SourceCalib.PointCoord=Object.Coord;
329t=struct2xml(GeometryCalib,t,uid_calib);
330save(t,outputfile);
331msgbox_uvmat('CONFIRMATION',{[outputfile ' updated with calibration data'];...
332    ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];...
333    ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']})
334
335%display image with new calibration in the currently opened uvmat interface
336hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers
337if ~isempty(hhh)
338    delete(hhh);
339end
340hhh=findobj(hhuvmat.axes3,'Tag','calib_points');
341if ~isempty(hhh)
342    delete(hhh);
343end
344set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off'
345set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
346uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
347
348%------------------------------------------------------------------
349% --- Executes on button press in calibrate_lin.
350function REPLICATE_Callback(hObject, eventdata, handles)
351%------------------------------------------------------------------
352calib_cell=get(handles.calib_type,'String');
353val=get(handles.calib_type,'Value');
354calib_type=calib_cell{val};
355Coord_cell=get(handles.ListCoord,'String');
356Object=read_geometry_calib(Coord_cell);
357
358if isequal(calib_type,'rescale')
359    GeometryCalib=calib_rescale(Object.Coord);
360elseif isequal(calib_type,'linear')
361    GeometryCalib=calib_linear(Object.Coord);
362elseif isequal(calib_type,'tsai')
363    GeometryCalib=calib_tsai(Object.Coord);
364end
365% %record image source
366% hgrid=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata
367% imagename=get(hgrid,'UserData');
368% if exist(imagename,'file')
369%     GeometryCalib.SourceCalib.ImageCalib=imagename;
370% end
371GeometryCalib.SourceCalib.PointCoord=Object.Coord;
372
373
374%root PROJETS
375
376%open and read the dataview GUI
377h_dataview=findobj(allchild(0),'name','dataview');
378if ~isempty(h_dataview)
379    delete(h_dataview)
380end
381CalibData=get(handles.figure1,'UserData');%read the calibration image source on the interface userdata
382% filename='PROJETS';%default
383% if isfield(CalibData,'XmlInput')
384%      [pp,filename]=fileparts(CalibData.XmlInput);
385% end
386% while ~isequal(filename,'PROJETS') && numel(filename)>1
387%     filename_1=filename;
388%     pp_1=pp;
389%     [pp,filename]=fileparts(pp)
390% end
391% projinput=fullfile(pp_1,filename_1)
392% dd=dataview(projinput)
393
394%
395% Device=[];%default
396%
397% h_dataview=dataview;
398% hhdataview=guidata(h_dataview);
399% drawnow
400
401if isfield(CalibData,'XmlInput')
402    XmlInput=fileparts(CalibData.XmlInput);
403    [XmlInput,filename,ext]=fileparts(XmlInput);
404end
405SubCampaignTest='n'; %default
406testinput=0;
407if isfield(CalibData,'Heading')
408    Heading=CalibData.Heading;
409    if isfield(Heading,'Record') && isequal([filename ext],Heading.Record)
410        [XmlInput,filename,ext]=fileparts(XmlInput);
411    end
412    if isfield(Heading,'Device') && isequal([filename ext],Heading.Device)
413        [XmlInput,filename,ext]=fileparts(XmlInput);
414        Device=Heading.Device;
415    end
416    if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment)
417        [PP,filename,ext]=fileparts(XmlInput);
418    end
419    testinput=0;
420    if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign)
421%         set(hhdataview.RootDirectory,'String',XmlInput)
422%         set(hhdataview.SubCampaignTest,'Value',1)
423        SubCampaignTest='y';
424        testinput=1;
425    elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign)
426%         set(hhdataview.RootDirectory,'String',XmlInput)
427%         set(hhdataview.SubCampaignTest,'Value',0)
428        testinput=1;
429    end
430end
431if ~testinput
432    filename='PROJETS';%default
433    if isfield(CalibData,'XmlInput')
434         [pp,filename]=fileparts(CalibData.XmlInput);
435    end
436    while ~isequal(filename,'PROJETS') && numel(filename)>1
437        filename_1=filename;
438        pp_1=pp;
439        [pp,filename]=fileparts(pp);
440    end
441    XmlInput=fullfile(pp_1,filename_1);
442    testinput=1;
443end
444if testinput
445    outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib)%,SubCampaignTest)
446end
447%     %A COMPLETER
448%     dataview('RootDirectory_Callback',hObject,eventdata,hhdataview)
449%     ListDevices=get(hhdataview.ListDevices,'String');
450%     for ilist=1:length(ListDevices)
451%         if isequal(ListDevices{ilist},Device)
452%             set(hhdataview.ListDevices,'Value',ilist)
453%             dataview('ListDevices_Callback',hObject,eventdata,hhdataview)
454%             break
455%         end
456%     end
457
458% % hhdataview=guidata(h_dataview);
459% CurrentPath=get(hhdataview.RootDirectory,'String');
460% ListExperiments=get(hhdataview.ListExperiments,'String');
461% Value=get(hhdataview.ListExperiments,'Value');
462% if ~isequal(Value,1)
463%     ListExperiments=ListExperiments(Value);
464% end
465% ListDevices=get(hhdataview.ListDevices,'String');
466% Value=get(hhdataview.ListDevices,'Value');
467% if isequal(Value,1)
468%     msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated')
469%     return
470% else
471%     ListDevices=ListDevices(Value);
472% end
473% ListRecords=get(hhdataview.ListRecords,'String');
474% Value=get(hhdataview.ListRecords,'Value');
475% if ~isequal(Value,1)
476%     ListRecords=ListRecords(Value);
477% end
478% [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
479% ListXml=get(hhdataview.ListXml,'String');
480% Value=get(hhdataview.ListXml,'Value');
481% if isequal(Value,1)
482%     msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit')
483%     return
484% else
485%     ListXml=ListXml(Value);
486% end
487%
488% %update all the selected xml files
489% answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' calib_type ' calibration data'])
490% if ~isequal(answer,'Yes')
491%     return
492% end
493% 'TESTcalib'
494% List=DataFiles.List
495% for iexp=1:length(List.Experiment)
496%     ExpName=List.Experiment{iexp}.name;
497%     if isfield(List.Experiment{iexp},'Device')
498%         for idevice=1:length(List.Experiment{iexp}.Device)
499%             DeviceName=List.Experiment{iexp}.Device{idevice}.name;       
500%             if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
501%                 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
502%                     FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
503%                     for ilistxml=1:length(ListXml)
504%                         if isequal(FileName,ListXml{ilistxml})
505%                             set(hhdataview.ListXml,'Value',Value(ilistxml))
506%                             drawnow
507%                             xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName);
508%                             update_imadoc(GeometryCalib,xmlfullname)
509%                             break
510%                         end
511%                     end
512%                 end
513%              elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
514%                 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
515%                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
516%                     if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
517%                         for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
518%                             FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
519%                             for ilistxml=1:length(ListXml)
520%                                 if isequal(FileName,ListXml{ilistxml})
521%                                     set(hhdataview.ListXml,'Value',Value(ilistxml))
522%                                     drawnow
523%                                     xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName);
524%                                     update_imadoc(GeometryCalib,xmlfullname)
525%                                     break
526%                                 end
527%                             end
528%                         end
529%                     end
530%                 end
531%             end
532%         end
533%     end
534% end
535% set(hhdataview.ListXml,'Value',Value)
536
537
538%-----------------------------------------------------------------
539% determine the parameters for a calibration by an affine function (rescaling and offset, no rotation)
540function GeometryCalib=calib_rescale(Coord)
541%------------------------------------------------------------------
542 
543X=Coord(:,1);
544Y=Coord(:,2);
545x_ima=Coord(:,4);
546y_ima=Coord(:,5);
547[px,sx]=polyfit(X,x_ima,1);
548[py,sy]=polyfit(Y,y_ima,1);
549T_x=px(2);
550T_y=py(2);
551GeometryCalib.CalibrationType='rescale';
552GeometryCalib.focal=1;
553GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
554GeometryCalib.Tx_Ty_Tz=[T_x T_y 1];
555GeometryCalib.R=[px(1),0,0;0,py(1),0;0,0,1];
556
557%check error
558Calib.dpx=1;
559Calib.dpy=1;
560Calib.sx=1;
561Calib.Cx=0;
562Calib.Cy=0;
563Calib.Tz=1;
564Calib.kappa1=0;
565Calib.f=GeometryCalib.focal;
566Calib.Tx=T_x;
567Calib.Ty=T_y;
568Calib.R=GeometryCalib.R;
569[Xpoints,Ypoints]=px_XYZ(Calib,X,Y,0);
570GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));
571GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima));
572GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
573GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima));
574
575
576%------------------------------------------------------------------
577% determine the parameters for a calibration by a linear transform matrix (rescale and rotation)
578function GeometryCalib=calib_linear(Coord)
579%------------------------------------------------------------------
580X=Coord(:,1);
581Y=Coord(:,2);
582x_ima=Coord(:,4);
583y_ima=Coord(:,5);
584XY_mat=[ones(size(X)) X Y];
585a_X1=XY_mat\x_ima; %transformation matrix for X
586x1=XY_mat*a_X1;%reconstruction
587err_X1=max(abs(x1-x_ima));%error
588a_Y1=XY_mat\y_ima;%transformation matrix for X
589y1=XY_mat*a_Y1;
590err_Y1=max(abs(y1-y_ima));%error
591T_x=a_X1(1);
592T_y=a_Y1(1);
593GeometryCalib.CalibrationType='linear';
594GeometryCalib.focal=1;
595GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
596GeometryCalib.Tx_Ty_Tz=[T_x T_y 1];
597GeometryCalib.R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,1];
598
599%check error
600GeometryCalib.ErrorRms(1)=sqrt(mean((x1-x_ima).*(x1-x_ima)));
601GeometryCalib.ErrorMax(1)=max(abs(x1-x_ima));
602GeometryCalib.ErrorRms(2)=sqrt(mean((y1-y_ima).*(y1-y_ima)));
603GeometryCalib.ErrorMax(2)=max(abs(y1-y_ima));
604
605
606
607
608%------------------------------------------------------------------
609function GeometryCalib=calib_tsai(Coord)
610%------------------------------------------------------------------
611%TSAI
612% 'calibration_lin' provides a linear transform on coordinates,
613path_uvmat=which('uvmat');% check the path detected for source file uvmat
614path_UVMAT=fileparts(path_uvmat); %path to UVMAT
615if isunix
616    %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names
617    xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml');
618    if exist(xmlfile,'file')
619        t=xmltree(xmlfile);
620        sparam=convert(t);
621    end
622else
623    %fid = fopen(fullfile(path_UVMAT,'PARAM_WIN.txt'),'r');%open the file with civ binary names
624    xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml');
625    if exist(xmlfile,'file')
626        t=xmltree(xmlfile);
627        sparam=convert(t);
628    end
629end
630if ~isfield(sparam,'GeometryCalib_exe')
631    warndlg_uvmat(['calibration program <GeometryCalib_exe> undefined in parameter file ' xmlfile],'ERROR')
632    return
633end
634Tsai_exe=sparam.GeometryCalib_exe;
635if ~exist(Tsai_exe,'file')
636    warndlg_uvmat(['calibration program ' Tsai_exe ' does not exist'],'ERROR')
637    return
638end
639
640textcoord=num2str(Coord,4);
641dlmwrite('t.txt',textcoord,''); 
642% ['!' Tsai_exe ' -f1 0 -f2 t.txt']
643    eval(['!' Tsai_exe ' -f t.txt > tsaicalib.log']);
644if ~exist('calib.dat','file')
645    warndlg_uvmat('no output from calibration program Tsai_exe: possibly too few points','ERROR')
646end
647calibdat=dlmread('calib.dat');
648GeometryCalib.CalibrationType='tsai';
649GeometryCalib.focal=calibdat(10);
650GeometryCalib.dpx_dpy=[calibdat(5) calibdat(6)];
651GeometryCalib.Cx_Cy=[calibdat(7) calibdat(8)];
652GeometryCalib.sx=calibdat(9);
653GeometryCalib.kappa1=calibdat(11);
654GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
655GeometryCalib.Tx_Ty_Tz=[calibdat(12) calibdat(13) calibdat(14)];
656Rx_Ry_Rz=calibdat([15:17]);
657sa = sin(Rx_Ry_Rz(1)) ;
658ca=cos(Rx_Ry_Rz(1));
659sb=sin(Rx_Ry_Rz(2));
660cb =cos(Rx_Ry_Rz(2));
661sg =sin(Rx_Ry_Rz(3));
662cg =cos(Rx_Ry_Rz(3));
663r1 = cb * cg;
664r2 = cg * sa * sb - ca * sg;
665r3 = sa * sg + ca * cg * sb;
666r4 = cb * sg;
667r5 = sa * sb * sg + ca * cg;
668r6 = ca * sb * sg - cg * sa;
669r7 = -sb;
670r8 = cb * sa;
671r9 = ca * cb;
672%EN DEDUIRE MATRICE R ??
673GeometryCalib.R=[r1,r2,r3;r4,r5,r6;r7,r8,r9];
674%erreur a caracteriser?
675%check error
676Calib.dpx=GeometryCalib.dpx_dpy(1);
677Calib.dpy=GeometryCalib.dpx_dpy(2);
678Calib.sx=GeometryCalib.sx;
679Calib.Cx=GeometryCalib.Cx_Cy(1);
680Calib.Cy=GeometryCalib.Cx_Cy(2);
681Calib.kappa1=GeometryCalib.kappa1;
682Calib.f=GeometryCalib.focal;
683Calib.Tx=GeometryCalib.Tx_Ty_Tz(1);
684Calib.Ty=GeometryCalib.Tx_Ty_Tz(2);
685Calib.Tz=GeometryCalib.Tx_Ty_Tz(3);
686Calib.R=GeometryCalib.R;
687X=Coord(:,1);
688Y=Coord(:,2);
689Z=Coord(:,3);
690x_ima=Coord(:,4);
691y_ima=Coord(:,5);
692[Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z);
693
694GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));
695GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima));
696GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
697GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima));
698% Nfx
699% dx
700% dy
701% 5 dpx
702% 6 dpy
703% cx
704% cy
705% sx
706% f
707% kappa1
708% tx
709% ty
710% tz
711% rx
712% ry
713% rz
714% p1
715% p2
716
717%calibcoeff=str2num(calibdat)
718
719
720
721% --- Executes on button press in rotation.
722function rotation_Callback(hObject, eventdata, handles)
723angle_rot=(pi/180)*str2num(get(handles.Phi,'String'));
724Coord_cell=get(handles.ListCoord,'String');
725data=read_geometry_calib(Coord_cell);
726data.Coord(:,1)=cos(angle_rot)*data.Coord(:,1)+sin(angle_rot)*data.Coord(:,2);
727data.Coord(:,1)=-sin(angle_rot)*data.Coord(:,1)+cos(angle_rot)*data.Coord(:,2);
728set(handles.XObject,'String',num2str(data.Coord(:,1),4));
729set(handles.YObject,'String',num2str(data.Coord(:,2),4));
730
731
732function XImage_Callback(hObject, eventdata, handles)
733update_list(hObject, eventdata,handles)
734
735function YImage_Callback(hObject, eventdata, handles)
736update_list(hObject, eventdata,handles)
737
738function XObject_Callback(hObject, eventdata, handles)
739update_list(hObject, eventdata,handles)
740
741function YObject_Callback(hObject, eventdata, handles)
742update_list(hObject, eventdata,handles)
743
744function ZObject_Callback(hObject, eventdata, handles)
745update_list(hObject, eventdata,handles)
746
747function update_list(hObject, eventdata, handles)
748str4=get(handles.XImage,'String');
749str5=get(handles.YImage,'String');
750str1=get(handles.XObject,'String');
751tt=double(str1);
752str2=get(handles.YObject,'String');
753str3=get(handles.ZObject,'String');
754if ~isempty(str1) & ~isequal(double(str1),32) & (isempty(str3)|isequal(double(str3),32))
755    str3='0';%put z to 0 by default
756end
757strline=[str1 '    |    ' str2 '    |    ' str3 '    |    ' str4 '    |    ' str5];
758Coord=get(handles.ListCoord,'String');
759val=get(handles.ListCoord,'Value');
760Coord{val}=strline;
761set(handles.ListCoord,'String',Coord)
762
763%--------------------------------------------------------------------
764% --- Executes on selection change in ListCoord.
765%--------------------------------------------------------------------
766function ListCoord_Callback(hObject, eventdata, handles)
767% hObject    handle to ListCoord (see GCBO)
768% eventdata  reserved - to be defined in a future version of MATLAB
769% handles    structure with handles and user data (see GUIDATA)
770
771% Hints: contents = get(hObject,'String') returns ListCoord contents as cell array
772%        contents{get(hObject,'Value')} returns selected item from ListCoord
773%set(handles.edit_append,'Value',2); %set to edit mode
774Coord_cell=get(handles.ListCoord,'String');
775val=get(handles.ListCoord,'Value');
776if length(Coord_cell)>0
777    coord_str=Coord_cell{val};
778    k=findstr('|',coord_str);
779    if isempty(k)
780        return
781    end
782    set(handles.XObject,'String',coord_str(1:k(1)-5))
783    set(handles.YObject,'String',coord_str(k(1)+5:k(2)-5))
784    set(handles.ZObject,'String',coord_str(k(2)+5:k(3)-5))
785    set(handles.XImage,'String',coord_str(k(3)+5:k(4)-5))
786    set(handles.YImage,'String',coord_str(k(4)+5:end))
787    huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
788    hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
789    h_menu_coord=findobj(huvmat,'Tag','menu_coord');
790    menu=get(h_menu_coord,'String');
791    choice=get(h_menu_coord,'Value');
792    if iscell(menu)
793        option=menu{choice};
794    else
795        option='px'; %default
796    end
797    if isequal(option,'phys')
798        XCoord=str2num(coord_str(1:k(1)-5));
799        YCoord=str2num(coord_str(k(1)+5:k(2)-5));
800    elseif isequal(option,'px')|| isequal(option,'')
801        XCoord=str2num(coord_str(k(3)+5:k(4)-5));
802        YCoord=str2num(coord_str(k(4)+5:end));
803    else
804        warndlg_uvmat('the choice in menu_coord of uvmat must be px or phys ','ERROR')
805    end
806    huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
807    hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
808    hhh=findobj(hplot,'Tag','calib_marker');
809    if isempty(hhh)
810        axes(hplot)
811        line(XCoord,YCoord,'Color','m','Tag','calib_marker','LineStyle','.','Marker','o','MarkerSize',20);
812    else
813        set(hhh,'XData',XCoord)
814        set(hhh,'YData',YCoord)
815    end
816end
817
818
819%----------------------------------------------------
820% --- Executes on button press in rotation_plus.
821function rotation_plus_Callback(hObject, eventdata, handles)
822Phi=0;
823Phi=get(handles.Phi,'String');
824if ~isempty(Phi)
825    Phi=str2num(Phi);
826end
827rotation(handles,Phi)
828
829%-------------------------------------------------
830% --- Executes on button press in rotation_minus.
831function rotation_minus_Callback(hObject, eventdata, handles)
832Phi=0;
833Phi=get(handles.Phi,'String');
834if ~isempty(Phi)
835    Phi=-str2num(Phi);
836end
837rotation(handles,Phi)
838
839
840
841function O_x_Callback(hObject, eventdata, handles)
842
843
844function O_y_Callback(hObject, eventdata, handles)
845
846
847function O_z_Callback(hObject, eventdata, handles)
848
849
850% --- Executes on selection change in edit_append.
851function edit_append_Callback(hObject, eventdata, handles)
852% val=get(handles.PLOT_append,'Value');
853% if isequal(val,2); %append mode
854%     %appeler mouse
855% end
856choice=get(handles.edit_append,'Value');
857if choice==1
858       Coord=get(handles.ListCoord,'String');
859       val=length(Coord);
860       if val>=1 & isequal(Coord{val},'')
861            val=val-1; %do not take into account blank
862       end
863       Coord{val+1}='';
864       set(handles.ListCoord,'String',Coord)
865       set(handles.ListCoord,'Value',val+1)
866end
867
868
869%A REVOIR
870% if choice==2
871%     %display image with px coordinates
872%     hrootpath=findobj(huvmat,'Tag','RootPath');
873%     hrootfile=findobj(huvmat,'Tag','RootFile');
874%     RootPath='';
875%     RootFile='';
876% %     if ~isempty(hrootpath)& ~isempty(hrootfile)
877%         testhandle=1;
878%         RootPath=get(hrootpath,'String');
879%         RootFile=get(hrootfile,'String');
880% %         filebase=fullfile(RootPath,RootFile);
881% %         outputfile=[filebase '.xml'];
882%         Indices=get(findobj(huvmat,'Tag','FileIndex'),'String');
883%         Ext=get(findobj(huvmat,'Tag','FileExt'),'String');
884%         imagename=[fullfile(RootPath,RootFile) Indices Ext];
885%         % input.menu_coord=1;
886%          h_menu_coord=findobj(huvmat,'Tag','menu_coord');
887%         set(h_menu_coord,'Value',3)
888%         huvmat=uvmat(imagename);%open uvmat, set phys coord (Value 1)
889%     
890% %     end
891% end
892   
893function NEW_Callback(hObject, eventdata, handles)
894%A METTRE SOUS UN BOUTON
895huvmat=findobj(allchild(0),'Name','uvmat');
896hchild=get(huvmat,'children');
897hcoord=findobj(hchild,'Tag','menu_coord');
898coordtype=get(hcoord,'Value');
899haxes=findobj(hchild,'Tag','axes3');
900AxeData=get(haxes,'UserData');
901if ~isequal(hcoord,2)
902    set(hcoord,'Value',2)
903    huvmat=uvmat(AxeData);
904    'relancer uvmat';
905end
906if ~isfield(AxeData,'ZoomAxes')
907    warndlg_uvmat('first draw a window around a grid marker','ERRROR')
908    return
909end
910XLim=get(AxeData.ZoomAxes,'XLim');
911YLim=get(AxeData.ZoomAxes,'YLim');
912np=size(AxeData.A);
913ind_sub_x=round(XLim);
914ind_sub_y=np(1)-round(YLim);
915Mfiltre=AxeData.A([ind_sub_y(2):ind_sub_y(1)] ,ind_sub_x,:);
916Mfiltre_norm=double(Mfiltre);
917Mfiltre_norm=Mfiltre_norm/sum(sum(Mfiltre_norm));
918Mfiltre_norm=100*(Mfiltre_norm-mean(mean(Mfiltre_norm)));
919Atype=class(AxeData.A);
920Data.NbDim=2;
921Data.A=filter2(Mfiltre_norm,double(AxeData.A));
922Data.A=feval(Atype,Data.A);
923Data.AName='image';
924Data.AX=AxeData.AX;
925Data.AY=AxeData.AY;
926Data.CoordType='px';
927plot_field(Data)
928 
929
930
931%'key_press_fcn:' function activated when a key is pressed on the keyboard
932%-----------------------------------
933function key_press_fcn(hObject,eventdata,handles)
934hh=get(hObject,'parent');
935xx=double(get(hh,'CurrentCharacter')); %get the keyboard character
936
937if ismember(xx,[8 127])%backspace or delete
938    Coord_cell=get(handles.ListCoord,'String');
939    data=read_geometry_calib(Coord_cell);
940    Coord=[]; %default
941    if isfield(data,'Coord')
942        Coord=data.Coord;
943    end
944    val=get(handles.ListCoord,'Value');
945    Coord(val,:)=[];%suppress the selected item in the list
946    CoordCell={};
947    for iline=1:size(Coord,1)
948        for j=1:5
949            CoordCell{iline,j}=num2str(Coord(iline,j),4);
950        end
951    end
952    Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
953    val=min(size(Coord,1),val);
954    set(handles.ListCoord,'Value',max(val,1))
955    set(handles.ListCoord,'String',Tabchar) 
956    ListCoord_Callback(hObject, eventdata, handles)
957    PLOT_Callback(hObject,eventdata,handles)
958end
959
960
961% --- Executes on button press in append_point.
962function append_point_Callback(hObject, eventdata, handles)
963
964       Coord=get(handles.ListCoord,'String');
965       val=length(Coord);
966       if val>=1 & isequal(Coord{val},'')
967            val=val-1; %do not take into account blank
968       end
969       Coord{val+1}='';
970       set(handles.ListCoord,'String',Coord)
971       set(handles.ListCoord,'Value',val+1)
972
973
974% --------------------------------------------------------------------
975function MenuOpen_Callback(hObject, eventdata, handles)
976%get the object file
977huvmat=findobj(allchild(0),'Name','uvmat');
978UvData=get(huvmat,'UserData');
979hchild=get(huvmat,'Children');
980hrootpath=findobj(hchild,'Tag','RootPath');
981oldfile=get(hrootpath,'String');
982if isempty(oldfile)
983    oldfile='';
984end
985%[FileName,PathName] = uigetfile('*.civ','Select a .civ file',oldfile)
986[FileName, PathName, filterindex] = uigetfile( ...
987       {'*.xml;*.mat', ' (*.xml,*.mat)';
988       '*.xml',  '.xml files '; ...
989        '*.mat',  '.mat matlab files '}, ...
990        'Pick a file',oldfile);
991fileinput=[PathName FileName];%complete file name
992testblank=findstr(fileinput,' ');%look for blanks
993if ~isempty(testblank)
994    msgbox_uvmat('ERROR','forbidden input file name or path: no blank character allowed')
995    return
996end
997sizf=size(fileinput);
998if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
999loadfile(handles,fileinput)
1000
1001
1002% --------------------------------------------------------------------
1003function Untitled_3_Callback(hObject, eventdata, handles)
1004% hObject    handle to Untitled_3 (see GCBO)
1005% eventdata  reserved - to be defined in a future version of MATLAB
1006% handles    structure with handles and user data (see GUIDATA)
1007
1008
1009% --------------------------------------------------------------------
1010function MenuPlot_Callback(hObject, eventdata, handles)
1011
1012huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
1013UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
1014hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
1015hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
1016h_menu_coord=findobj(huvmat,'Tag','menu_coord');
1017menu=get(h_menu_coord,'String');
1018choice=get(h_menu_coord,'Value');
1019if iscell(menu)
1020    option=menu{choice};
1021else
1022    option='px'; %default
1023end
1024Coord_cell=get(handles.ListCoord,'String');
1025ObjectData=read_geometry_calib(Coord_cell);
1026%ObjectData=read_geometry_calib(handles);%read the interface input parameters defining the object
1027if isequal(option,'phys')
1028    ObjectData.Coord=ObjectData.Coord(:,[1:3]);
1029elseif isequal(option,'px')||isequal(option,'')
1030    ObjectData.Coord=ObjectData.Coord(:,[4:5]);
1031else
1032    msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be px or phys ')
1033end
1034axes(hhuvmat.axes3)
1035hh=findobj('Tag','calib_points');
1036if isempty(hh)
1037    hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
1038else
1039    set(hh,'XData',ObjectData.Coord(:,1))
1040    set(hh,'YData',ObjectData.Coord(:,2))
1041end
1042
1043% --------------------------------------------------------------------
1044function MenuHelp_Callback(hObject, eventdata, handles)
1045path_to_uvmat=which ('uvmat');% check the path of uvmat
1046pathelp=fileparts(path_to_uvmat);
1047    helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
1048if isempty(dir(helpfile)), warndlg_uvmat('The help file uvmat_doc.html needs to be put in the directory UVMAT/UVMAT_DOC','ERROR')
1049else
1050   web([helpfile '#geometry_calib'])
1051end
1052
1053
1054
1055% --------------------------------------------------------------------
1056function MenuCreateGrid_Callback(hObject, eventdata, handles)
1057hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib
1058CalibData=get(hcalib,'UserData');
1059Tinput=[];%default
1060if isfield(CalibData,'grid')
1061    Tinput=CalibData.grid;
1062end
1063T=create_grid(Tinput);%display translate_points GUI and get shift parameters
1064CalibData.grid=T;
1065set(hcalib,'UserData',CalibData)
1066
1067%grid in phys space
1068Coord_cell=get(handles.ListCoord,'String');
1069data=read_geometry_calib(Coord_cell);
1070data.Coord(:,1)=T(1)+data.Coord(:,1);
1071data.Coord(:,2)=T(2)+data.Coord(:,2);
1072data.Coord(:,3)=T(3)+data.Coord(:,3);
1073data.Coord(:,[4 5])=data.Coord(:,[4 5]);
1074for i=1:size(data.Coord,1)
1075    for j=1:5
1076          Coord{i,j}=num2str(data.Coord(i,j),4);%phys x,y,z
1077   end
1078end
1079Tabchar=cell2tab(Coord,'    |    ');
1080set(handles.ListCoord,'Value',1)
1081set(handles.ListCoord,'String',Tabchar)
1082
1083
1084
1085% --------------------------------------------------------------------
1086function MenuTranslatePoints_Callback(hObject, eventdata, handles)
1087hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib
1088CalibData=get(hcalib,'UserData')
1089Tinput=[];%default
1090if isfield(CalibData,'translate')
1091    Tinput=CalibData.translate;
1092end
1093T=translate_points(Tinput);%display translate_points GUI and get shift parameters
1094CalibData.translate=T;
1095set(hcalib,'UserData',CalibData)
1096%translation
1097Coord_cell=get(handles.ListCoord,'String');
1098data=read_geometry_calib(Coord_cell);
1099data.Coord(:,1)=T(1)+data.Coord(:,1);
1100data.Coord(:,2)=T(2)+data.Coord(:,2);
1101data.Coord(:,3)=T(3)+data.Coord(:,3);
1102data.Coord(:,[4 5])=data.Coord(:,[4 5]);
1103for i=1:size(data.Coord,1)
1104    for j=1:5
1105          Coord{i,j}=num2str(data.Coord(i,j),4);%phys x,y,z
1106   end
1107end
1108Tabchar=cell2tab(Coord,'    |    ');
1109set(handles.ListCoord,'Value',1)
1110set(handles.ListCoord,'String',Tabchar)
1111
1112
1113% --------------------------------------------------------------------
1114function MenuRotatePoints_Callback(hObject, eventdata, handles)
1115hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib
1116CalibData=get(hcalib,'UserData')
1117Tinput=[];%default
1118if isfield(CalibData,'rotate')
1119    Tinput=CalibData.rotate;
1120end
1121T=rotate_points(Tinput);%display translate_points GUI and get shift parameters
1122CalibData.rotate=T;
1123set(hcalib,'UserData',CalibData)
1124%-----------------------------------------------------
1125%rotation
1126Phi=T(1);
1127O_x=0;%default
1128O_y=0;%default
1129if numel(T)>=2
1130    O_x=T(2);%default
1131end
1132if numel(T)>=3
1133    O_y=T(3);%default
1134end
1135Coord_cell=get(handles.ListCoord,'String');
1136data=read_geometry_calib(Coord_cell);
1137r1=cos(pi*Phi/180);
1138r2=-sin(pi*Phi/180);
1139r3=sin(pi*Phi/180);
1140r4=cos(pi*Phi/180);
1141x=data.Coord(:,1)-O_x;
1142y=data.Coord(:,2)-O_y;
1143data.Coord(:,1)=r1*x+r2*y;
1144data.Coord(:,2)=r3*x+r4*y;
1145% data.Coord(:,[4 5])=data.Coord(:,[4 5]);
1146for i=1:size(data.Coord,1)
1147    for j=1:5
1148          Coord{i,j}=num2str(data.Coord(i,j),4);%phys x,y,z
1149   end
1150end
1151Tabchar=cell2tab(Coord,'    |    ');
1152set(handles.ListCoord,'Value',1)
1153set(handles.ListCoord,'String',Tabchar)
1154
1155
Note: See TracBrowser for help on using the repository browser.