Changeset 341


Ignore:
Timestamp:
Dec 19, 2011, 5:00:54 PM (13 years ago)
Author:
sommeria
Message:

various bugs corrected

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r332 r341  
    9999%set menu of calibration options
    100100set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'})
    101 inputxml='';
     101% inputxml='';
    102102if exist('inputfile','var')&& ~isempty(inputfile)
    103103    struct.XmlInputFile=inputfile;
    104     [Pathsub,RootFile,field_count,str2,str_a,str_b,ext]=name2display(inputfile);
    105     if ~strcmp(ext,'.xml')
    106         inputfile=[fullfile(Pathsub,RootFile) '.xml'];%xml file corresponding to the input file
     104%     [Pathsub,RootFile,field_count,str2,str_a,str_b,ext]=name2display(inputfile);
     105    [RootPath,~,RootFile,~,~,~,~,FileExt]=fileparts_uvmat(inputfile);
     106    if ~strcmp(FileExt,'.xml')
     107        inputfile=[fullfile(RootPath,RootFile) '.xml'];%xml file corresponding to the input file
    107108    end
    108109    set(handles.ListCoord,'String',{'......'})
     
    134135if ~isempty(huvmat)
    135136    handles=guidata(huvmat);
    136 %     set(handles.MenuMask,'enable','on')
    137 %     set(handles.MenuGrid,'enable','on')
    138 %     set(handles.MenuObject,'enable','on')
    139 %     set(handles.MenuEdit,'enable','on')
    140 %     set(handles.edit,'enable','on')
    141137    hobject=findobj(handles.axes3,'tag','calib_points');
    142138    if ~isempty(hobject)
     
    179175    GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
    180176    [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima));
    181     [EM,ind_dim]=max(GeometryCalib.ErrorMax);
     177    [~,ind_dim]=max(GeometryCalib.ErrorMax);
    182178    index=index(ind_dim);
    183179    %set the Z position of the reference plane used for calibration
     
    222218hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
    223219RootPath='';
    224 RootFile='';
     220% RootFile='';
    225221if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile)
    226     testhandle=1;
     222%     testhandle=1;
    227223    RootPath=get(hhuvmat.RootPath,'String');
    228224    RootFile=get(hhuvmat.RootFile,'String');
     
    321317    [Xpoints,Ypoints]=px_XYZ(GeometryCalib,X,Y,Z);
    322318    GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));
    323     [GeometryCalib.ErrorMax(1),index(1)]=max(abs(Xpoints-x_ima));
     319    [GeometryCalib.ErrorMax(1)]=max(abs(Xpoints-x_ima));
    324320    GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
    325     [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima));
    326     [EM,ind_dim]=max(GeometryCalib.ErrorMax);
    327 %     index=index(ind_dim);
     321    [GeometryCalib.ErrorMax(2)]=max(abs(Ypoints-y_ima));
     322%     [EM,ind_dim]=max(GeometryCalib.ErrorMax);
    328323    %set the Z position of the reference plane used for calibration
    329324    Z_plane=[];
     
    360355end
    361356CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata
    362 InputFile='';
     357% InputFile='';
    363358if isfield(CalibData,'XmlInputFile')
    364359    InputDir=fileparts(CalibData.XmlInputFile);
     
    388383
    389384dataview(answer,SubCampaignTest,GeometryCalib);
    390        
    391 %     if isfield(Heading,'Device') && isequal([filename ext],Heading.Device)
    392 %         [XmlInput,filename,ext]=fileparts(XmlInput);
    393 %         Device=Heading.Device;
    394 %     end
    395 %     if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment)
    396 %         [PP,filename,ext]=fileparts(XmlInput);
    397 %     end
    398 %     testinput=0;
    399 %     if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign)
    400 %         SubCampaignTest='y';
    401 %         testinput=1;
    402 %     elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign)
    403 %         testinput=1;
    404 % %     end
    405 % end
    406 % if ~testinput
    407 %     filename='PROJETS';%default
    408 %     if isfield(CalibData,'XmlInputFile')
    409 %          [pp,filename]=fileparts(CalibData.XmlInputFile);
    410 %     end
    411 %     while ~isequal(filename,'PROJETS') && numel(filename)>1
    412 %         filename_1=filename;
    413 %         pp_1=pp;
    414 %         [pp,filename]=fileparts(pp);
    415 %     end
    416 %     XmlInput=fullfile(pp_1,filename_1);
    417 %     testinput=1;
    418 % end
    419 % if testinput
    420 %     outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib);
    421 % end
    422385
    423386%------------------------------------------------------------------------
     
    429392x_ima=Coord(:,4);
    430393y_ima=Coord(:,5);
    431 [px,sx]=polyfit(X,x_ima,1);
    432 [py,sy]=polyfit(Y,y_ima,1);
    433 T_x=px(2);
    434 T_y=py(2);
     394[px]=polyfit(X,x_ima,1);
     395[py]=polyfit(Y,y_ima,1);
     396% T_x=px(2);
     397% T_y=py(2);
    435398GeometryCalib.CalibrationType='rescale';
    436399GeometryCalib.fx_fy=[px(1) py(1)];%.fx_fy corresponds to pxcm along x and y
    437400GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    438401GeometryCalib.Tx_Ty_Tz=[px(2)/px(1) py(2)/py(1) 1];
    439 %GeometryCalib.R=[1,0,0;0,1,0;0,0,0];
    440402GeometryCalib.omc=[0 0 0];
    441403
     
    452414XY_mat=[ones(size(X)) X Y];
    453415a_X1=XY_mat\x_ima; %transformation matrix for X
    454 % x1=XY_mat*a_X1;%reconstruction
    455 % err_X1=max(abs(x1-x_ima));%error
    456416a_Y1=XY_mat\y_ima;%transformation matrix for X
    457 % y1=XY_mat*a_Y1;
    458 % err_Y1=max(abs(y1-y_ima));%error
    459 % R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,1];
    460417R=[a_X1(2),a_X1(3);a_Y1(2),a_Y1(3)];
    461418epsilon=sign(det(R));
     
    469426GeometryCalib.fx_fy(2)=(a_Y1(3)/a_X1(2))*GeometryCalib.fx_fy(1);
    470427GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    471 %GeometryCalib.Tx_Ty_Tz=[a_X1(1) a_Y1(1) 1];
    472428GeometryCalib.Tx_Ty_Tz=[a_X1(1)/GeometryCalib.fx_fy(1) a_Y1(1)/GeometryCalib.fx_fy(2) 1];
    473429R(1,:)=R(1,:)/GeometryCalib.fx_fy(1);
     
    740696
    741697
    742 %--------------------------------------------------------------------------
    743 function GeometryCalib=calib_tsai(Coord,handles)% OBSOLETE: old version using gauthier's bianry ccal_fo
    744 % NOT USED
    745 %------------------------------------------------------------------------
    746 %TSAI
    747 path_uvmat=which('uvmat');% check the path detected for source file uvmat
    748 path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    749 xmlfile=fullfile(path_UVMAT,'PARAM.xml');%name of the file containing names of binary executables
    750 if exist(xmlfile,'file')
    751     t=xmltree(xmlfile);% read the (xml) file containing names of binary executables
    752     sparam=convert(t);% convert to matlab structure
    753 end
    754 if ~isfield(sparam,'GeometryCalibBin')
    755     msgbox_uvmat('ERROR',['calibration program <GeometryCalibBin> undefined in parameter file ' xmlfile])
    756     return
    757 end
    758 Tsai_exe=sparam.GeometryCalibBin;
    759 if ~exist(Tsai_exe,'file')%the binary is defined in /bin, default setting
    760      Tsai_exe=fullfile(path_UVMAT,Tsai_exe);
    761 end
    762 if ~exist(Tsai_exe,'file')
    763     msgbox_uvmat('ERROR',['calibration program ' sparam.GeometryCalibBin ' defined in PARAM.xml does not exist'])
    764     return
    765 end
    766 
    767 textcoord=num2str(Coord,4);
    768 dlmwrite('t.txt',textcoord,''); 
    769 % ['!' Tsai_exe ' -fx 0 -fy t.txt']
    770 eval(['!' Tsai_exe ' -f t.txt > tsaicalib.log']);
    771 if ~exist('calib.dat','file')
    772     msgbox_uvmat('ERROR','no output from calibration program Tsai_exe: possibly too few points')
    773 end
    774 calibdat=dlmread('calib.dat');
    775 delete('calib.dat')
    776 %delete('t.txt')
    777 GeometryCalib.CalibrationType='tsai';
    778 GeometryCalib.focal=calibdat(10);
    779 GeometryCalib.dpx_dpy=[calibdat(5) calibdat(6)];
    780 GeometryCalib.Cx_Cy=[calibdat(7) calibdat(8)];
    781 GeometryCalib.sx=calibdat(9);
    782 GeometryCalib.kappa1=calibdat(11);
    783 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    784 GeometryCalib.Tx_Ty_Tz=[calibdat(12) calibdat(13) calibdat(14)];
    785 Rx_Ry_Rz=calibdat(15:17);
    786 sa = sin(Rx_Ry_Rz(1)) ;
    787 ca=cos(Rx_Ry_Rz(1));
    788 sb=sin(Rx_Ry_Rz(2));
    789 cb =cos(Rx_Ry_Rz(2));
    790 sg =sin(Rx_Ry_Rz(3));
    791 cg =cos(Rx_Ry_Rz(3));
    792 r1 = cb * cg;
    793 r2 = cg * sa * sb - ca * sg;
    794 r3 = sa * sg + ca * cg * sb;
    795 r4 = cb * sg;
    796 r5 = sa * sb * sg + ca * cg;
    797 r6 = ca * sb * sg - cg * sa;
    798 r7 = -sb;
    799 r8 = cb * sa;
    800 r9 = ca * cb;
    801 %EN DEDUIRE MATRICE R ??
    802 GeometryCalib.R=[r1,r2,r3;r4,r5,r6;r7,r8,r9];
    803 
    804698%------------------------------------------------------------------------
    805699% --- determine the rms of calibration error
     
    855749% RootFile='';
    856750if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile)
    857     testhandle=1;
     751%     testhandle=1;
    858752    RootPath=get(hhuvmat.RootPath,'String');
    859753    RootFile=get(hhuvmat.RootFile,'String');
  • trunk/src/series.m

    r339 r341  
    480480set(handles.waitbar_frame,'Units','pixels')
    481481pos=get(handles.waitbar_frame,'Position');
    482 xima=0.5:pos(3)-0.5;
     482xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
    483483yima=0.5:pos(4)-0.5;
    484484[XIma,YIma]=meshgrid(xima,yima);
     
    491491file_ima=double((i1_series(:,:,1)>0)');
    492492if size(file_ima,1)==1
    493     file_ima=ones(pos(4),1)*file_ima;
    494 end
    495 CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
     493    CLine=interp1(ind_i,file_ima,xima,'nearest');
     494    CData(:,:,2)=ones(size(yima'))*CLine;
     495%     file_ima=ones(pos(4),1)*file_ima;
     496%     Ind_i=
     497else
     498    CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
     499end
    496500set(handles.waitbar_frame,'CData',CData)
    497501set(handles.waitbar_frame,'Units','normalized')
     
    14891493% set(handles.waitbar,'Position',waitbarpos)
    14901494
    1491 
     1495if isfield(Series.IndexRange,'NbSlice')
    14921496Series.NbSlice=Series.IndexRange.NbSlice;
     1497end
    14931498if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
    14941499    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
  • trunk/src/set_object.m

    r309 r341  
    673673ListObject=get(hhuvmat.ListObject,'String');%position in the objet list
    674674IndexObj=get(hhuvmat.ListObject,'Value')
    675 % name of the object
     675
     676%% read the object on the GUI set_object
    676677ObjectName=get(handles.TITLE,'String');%name of the current object defiend in set_object
    677678ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object
  • trunk/src/uvmat.m

    r339 r341  
    555555fileinput=read_file_boxes(handles);
    556556% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    557 [i1_series,i2_series,j1_series,j2_series,~,FileType,MovieObject]=find_file_series(fileinput);
     557[RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,~,FileType,MovieObject]=find_file_series(fileinput);
    558558% initiate the input file series and refresh the current field view:
    559559update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
     
    10401040
    10411041%[path,name,ext]=fileparts(fileinput_1);
    1042 [RootPath_1,SubDir_1,RootFile_1,i1,i2,j1,j2,FileExt_1]=fileparts_uvmat(fileinput_1);
    1043 [i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput_1);
     1042[~,SubDir_1,~,i1,i2,j1,j2,FileExt_1]=fileparts_uvmat(fileinput_1);
     1043[RootPath_1,RootFile_1,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput_1);
    10441044% [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
    10451045switch FileType
Note: See TracChangeset for help on using the changeset viewer.