source: trunk/src/geometry_calib.m @ 35

Last change on this file since 35 was 17, checked in by sommeria, 15 years ago

possibilite de créer une grille physique dans geometry_calib (le faire apres avoir introduit les points sur l'image avec la souris)
petites corrections mineures sur les autres fichiers

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