Changeset 840 for trunk/src


Ignore:
Timestamp:
Dec 10, 2014, 11:11:09 PM (6 years ago)
Author:
sommeria
Message:
 
Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/phys_ima.m

    r835 r840  
    4949    Calib=XmlData{icell}.GeometryCalib;
    5050    % rescaling of the image coordinates without change of the image array
    51     if strcmp(Calib.CalibrationType,'rescale') && isequal(Calib,CalibIn{1})
     51    if strcmp(Calib.CalibrationType,'rescale') && isequal(Calib,XmlData{1}.GeometryCalib)
    5252        A_out{icell}=A{icell};%no transform
    5353        Rangx=[0.5 npx-0.5];%image coordiantes of corners
  • trunk/src/series.m

    r832 r840  
    16571657            Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
    16581658        end
    1659         Param.InputTable{1}=regexprep(Param.InputTable{1},'\','/');%correct path name for PCWIN system
     1659        for ilist=1:size(Param.InputTable,1)
     1660        Param.InputTable{ilist,1}=regexprep(Param.InputTable{ilist,1},'\','/');%correct path name for PCWIN system
     1661        end
    16601662        % create, fill and save the xml parameter file
    16611663        t=struct2xml(Param);
  • trunk/src/series/civ2vel_3C.m

    r839 r840  
    127127[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    128128
     129%% grid of physical positions
     130[x,y]=meshgrid(ObjectData.RangeX(1):ObjectData.DX:ObjectData.RangeX(2),ObjectData.RangeY(1):ObjectData.DY:ObjectData.RangeY(2));
     131%camera coordinates:initialisation 2 cameras
     132NbCamera=2;
     133X=zeros(NbCamera,size(x,1),size(y,1));
     134Y=zeros(NbCamera,size(x,1),size(y,1));
     135for icamera=1:NbCamera
     136%camera coordinates
     137Calib=XmlData{1}.GeometryCalib;
     138    xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1);
     139    yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2);
     140    zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tx_Ty_Tz(3);
     141   
     142    %undistorted image coordinates
     143    X(icamera,:,:)=xc./zc;
     144    Y(icamera,:,:)=yc./zc;
     145end
     146
     147%% case of fixed planes (for moving interface, coeff need to be calculated for each field
     148if isequal(size(InputTable),2)
     149[S,D]=get_coeff(XmlData,X,Y);
     150end
     151
    129152 %% MAIN LOOP ON FIELDS
    130153for index=1:NbField
     
    154177       
    155178        %% transform the input field (e.g; phys) if requested (no transform involving two input fields)
     179            %camera coordinates
     180        xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1);
     181        yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2);
     182        zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tx_Ty_Tz(3);
     183
     184        %undistorted image coordinates
     185        Xu=xc./zc;
     186        Yu=yc./zc;
    156187        Data{iview}=phys(Data{iview},XmlData{iview});
    157188       
     
    346377display([file_st ' written'])
    347378
    348 
     379function [S,D]=get_coeff(XmlData,X,Y);
     380Calib_a=XmlData{1}.GeometryCalib;
     381R=(Calib_a.R)';%rotation matrix
     382A(1,1)=R(1)-R(7)*X;
     383A(1,2)=R(2)-R(8)*X;
     384A(1,3)=R(3)-R(9)*X;
     385A(2,1)=R(4)-R(7)*Y;
     386A(2,2)=R(5)-R(8)*Y;
     387A(2,3)=R(6)-R(9)*Y;
    349388
    350389%'pxcm_tsai': find differentials of the Tsai calibration
  • trunk/src/series/extract_rdvision.m

    r839 r840  
    7878    check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
    7979    ListDir=ListCells(1,find(check_dir & ~check_bad));
    80     InputTable=cell(numel(ListDir),5);
    81     InputTable(:,2)=ListDir';
     80    InputTable=cell(1,5);
     81%    InputTable(:,2)=ListDir';
    8282    isel=0;
    8383    for ilist=1:numel(ListDir)
     
    9191           isel=isel+1;
    9292           InputTable{isel,1}=RootPath;
     93           InputTable{isel,2}=ListDir{ilist};
    9394            RootFile=regexprep(ListCellSub{1,seq_index},'.seq$','');
    9495            InputTable{isel,3}=RootFile;
    95         end
    96         InputTable{isel,4}='*';
     96                    InputTable{isel,4}='*';
    9797        InputTable{isel,5}='.seq';
     98        end
     99
    98100    end
    99101    hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series'
     
    269271    [success,message]=copyfile(filexml,[filexml '~']);%make backup
    270272    if success~=1
    271         dips(['errror in xml file backup: ' message]);
     273        displ(['errror in xml file backup: ' message]);
    272274        return
    273275    end
     
    366368BitDepth=8*SeqData.bytesperpixel;%needed to write images (8 or 16 bits)
    367369binrepertoire=fullfile(PathDir,SeqData.binrepertoire);
    368 tic
    369 OutputDir=fullfile(PathDir,SeqData.sequencename)
     370OutputDir=fullfile(PathDir,SeqData.sequencename);
    370371if exist(OutputDir,'dir')
    371372    errormsg=[OutputDir ' already exist, delete it first'];
     
    376377    return%not able to create new image dir
    377378end
     379fid=0;
    378380for ii=1:SeqData.nb_frames
    379     fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx));
    380     if ii==1 || ~strcmp(fname,fname_prev) % open the bin file if not in use
    381         fid=fopen(fname,'rb');
     381    OutputFile=fullfile_uvmat(PathDir,SeqData.sequencename,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode
     382    if ~exist(OutputFile,'file')
     383        fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx));
     384        if fid==0 || ~strcmp(fname,fname_prev) % open the bin file if not in use
     385            if fid~=0
     386                fclose(fid);%close the previous bin file
     387            end
     388            fid=fopen(fname,'rb');
     389            fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
     390            NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose)
     391            BinSize(NbBinFile)=0;% strat counter for new bin file
     392        else
     393            %
     394            %         fid=fopen(fname,'rb');% open the new bin file
     395%             fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
     396        end
    382397        fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
    383         NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose)
    384         BinSize(NbBinFile)=0;% strat counter for new bin file
    385     else
    386         fclose(fid);%close the previous bin file
    387         fid=fopen(fname,'rb');% open the new bin file
    388         fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file
    389     end
    390     fname_prev=fname;
    391     A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image
    392     A=A';
    393     BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read
    394     j1=[];
    395     if ~isequal(nbfield2,1)
    396         j1=mod(ii-1,nbfield2)+1;
    397     end
    398     i1=floor((ii-1)/nbfield2)+1;
    399     OutputFile=fullfile_uvmat(PathDir,SeqData.sequencename,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode
    400     try
    401         imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images
    402         disp([OutputFile ' written']);
    403         [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a')
    404         if ~s
    405 %             disp_uvmat('ERROR',errormsg,checkrun);
     398        fname_prev=fname;
     399        A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image
     400        A=A';
     401        BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read
     402        j1=[];
     403        if ~isequal(nbfield2,1)
     404            j1=mod(ii-1,nbfield2)+1;
     405        end
     406        i1=floor((ii-1)/nbfield2)+1;
     407       
     408        try
     409            imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images
     410            disp([OutputFile ' written']);
     411            % [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a')
     412            %         if ~s
     413            % %             disp_uvmat('ERROR',errormsg,checkrun);
     414            %             return
     415            %         end
     416        catch ME
     417            errormsg=ME.message;
    406418            return
    407419        end
    408     catch ME
    409         errormsg=ME.message;
    410         return
    411420    end
    412421end
    413422fclose(fid)
    414 toc
     423
    415424
    416425
Note: See TracChangeset for help on using the changeset viewer.