Changeset 694 for trunk/src


Ignore:
Timestamp:
Nov 4, 2013, 9:34:10 PM (11 years ago)
Author:
sommeria
Message:

create_grid now remember white or black marks
bug repaired for transform fct in series

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/create_grid.m

    r156 r694  
    110110        set(handles.z,'String',num2str(input_grid.z));
    111111   end 
     112   if isfield(input_grid,'CheckWhite')
     113       if input_grid.CheckWhite
     114        set(handles.white,'Value',1)
     115        set(handles.black,'Value',0)
     116       else
     117          set(handles.white,'Value',0)
     118          set(handles.black,'Value',1)
     119       end
     120   end
    112121end
    113122
     
    141150    varargout{1}=[xarray yarray zarray];
    142151    varargout{2}=T;
    143     varargout{3}=get(handles.white,'Value')
     152    varargout{3}=get(handles.white,'Value');
    144153end
    145154
  • trunk/src/geometry_calib.m

    r693 r694  
    540540est_aspect_ratio=0;
    541541est_fc=[1;1];
    542 %fc=[25;25]/0.012;
    543542center_optim=0;
    544 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));
     543run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'
    545544GeometryCalib.CalibrationType='3D_linear';
    546545GeometryCalib.fx_fy=fc';
    547 %GeometryCalib.focal=fc(2);
    548 %GeometryCalib.dpx_dpy=[1 1];
    549546GeometryCalib.Cx_Cy=cc';
    550 %GeometryCalib.sx=fc(1)/fc(2);
    551547GeometryCalib.kc=kc(1);
    552 %GeometryCalib.kappa1=-kc(1)/fc(2)^2;
    553548GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    554549GeometryCalib.Tx_Ty_Tz=Tc_1';
     
    611606est_dist=[1;0;0;0;0];
    612607est_aspect_ratio=1;
    613 %est_fc=[0;0];
    614 %fc=[25;25]/0.012;
    615608center_optim=0;
    616 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));
     609run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'
    617610
    618611GeometryCalib.CalibrationType='3D_quadr';
    619612GeometryCalib.fx_fy=fc';
    620 %GeometryCalib.focal=fc(2);
    621 %GeometryCalib.dpx_dpy=[1 1];
    622613GeometryCalib.Cx_Cy=cc';
    623 %GeometryCalib.sx=fc(1)/fc(2);
    624614GeometryCalib.kc=kc(1);
    625 %GeometryCalib.kappa1=-kc(1)/fc(2)^2;
    626615GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    627616GeometryCalib.Tx_Ty_Tz=Tc_1';
     617if ~exist('Rc_1','var')
     618    msgbox_uvmat('ERROR',['calibration function ' fullfile('toolbox_calib','go_calib_optim') ' did not converge: use multiple views or option 3D_extrinsic'])
     619    return
     620end
    628621GeometryCalib.R=Rc_1;
    629622GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate
     
    656649addpath(fct_path)
    657650GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%reverse Cx_Cy(2) for calibration (inversion of px ordinate)
    658 % [omc1,Tc1,Rc1,H,x,ex,JJ] = compute_extrinsic(x_1,X_1,...
    659 %     [Calib.f Calib.f*Calib.sx]',...
    660 %     [Calib.Cx Calib.Cy]',...
    661 %     [-Calib.kappa1*Calib.f^2 0 0 0 0]);
    662651[omc,Tc1,Rc1,H,x,ex,JJ] = compute_extrinsic(x_1,X_1,...
    663     (GeometryCalib.fx_fy)',GeometryCalib.Cx_Cy',[GeometryCalib.kc 0 0 0 0]);
     652   (GeometryCalib.fx_fy)',GeometryCalib.Cx_Cy',[GeometryCalib.kc 0 0 0 0]);
    664653rmpath(fct_path);
    665654GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
     
    876865    grid_input=CalibData.grid;%retrieve the previously used grid
    877866end
    878 [T,CalibData.grid,white_test]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T
     867[T,CalibData.grid,CalibData.grid.CheckWhite]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T
    879868set(handles.geometry_calib,'UserData',CalibData)%store the phys grid parameters for later use
    880869
     
    922911Rangx=DataOut.AX;
    923912Rangy=DataOut.AY;
    924 if white_test
     913if CalibData.CheckWhite
    925914    Amod=double(Amod);%case of white grid markers: will look for image maxima
    926915else
    927916    Amod=-double(Amod);%case of black grid markers: will look for image minima
    928917end
    929 % figure(12) %display corrected image
    930 % Amax=max(max(Amod));
    931 % image(Rangx,Rangy,uint8(255*Amod/Amax))
    932918
    933919%% detection of local image extrema in each direction
     
    946932    i0max=min(i0+ind_range_x,size(Amod,2));
    947933    Asub=Amod(j0min:j0max,i0min:i0max);
    948     x_profile=sum(Asub,1);
    949     y_profile=sum(Asub,2);
    950     [Amax,ind_x_max]=max(x_profile);
    951     [Amax,ind_y_max]=max(y_profile);
     934 
     935
     936   
     937    x_profile=sum(Asub,1);%profile of subimage summed over y
     938    y_profile=sum(Asub,2);%profile of subimage summed over x
     939    %%%%
     940%     if ipoint==5
     941%                 figure(10)
     942%   imagesc(Asub)
     943%     figure(11)
     944%     plot(x_profile,'r')
     945%     hold on
     946%     plot(y_profile,'b')
     947%     end
     948    %%%%
     949    [tild,ind_x_max]=max(x_profile);
     950    [tild,ind_y_max]=max(y_profile);
    952951    %sub-pixel improvement using moments
    953952    x_shift=0;
    954953    y_shift=0;
    955954    if ind_x_max+2<=numel(x_profile) && ind_x_max-2>=1
    956         Atop=x_profile(ind_x_max-2:ind_x_max+2);
     955        Atop=x_profile(ind_x_max-2:ind_x_max+2);% extract x profile around the max
    957956        x_shift=sum(Atop.*[-2 -1 0 1 2])/sum(Atop);
    958957    end
    959958    if ind_y_max+2<=numel(y_profile) && ind_y_max-2>=1
    960         Atop=y_profile(ind_y_max-2:ind_y_max+2);
     959        Atop=y_profile(ind_y_max-2:ind_y_max+2);% extract y profile around the max
    961960        y_shift=sum(Atop.*[-2 -1 0 1 2]')/sum(Atop);
    962961    end
    963     Delta(ipoint,1)=(x_shift+ind_x_max+i0min-i0-1)*Dx;%shift from the initial guess
    964     Delta(ipoint,2)=(y_shift+ind_y_max+j0min-j0-1)*Dy;
     962    Delta(ipoint,1)=(i0min+ind_x_max-1+x_shift-i0)*Dx;%shift from the initial guess
     963    Delta(ipoint,2)=(j0min+ind_y_max-1+y_shift-j0)*Dy;
    965964end
    966965Tmod=T(:,(1:2))+Delta;% 'phys' coordinates of the detected points
     
    10331032end
    10341033[s,errormsg]=imadoc2struct(fileinput,'GeometryCalib');
     1034if ~isfield(s,'GeometryCalib')
     1035    msgbox_uvmat('ERROR','invalid input file: no geometry_calib data')
     1036    return
     1037end
    10351038GeometryCalib=s.GeometryCalib;
     1039if ~(isfield(GeometryCalib,'SourceCalib')&&isfield(GeometryCalib.SourceCalib,'PointCoord'))
     1040        msgbox_uvmat('ERROR','invalid input file: no calibration points')
     1041    return
     1042end
    10361043Coord=GeometryCalib.SourceCalib.PointCoord;
    10371044Coord=[Coord zeros(size(Coord,1),1)];
  • trunk/src/series.m

    r682 r694  
    25902590% ff=functions(list_transform{end});
    25912591if isequal(TransformName,'more...');
    2592 %     coord_fct='';
    2593 %     prompt = {'Enter the name of the transform function'};
    2594 %     dlg_title = 'user defined transform';
    2595 %     num_lines= 1;
    2596     [FileName, PathName] = uigetfile( ...
    2597        {'*.m', ' (*.m)';
    2598         '*.m',  '.m files '; ...
    2599         '*.*', 'All Files (*.*)'}, ...
    2600         'Pick a transform function',get(handles.TransformPath,'String'));
    2601     if isequal(FileName,0)
     2592%     [FileName, PathName] = uigetfile( ...
     2593%        {'*.m', ' (*.m)';
     2594%         '*.m',  '.m files '; ...
     2595%         '*.*', 'All Files (*.*)'}, ...
     2596%         'Pick a transform function',get(handles.TransformPath,'String'));
     2597   
     2598    FileName=uigetfile_uvmat('Pick a transform function',get(handles.TransformPath,'String'),'.m');
     2599    if isempty(FileName)
    26022600        return     %browser closed without choice
    26032601    end
    2604     if isequal(PathName(end),'/')||isequal(PathName(end),'\')
    2605         PathName(end)=[];
    2606     end
     2602%     if isequal(PathName(end),'/')||isequal(PathName(end),'\')
     2603%         PathName(end)=[];
     2604%     end
    26072605    [TransformPath,TransformName,TransformExt]=fileparts(FileName);% removes extension .m
    26082606    if ~strcmp(TransformExt,'.m')
     
    26262624           TransformPathListUser{ilist-nb_builtin_transform}=TransformPathList{ilist};
    26272625       end
     2626       TransformPathListUser=TransformPathListUser';
     2627       TransformListUser=TransformListUser';
    26282628       save (profil_perso,'TransformPathListUser','TransformListUser','-append'); %store the root name for future opening of uvmat
    26292629   end
Note: See TracChangeset for help on using the changeset viewer.