Changeset 435


Ignore:
Timestamp:
May 31, 2012, 8:21:06 AM (12 years ago)
Author:
sommeria
Message:

civ improved to deal with movies. Introduction of a file type mmreader needed for Matlab 2009 (Videoreader not available)

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src

    • Property svn:ignore
      •  

        old new  
        44XML_SCHEMAS
        55bin
         6check_files.m
        67toolbox_calib
        78uvmat_doc
  • trunk/src/civ.m

    r427 r435  
     1
    12%'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch)
    23%------------------------------------------------------------------------
     
    6364        t=xmltree(xmlfile);
    6465        sparam=convert(t);
    65     catch
    66         errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr};
     66    catch ME
     67        errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message};
    6768    end
    6869else
     
    409410% end
    410411switch FileType
    411     case {'image','multimage','video'}
     412    case {'image','multimage','video','mmreader'}
    412413    otherwise
    413414        errormsg='invalid input file: enter an image, a movie or civ .nc file';
     
    10591060
    10601061
    1061 %------------------------------------------------------------------------
     1062%--------------orm----------------------------------------------------------
    10621063% --- Main lauch command, called by RUN and BATCH
    10631064function errormsg=launch_jobs(hObject, eventdata, handles, batch)
     
    12271228if ~strcmp(CivMode,'CivX')
    12281229    if Param.CheckCiv1
    1229     [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});
    1230     [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});
     1230        [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});
     1231        [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});
    12311232    end
    12321233    if Param.CheckCiv2
    1233     [Param.Civ2.FileTypeA,FileInfo,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1});
    1234     [Param.Civ2.FileTypeB,FileInfo,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1});
     1234        [Param.Civ2.FileTypeA,FileInfo,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1});
     1235        [Param.Civ2.FileTypeB,FileInfo,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1});
    12351236    end
    12361237end
     
    12711272        if Param.CheckCiv1
    12721273            % read image-dependent parameters
    1273             Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};
    1274             Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
     1274           
    12751275            if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j)
    12761276                Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1));
     
    12801280            Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2);
    12811281            if strcmp(CivMode,'CivX')
    1282             Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE?
    1283             Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);%
    1284             end
    1285             form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
    1286             if isempty(form)
    1287                 ImageInfo=get(VideoReader(filecell.ima1.civ1{1,1}));
     1282                Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE?
     1283                Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);%
     1284            end
     1285            if strcmp(Param.Civ1.FileTypeA,'video')|| strcmp(Param.Civ1.FileTypeA,'mmreader')
     1286                %   ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
     1287                ImageInfo=get(Param.Civ1.ImageA);
     1288                %                 elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
     1289                %                     ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
    12881290                Param.Civ1.ImageBitDepth=ImageInfo.BitsPerPixel/3;
     1291                if batch
     1292                    Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};%file name must be used for batch instead of video object
     1293                    Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
     1294                end
    12891295            else
     1296                Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};
     1297                Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
     1298                form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
    12901299                ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size
    12911300                Param.Civ1.ImageBitDepth=ImageInfo.BitDepth;
    12921301            end
     1302           
    12931303            Param.Civ1.ImageWidth=ImageInfo.Width;
    12941304            Param.Civ1.ImageHeight=ImageInfo.Height;
    1295             Param.Civ1.i1=i1_civ1(ifile);
    1296             Param.Civ1.i2=i2_civ1(ifile);
    1297             % read mask parameters
     1305            Param.Civ1.FrameIndexA=i1_civ1(ifile);
     1306            Param.Civ1.FrameIndexB=i2_civ1(ifile);
     1307            % read mask )parameters
    12981308            if Param.Civ1.CheckMask % the lines below should be changed with the new gui
    12991309                if ~exist(Param.Civ1.Mask,'file')
     
    13121322                        i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1;
    13131323                        Param.Civ1.Grid=[filecell.filebase '_' fullfile_uvmat('','',Param.Civ1.Grid,'.grid','_1',i1_grid)];
    1314 %                         Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')];
     1324                        %                         Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')];
    13151325                        if ~exist(Param.Civ1.GridName,'file')
    13161326                            errormsg='grid file absent for civ1';
     
    14241434        end
    14251435        if Param.CheckCiv2==1
    1426             Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};
    1427             Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
     1436            if strcmp(Param.Civ2.FileTypeA,'video')|| strcmp(Param.Civ2.FileTypeA,'mmreader')
     1437                %   ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
     1438                ImageInfo=get(Param.Civ2.ImageA);
     1439                %                 elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
     1440                %                     ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
     1441                Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3;
     1442                if batch
     1443                    Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};%file name must be used for batch instead of video object
     1444                    Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
     1445                end
     1446            else
     1447                Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};
     1448                Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
     1449                form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
     1450                ImageInfo=imfinfo(filecell.ima1.civ2{1,1});%read the first image to get the size
     1451                Param.Civ2.ImageBitDepth=ImageInfo.BitDepth;
     1452            end
     1453           
    14281454            if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j)
    14291455                Param.Civ2.Dt=time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1);
     
    14631489            form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
    14641490            if isempty(form)
    1465                 ImageInfo=get(VideoReader(filecell.ima1.civ2{1,1}));
     1491               % ImageInfo=get(VideoReader(fullfile());
    14661492                Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3;
    14671493            else
     
    14711497            Param.Civ2.ImageWidth=ImageInfo.Width;
    14721498            Param.Civ2.ImageHeight=ImageInfo.Height;
    1473             Param.Civ2.i1=i1_civ2(ifile);
    1474             Param.Civ2.i2=i2_civ2(ifile);
     1499            Param.Civ2.FrameIndexA=i1_civ2(ifile);
     1500             Param.Civ2.FrameIndexB=i2_civ2(ifile);
     1501%             Param.Civ2.i1=i1_civ2(ifile);
     1502%             Param.Civ2.i2=i2_civ2(ifile);
    14751503            switch CivMode
    14761504                case 'CivX'
     
    40004028    par_civ1.ImageHeight=size(Data.A,1);
    40014029    par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation
    4002     par_civ1.i1=i1;
    4003     par_civ1.i2=i2;
     4030    par_civ1.FrameIndexA=num2str(i1);
     4031    par_civ1.FrameIndexB=num2str(i2);
    40044032    Param.Civ1=par_civ1;
    40054033    Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV
  • trunk/src/civ_matlab.m

    r411 r435  
    5252check_patch1=0;%default
    5353
     54% case of input Param set by an xml file (batch mode)
    5455if ischar(Param)
    5556    Param=xml2struct(Param); %if Param is the name of an xml file, read this file as a Matlab structure
     57    if isfield(Param,'Civ1')
     58        if strcmp(Param.Civ1.FileTypeA,'video')
     59            Param.Civ1.ImageA=VideoReader(Param.Civ1.ImageA);
     60        elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
     61            Param.Civ1.ImageA=mmreader(Param.Civ1.ImageA);
     62        end
     63        if strcmp(Param.Civ1.FileTypeB,'video')
     64            Param.Civ1.ImageB=VideoReader(Param.Civ1.ImageB);
     65        elseif strcmp(Param.Civ1.FileTypeB,'mmreader')
     66            Param.Civ1.ImageB=mmreader(Param.Civ1.ImageB);
     67        end
     68    end
     69    if isfield(Param,'Civ2')
     70        if strcmp(Param.Civ2.FileTypeA,'video')
     71            Param.Civ2.ImageA=VideoReader(Param.Civ2.ImageA);
     72        elseif strcmp(Param.Civ2.FileTypeA,'mmreader')
     73            Param.Civ2.ImageA=mmreader(Param.Civ2.ImageA);
     74        end
     75         if strcmp(Param.Civ2.FileTypeB,'video')
     76            Param.Civ2.ImageB=VideoReader(Param.Civ2.ImageB);
     77        elseif strcmp(Param.Civ2.FileTypeB,'mmreader')
     78            Param.Civ2.ImageB=mmreader(Param.Civ2.ImageB);
     79        end
     80    end
    5681end
    5782
    5883%% Civ1
    5984if isfield (Param,'Civ1')
    60 %     check_civ1=1;% test for further use of civ1 results
     85    %     check_civ1=1;% test for further use of civ1 results
    6186    % %% prepare images
    6287    par_civ1=Param.Civ1;
     
    7297        end
    7398    else
    74         if isfield(par_civ1,'ImageA')&&(ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')) % case with no image: only the PIV grid is calculated
    75             [Field,ParamOut,errormsg] = read_field(par_civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.i1);
    76             par_civ1.ImageA=Field.A;%imread(par_civ1.ImageA);%[Field,ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num)
    77         end
    78         if isfield(par_civ1,'ImageB')&& (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageA),'VideoReader'))
    79             [Field,ParamOut,errormsg] = read_field(par_civ1.ImageB,par_civ1.FileTypeB,[],par_civ1.i2);
    80             par_civ1.ImageB=Field.A;%=imread(par_civ1.ImageB);
     99        if isfield(par_civ1,'ImageA')%&&(ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')) % case with no image: only the PIV grid is calculated
     100           
     101            [Field,ParamOut,errormsg] = read_field(par_civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.FrameIndexA);
     102            if ~isempty(errormsg)
     103                errormsg=['error in civ_matlab/read_field:' errormsg];
     104                return
     105            end
     106            par_civ1.ImageA=Field.A;%= image matrix A in the first input field
     107        end
     108        if isfield(par_civ1,'ImageB')%&& (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageA),'VideoReader'))
     109            [Field,ParamOut,errormsg] = read_field(par_civ1.ImageB,par_civ1.FileTypeB,[],par_civ1.FrameIndexB);
     110            if ~isempty(errormsg)
     111                errormsg=['error in civ_matlab/read_field:' errormsg];
     112                return
     113            end
     114            par_civ1.ImageB=Field.A;%= image matrix A in the second input field
    81115        end
    82116    end
     
    121155    Data.Civ1_C=reshape(ctable,[],1);
    122156    Data.Civ1_F=reshape(F,[],1);
    123     Data.CivStage=1; 
     157    Data.CivStage=1;
    124158else
    125159    if exist('ncfile','var')
     
    162196        Data.VarDimName=[Data.VarDimName {'nb_vec_1'}];
    163197        nbvar=length(Data.ListVarName);
    164         Data.VarAttribute{nbvar}.Role='errorflag';   
     198        Data.VarAttribute{nbvar}.Role='errorflag';
    165199        Data.Civ1_FF=fix(Param.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V);
    166         Data.CivStage=2;   
    167     end
    168 end   
     200        Data.CivStage=2;
     201    end
     202end
    169203%% Patch1
    170204if isfield (Param,'Patch1')
     
    180214    nbvar=length(Data.ListVarName);
    181215    Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
    182         Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},{'nb_subdomain_1'},...
    183              {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}];
     216    Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},{'nb_subdomain_1'},...
     217        {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}];
    184218    Data.VarAttribute{nbvar+1}.Role='vector_x';
    185219    Data.VarAttribute{nbvar+2}.Role='vector_y';
     
    191225    if isfield(Data,'Civ1_FF')
    192226        ind_good=find(Data.Civ1_FF==0);
    193     else 
     227    else
    194228        ind_good=1:numel(Data.Civ1_X);
    195229    end
    196230    [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
    197             filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold);
    198       fill=zeros(3,2,size(Data.Civ1_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
    199       Data.Civ1_Coord_tps=cat(1,Data.Civ1_Coord_tps,fill);
    200       Data.Civ1_U_smooth(ind_good)=Ures;
    201       Data.Civ1_V_smooth(ind_good)=Vres;
    202       Data.Civ1_FF(ind_good)=FFres;
    203       Data.CivStage=3;                             
    204 end   
     231        filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold);
     232    fill=zeros(3,2,size(Data.Civ1_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
     233    Data.Civ1_Coord_tps=cat(1,Data.Civ1_Coord_tps,fill);
     234    Data.Civ1_U_smooth(ind_good)=Ures;
     235    Data.Civ1_V_smooth(ind_good)=Vres;
     236    Data.Civ1_FF(ind_good)=FFres;
     237    Data.CivStage=3;
     238end
    205239
    206240%% Civ2
     
    209243    if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageA,par_civ2.ImageA)
    210244        %read first image if not already done for civ1
    211         [Field,ParamOut,errormsg] = read_field(par_civ2.ImageA,par_civ2.FileTypeA,[],par_civ2.i1);
     245        [Field,ParamOut,errormsg] = read_field(par_civ2.ImageA,par_civ2.FileTypeA,[],par_civ2.FrameIndexA);
     246                    if ~isempty(errormsg)
     247                errormsg=['error in civ_matlab/read_field:' errormsg];
     248                return
     249            end
    212250        par_civ2.ImageA=Field.A;
    213251    else
     
    216254    if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageB,par_civ2.ImageB)
    217255        %read first image if not already done for civ1
    218         [Field,ParamOut,errormsg] = read_field(par_civ2.ImageB,par_civ2.FileTypeB,[],par_civ2.i2);
     256        [Field,ParamOut,errormsg] = read_field(par_civ2.ImageB,par_civ2.FileTypeB,[],par_civ2.FrameIndexB);
     257         if ~isempty(errormsg)
     258                errormsg=['error in civ_matlab/read_field:' errormsg];
     259                return
     260            end
    219261        par_civ2.ImageB=Field.A;
    220262    else
     
    233275    [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy);
    234276    GridX=reshape(GridX,[],1);
    235     GridY=reshape(GridY,[],1); 
     277    GridY=reshape(GridY,[],1);
    236278    Shiftx=zeros(size(GridX));% shift expected from civ1 data
    237279    Shifty=zeros(size(GridX));
     
    270312    par_civ2.Shiftx=Shiftx(nbval>=1)./nbval(nbval>=1);
    271313    par_civ2.Shifty=Shifty(nbval>=1)./nbval(nbval>=1);
    272     par_civ2.Grid=[GridX(nbval>=1)-par_civ2.Shiftx/2 GridY(nbval>=1)-par_civ2.Shifty/2];% grid taken at the extrapolated origin of the displacement vectors   
     314    par_civ2.Grid=[GridX(nbval>=1)-par_civ2.Shiftx/2 GridY(nbval>=1)-par_civ2.Shifty/2];% grid taken at the extrapolated origin of the displacement vectors
    273315    if par_civ2.CheckDeformation
    274316        par_civ2.DUDX=DUDX./nbval;
     
    279321    % caluclate velocity data (y and v in indices, reverse to y component)
    280322    [xtable ytable utable vtable ctable F] = civ (par_civ2);
    281 %     diff_squared=(utable-par_civ2.Shiftx).*(utable-par_civ2.Shiftx)+(vtable+par_civ2.Shifty).*(vtable+par_civ2.Shifty);
    282 %     F(diff_squared>=4)=4; %flag vectors whose distance to the guess exceeds 2 pixels
     323    %     diff_squared=(utable-par_civ2.Shiftx).*(utable-par_civ2.Shiftx)+(vtable+par_civ2.Shifty).*(vtable+par_civ2.Shifty);
     324    %     F(diff_squared>=4)=4; %flag vectors whose distance to the guess exceeds 2 pixels
    283325    list_param=(fieldnames(Param.Civ2))';
    284326    list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'};
     
    300342    end
    301343    Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param {'Civ2_Time','Civ2_Dt'}];
    302 %     Data.Civ2_Time=par_civ2.Time;
    303 %     Data.Civ2_Dt=par_civ2.Dt;
     344    %     Data.Civ2_Time=par_civ2.Time;
     345    %     Data.Civ2_Dt=par_civ2.Dt;
    304346    nbvar=numel(Data.ListVarName);
    305347    Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];%  cell array containing the names of the fields to record
     
    340382        Data.VarDimName=[Data.VarDimName {'nb_vec_2'}];
    341383        nbvar=length(Data.ListVarName);
    342         Data.VarAttribute{nbvar}.Role='errorflag';   
     384        Data.VarAttribute{nbvar}.Role='errorflag';
    343385        Data.Civ2_FF=fix(Param.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V);
    344         Data.CivStage=Data.CivStage+1;   
     386        Data.CivStage=Data.CivStage+1;
    345387    end
    346388   
    347 end   
     389end
    348390
    349391%% Patch2
     
    356398    Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbSites','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
    357399    Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2',{'nb_coord','nb_bounds','nb_subdomain_2'},{'nb_subdomain_2'},...
    358              {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}];
    359 
    360         Data.VarAttribute{nbvar+1}.Role='vector_x';
     400        {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}];
     401   
     402    Data.VarAttribute{nbvar+1}.Role='vector_x';
    361403    Data.VarAttribute{nbvar+2}.Role='vector_y';
    362404    Data.VarAttribute{nbvar+5}.Role='coord_tps';
     
    369411    else
    370412        ind_good=1:numel(Data.Civ2_X);
    371     end 
     413    end
    372414    [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
    373          filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold);
    374            fill=zeros(3,2,size(Data.Civ2_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
    375       Data.Civ2_Coord_tps=cat(1,Data.Civ2_Coord_tps,fill);
     415        filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold);
     416    fill=zeros(3,2,size(Data.Civ2_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
     417    Data.Civ2_Coord_tps=cat(1,Data.Civ2_Coord_tps,fill);
    376418    Data.Civ2_U_smooth(ind_good)=Ures;
    377419    Data.Civ2_V_smooth(ind_good)=Vres;
    378420    Data.Civ2_FF(ind_good)=FFres;
    379     Data.CivStage=Data.CivStage+1;                             
    380 end 
     421    Data.CivStage=Data.CivStage+1;
     422end
    381423
    382424%% write result in a netcdf file if requested
  • trunk/src/find_file_series.m

    r421 r435  
    5252% ifile_min=1;%default
    5353[FileType,FileInfo,Object]=get_file_type(fullfileinput);
    54 if strcmp( FileType,'multimage')||strcmp( FileType,'video')
     54if strcmp( FileType,'multimage')||strcmp( FileType,'video')||strcmp( FileType,'mmreader')
    5555    NomType='*';
    5656    i1_series=(1:FileInfo.NumberOfFrames)';
  • trunk/src/get_file_type.m

    r397 r435  
    7474                        FileInfo.NumberOfFrames=get(VideoObject,'NumberOfFrames');
    7575                        FileType='video';
     76                    elseif exist('mmreader.m','file')% Matlab 2009a
     77                        VideoObject=mmreader(fileinput);
     78                        FileInfo.NumberOfFrames=get(VideoObject,'NumberOfFrames');
     79                        FileType='mmreader';
    7680                    end             
    7781                end
  • trunk/src/read_field.m

    r406 r435  
    150150% %             ParamOut.FieldList={'get_field...'};
    151151%         end   
    152     case 'video'
     152    case {'video','mmreader'}
    153153        try
    154154            A=read(ObjectName,num);
    155155        catch ME
    156             errormsg=ME.message
     156            errormsg=ME.message;
    157157            return
    158158        end
  • trunk/src/uvmat.m

    r434 r435  
    15281528UvData=get(handles.uvmat,'UserData');
    15291529
    1530 while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
     1530while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
    15311531        errormsg=runpm(hObject,eventdata,handles,increment);
    15321532        if ~isempty(errormsg)
     
    15551555UvData=get(handles.uvmat,'UserData');
    15561556
    1557 while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
     1557while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
    15581558        errormsg=runpm(hObject,eventdata,handles,increment);
    15591559        if ~isempty(errormsg)
     
    20342034                end
    20352035            end
    2036         case 'video'
     2036        case {'video','mmreader'}
    20372037            ObjectName=UvData.MovieObject{1};         
    20382038        case 'vol' %TODO: update
     
    20942094                end
    20952095            end
    2096         case 'video'
     2096        case {'video','mmreader'}
    20972097            Name=UvData.MovieObject{2};
    20982098        case 'vol' %TODO: update
     
    24062406
    24072407%% get bounds and mesh (needed for mouse action and to open set_object)
    2408 XName=''; %default
    2409 YName='';
    2410 if ~isempty(VarType{imax}.coord_x)
    2411     XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
    2412     DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable
    2413     nbpoints_x=DimValue(DimIndex(NbDim));
    2414       %unstructured coordinates
    2415     if ~isempty(VarType{imax}.coord_y) 
     2408if NbDim>1
     2409    XName=''; %default
     2410    YName='';
     2411    %unstructured coordinates
     2412    if ~isempty(VarType{imax}.coord_x)&&~isempty(VarType{imax}.coord_y)
     2413        XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
    24162414        YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
    24172415        %nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors)
     
    24222420            NbDim=2;
    24232421        end
    2424     end
    2425 %structured coordinate   
    2426 elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0
    2427     XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
    2428     if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0
    2429         YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
    2430     end
    2431    % VarIndex=CellVarIndex{imax}; % list of variable indices
    2432     DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable
    2433     nbpoints_x=DimValue(DimIndex(NbDim));
    2434     XMax=nbpoints_x;%default
    2435     XMin=1;%default
    2436 end
    2437 
    2438 if NbDim==3
    2439     if ~test_x
    2440         ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
    2441     end
    2442     ZMax=max(UvData.Field.(ZName));
    2443     ZMin=min(UvData.Field.(ZName));
    2444     UvData.Field.ZMax=ZMax;
    2445     UvData.Field.ZMin=ZMin;
    2446     test_z=1;
    2447     if isequal(ZMin,ZMax)%no z dependency
    2448         NbDim=2;
    2449         test_z=0;
    2450     end
    2451 end
    2452 if ~isempty (XName)
    2453     XMax=max(max(UvData.Field.(XName)));
    2454     XMin=min(min(UvData.Field.(XName)));
    2455     UvData.Field.NbDim=NbDim;
    2456     UvData.Field.XMax=XMax;
    2457     UvData.Field.XMin=XMin;
    2458     if NbDim >1&& ~isempty(YName)
    2459         YMax=max(max(UvData.Field.(YName)));
    2460         YMin=min(min(UvData.Field.(YName)));
    2461         UvData.Field.YMax=YMax;
    2462         UvData.Field.YMin=YMin;
    2463     end
    2464     nbvec=length(UvData.Field.(XName));
    2465     if test_x %unstructured coordinates
    2466         if test_z
    2467             UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
    2468             UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
    2469         else
    2470             UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
    2471         end
    2472     end
    2473 end
    2474 % case of structured coordinates
    2475 if ~test_x
    2476     DX=(XMax-XMin)/(nbpoints_x-1);
    2477     if NbDim >1
    2478         nbpoints_y=DimValue(DimIndex(NbDim-1));
    2479         if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index
    2480             DY=1;
    2481             UvData.Field.YMax=nbpoints_y;
    2482             UvData.Field.YMin=1;
    2483         else
    2484             DY=(YMax-YMin)/(nbpoints_y-1);
    2485         end
    2486     end
     2422        %structured coordinate
     2423    elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0
     2424        XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
     2425        if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0
     2426            YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
     2427        end
     2428        % VarIndex=CellVarIndex{imax}; % list of variable indices
     2429        DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable
     2430        nbpoints_x=DimValue(DimIndex(NbDim));
     2431        XMax=nbpoints_x;%default
     2432        XMin=1;%default
     2433    end
     2434   
    24872435    if NbDim==3
    2488         nbpoints_z=DimValue(DimIndex(1));
    2489         DZ=(ZMax-ZMin)/(nbpoints_z-1);
    2490         UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
     2436        if ~test_x
     2437            ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
     2438        end
     2439        ZMax=max(UvData.Field.(ZName));
     2440        ZMin=min(UvData.Field.(ZName));
    24912441        UvData.Field.ZMax=ZMax;
    24922442        UvData.Field.ZMin=ZMin;
     2443        test_z=1;
     2444        if isequal(ZMin,ZMax)%no z dependency
     2445            NbDim=2;
     2446            test_z=0;
     2447        end
     2448    end
     2449    if ~isempty (XName)
     2450        XMax=max(max(UvData.Field.(XName)));
     2451        XMin=min(min(UvData.Field.(XName)));
     2452        UvData.Field.NbDim=NbDim;
     2453        UvData.Field.XMax=XMax;
     2454        UvData.Field.XMin=XMin;
     2455        if NbDim >1&& ~isempty(YName)
     2456            YMax=max(max(UvData.Field.(YName)));
     2457            YMin=min(min(UvData.Field.(YName)));
     2458            UvData.Field.YMax=YMax;
     2459            UvData.Field.YMin=YMin;
     2460        end
     2461        nbvec=length(UvData.Field.(XName));
     2462        if test_x %unstructured coordinates
     2463            if test_z
     2464                UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
     2465                UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
     2466            else
     2467                UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
     2468            end
     2469        end
     2470    end
     2471    % case of structured coordinates
     2472    if ~test_x
     2473        DX=(XMax-XMin)/(nbpoints_x-1);
     2474        if NbDim >1
     2475            nbpoints_y=DimValue(DimIndex(NbDim-1));
     2476            if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index
     2477                DY=1;
     2478                UvData.Field.YMax=nbpoints_y;
     2479                UvData.Field.YMin=1;
     2480            else
     2481                DY=(YMax-YMin)/(nbpoints_y-1);
     2482            end
     2483        end
     2484        if NbDim==3
     2485            nbpoints_z=DimValue(DimIndex(1));
     2486            DZ=(ZMax-ZMin)/(nbpoints_z-1);
     2487            UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
     2488            UvData.Field.ZMax=ZMax;
     2489            UvData.Field.ZMin=ZMin;
     2490        else
     2491            UvData.Field.Mesh=DX;%sqrt(DX*DY);
     2492        end
     2493    end
     2494    % adjust the mesh to a value 1, 2 , 5 *10^n
     2495    ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
     2496    if UvData.Field.Mesh/ord>=5
     2497        UvData.Field.Mesh=5*ord;
     2498    elseif UvData.Field.Mesh/ord>=2
     2499        UvData.Field.Mesh=2*ord;
    24932500    else
    2494         UvData.Field.Mesh=DX;%sqrt(DX*DY);
    2495     end
    2496 end
    2497 % adjust the mesh to a value 1, 2 , 5 *10^n
    2498 ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
    2499 if UvData.Field.Mesh/ord>=5
    2500     UvData.Field.Mesh=5*ord;
    2501 elseif UvData.Field.Mesh/ord>=2
    2502     UvData.Field.Mesh=2*ord;
    2503 else
    2504     UvData.Field.Mesh=ord;
    2505 end
    2506 UvData.Object{1}.Type='plane';%main plotting plane
    2507 UvData.Object{1}.ProjMode='projection';%main plotting plane
    2508 UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
    2509 UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
    2510 
    2511 %% 3D case (menuvolume)
    2512 if NbDim==3% && UvData.NewSeries
    2513     test_set_object=1;
    2514     hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
    2515     ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
    2516     ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    2517     if ~isempty(hset_object) %if set_object is detected
    2518           delete(hset_object);% delete the GUI set_object if it does not fit
    2519     end
    2520     if test_set_object% reinitiate the GUI set_object
    2521         delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
    2522         UvData.Object{1}.NbDim=NbDim;%test for 3D objects
    2523         UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
    2524         UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
    2525         UvData.Object{1}.Angle=[0 0 0];
    2526         UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
    2527         UvData.Object{1}.Name='1-PLANE';
    2528         UvData.Object{1}.enable_plot=1;
    2529         set_object(UvData.Object{1},handles,ZBounds);
    2530         set(handles.ListObject,'Value',1);
    2531         set(handles.ListObject,'String',{'1-PLANE'});
    2532         set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
    2533         edit_object_Callback([],[], handles)
    2534     end
    2535     %multilevel case (single menuplane in a 3D space)
    2536 elseif isfield(UvData,'Z')
    2537     if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
    2538         XmlData=UvData.XmlData{1};
    2539         if isfield(XmlData,'PlanePos')
    2540             UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
    2541         end
    2542         if isfield(XmlData,'PlaneAngle')
    2543             siz=size(XmlData.PlaneAngle);
    2544             indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
    2545             UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
    2546         end
    2547     elseif isfield(UvData,'ZIndex')
    2548         UvData.Object{1}.ZObject=UvData.ZIndex;
    2549     end
    2550 end
     2501        UvData.Field.Mesh=ord;
     2502    end
     2503    UvData.Object{1}.Type='plane';%main plotting plane
     2504    UvData.Object{1}.ProjMode='projection';%main plotting plane
     2505    UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
     2506    UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
     2507   
     2508    %% 3D case (menuvolume)
     2509    if NbDim==3% && UvData.NewSeries
     2510        test_set_object=1;
     2511        hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
     2512        ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
     2513        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
     2514        if ~isempty(hset_object) %if set_object is detected
     2515            delete(hset_object);% delete the GUI set_object if it does not fit
     2516        end
     2517        if test_set_object% reinitiate the GUI set_object
     2518            delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
     2519            UvData.Object{1}.NbDim=NbDim;%test for 3D objects
     2520            UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
     2521            UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
     2522            UvData.Object{1}.Angle=[0 0 0];
     2523            UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
     2524            UvData.Object{1}.Name='1-PLANE';
     2525            UvData.Object{1}.enable_plot=1;
     2526            set_object(UvData.Object{1},handles,ZBounds);
     2527            set(handles.ListObject,'Value',1);
     2528            set(handles.ListObject,'String',{'1-PLANE'});
     2529            set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
     2530            edit_object_Callback([],[], handles)
     2531        end
     2532        %multilevel case (single menuplane in a 3D space)
     2533    elseif isfield(UvData,'Z')
     2534        if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
     2535            XmlData=UvData.XmlData{1};
     2536            if isfield(XmlData,'PlanePos')
     2537                UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
     2538            end
     2539            if isfield(XmlData,'PlaneAngle')
     2540                siz=size(XmlData.PlaneAngle);
     2541                indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
     2542                UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
     2543            end
     2544        elseif isfield(UvData,'ZIndex')
     2545            UvData.Object{1}.ZObject=UvData.ZIndex;
     2546        end
     2547    end
     2548end
     2549
    25512550testnewseries=UvData.NewSeries;
    25522551UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
Note: See TracChangeset for help on using the changeset viewer.