Changeset 494 for trunk/src/civ.m


Ignore:
Timestamp:
Jul 19, 2012, 11:50:39 AM (12 years ago)
Author:
sommeria
Message:

various bugs corrected after testing in Windows OS. Introduction
of filter tps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r493 r494  
    2424%TODO: search range
    2525
    26 % Last Modified by GUIDE v2.5 13-Jul-2012 15:11:00
     26% Last Modified by GUIDE v2.5 18-Jul-2012 23:20:12
    2727% Begin initialization code - DO NOT EDIT
    2828gui_Singleton = 1;
     
    297297set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    298298RootPath=get(handles.RootPath,'String');
    299 SubdirImages=get(handles.SubdirImages,'String');
     299SubDirImages=get(handles.SubDirImages,'String');
    300300RootFile=get(handles.RootFile,'String');
    301301ref_i=str2num(get(handles.ref_i,'String'));
     
    303303NomType=get(handles.NomType,'String');
    304304ImaExt=get(handles.ImaExt,'String');
    305 fileinput=fullfile_uvmat(RootPath,SubdirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j);
     305fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j);
    306306errormsg=display_file_name(handles,fileinput);
    307307if ~isempty(errormsg)
     
    344344if strcmp(ExtInput,'.nc')
    345345    NomTypeNc=NomTypeInput;
    346     if isempty(regexp(NomTypeInput,'[ab|AB|-]'))
     346    if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once'))
    347347        set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs
    348348      %  [RootPath,SubDir]=fileparts(RootPath);
     
    435435% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    436436% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    437 [RootPath,SubdirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);
     437[RootPath,SubDirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);
    438438switch FileType
    439439    case {'image','multimage','video','mmreader'}
     
    443443end
    444444set(handles.RootPath,'String',RootPath)
    445 set(handles.SubdirImages,'String',SubdirImages)
     445set(handles.SubDirImages,'String',SubDirImages)
    446446set(handles.RootFile,'String',RootFile)
    447447if strcmp(ExtInput,'.nc')
    448     SubDirCiv=regexprep(SubDir,['^' SubdirImages],'');%suppress the root  SuddirImages;
     448    SubDirCiv=regexprep(SubDir,['^' SubDirImages],'');%suppress the root  SuddirImages;
    449449else
    450450    SubDirCiv= '.civ';
     
    460460MaxIndex_i=max(i1_series(i1_series>0));
    461461MaxIndex_j=max(j1_series(j1_series>0));
    462 
    463 %% fill reference indices from the input file indices
    464 num_ref_i=str2num(get(handles.ref_i,'String'));
    465 num_ref_j=str2num(get(handles.ref_j,'String'));
    466 % for movies don't modify except if the current ref is outside index bounds
    467 if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j)
    468     num_ref_i=i1;%default ref index
    469     if ~isempty(i2)
    470         num_ref_i=floor((num_ref_i+i2)/2);
    471     end
    472     num_ref_j=j1;
    473     if ~isempty(j2)
    474         num_ref_j=floor((num_ref_j+j2)/2);
    475     end
    476 end
    477462
    478463%% look for an image documentation file
     
    524509end
    525510if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
    526                set(handles.ListPairMode,'Value',1);
     511    set(handles.ListPairMode,'Value',1);
    527512    dt=1/get(MovieObject,'FrameRate');%time interval between successive frames
    528513    if strcmp(NomTypeIma,'*')
     
    533518        set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}])
    534519        MaxIndex_i=max(i1_series(i1_series>0));
    535         MaxIndex_j=get(MovieObject,'NumberOfFrames');   
     520        MaxIndex_j=get(MovieObject,'NumberOfFrames');
    536521        time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times
    537522        enable_j(handles,'on')
    538     end 
     523    end
    539524    TimeUnit='s';
    540525    set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter
     
    544529%show the reference image edit box if relevant (not needed for movies or in the absence of time information
    545530if numel(time)>=2 % if there are at least two time values to define dt
    546     MaxIndex_i=min(size(time,1),MaxIndex_i);
     531    MaxIndex_i=min(size(time,1),MaxIndex_i);%possibly adjust the max index according to time data
    547532    MaxIndex_j=min(size(time,2),MaxIndex_j);
    548533    time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices)
     
    563548set(handles.ImaExt,'String',ImaExt)
    564549set(handles.NomType,'String',NomTypeIma)
    565 set(handles.ref_i,'String',num2str(num_ref_i))
    566 set(handles.ref_j,'String',num2str(num_ref_j))
     550
     551%% set the reference indices from the input file indices
     552num_ref_i=str2num(get(handles.ref_i,'String'));
     553num_ref_j=str2num(get(handles.ref_j,'String'));
     554% for movies don't modify except if the current ref is outside index bounds
     555%if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j)
     556if ~isempty(i1)% if i1 has been selected by the input
     557    num_ref_i=i1;%default ref index
     558    if ~isempty(i2)
     559        num_ref_i=floor((num_ref_i+i2)/2);
     560    end
     561    if ~isempty(j1)
     562    num_ref_j=j1;
     563    if ~isempty(j2)
     564        num_ref_j=floor((num_ref_j+j2)/2);
     565    end
     566    end
     567end
     568if num_ref_i>MaxIndex_i||num_ref_i<MinIndex_i
     569    num_ref_i=round((MinIndex_i+MaxIndex_i)/2);
     570end
     571if ~isempty(num_ref_j)&&~isempty(MaxIndex_j)&& ~isempty(MinIndex_j)
     572    if (num_ref_j>MaxIndex_j||num_ref_j<MinIndex_j)
     573        num_ref_j=round((MinIndex_j+MaxIndex_j)/2);
     574    end
     575end
     576if isempty(num_ref_j)
     577    num_ref_j=1;
     578end
    567579
    568580%% update i and j index range if a nc file has been opened or pb withmin max image indices:
     
    570582first_i=str2num(get(handles.first_i,'String'));
    571583last_i=str2num(get(handles.last_i,'String'));
    572 if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i)
    573     set(handles.first_i,'String',num2str(num_ref_i));
    574     set(handles.last_i,'String',num2str(num_ref_i));%
    575 end
    576 if ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i
    577     set(handles.first_i,'String',num2str(num_ref_i));
    578     set(handles.last_i,'String',num2str(num_ref_i));%
     584if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i)||ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i
     585   first_i=num_ref_i;
     586   last_i=num_ref_i;
     587    set(handles.first_i,'String',num2str(first_i));
     588    set(handles.last_i,'String',num2str(last_i));%
    579589end
    580590
    581591%j index range
    582592first_j=str2num(get(handles.first_j,'String'));
    583 last_j=str2num(get(handles.last_i,'String'));
    584 if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j)
    585     set(handles.first_j,'String',num2str(num_ref_j));
    586     set(handles.last_j,'String',num2str(num_ref_j));%
    587 elseif ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j
    588     set(handles.first_j,'String',num2str(num_ref_j));
    589 set(handles.last_j,'String',num2str(num_ref_j));%
    590 end
     593last_j=str2num(get(handles.last_j,'String'));
     594if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j)||ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j
     595       first_j=num_ref_j;
     596   last_j=num_ref_j;
     597    set(handles.first_j,'String',num2str(first_j));
     598    set(handles.last_j,'String',num2str(last_j));%
     599end
     600if num_ref_i>last_i || num_ref_i<first_i
     601    num_ref_i=round((first_i+last_i)/2);
     602end
     603if num_ref_j>last_j || num_ref_j<first_j
     604    num_ref_j=round((first_j+last_j)/2);
     605end
     606set(handles.ref_i,'String',num2str(num_ref_i))
     607set(handles.ref_j,'String',num2str(num_ref_j))
    591608
    592609%% set the civ options depending on the input file content when a nc file has been opened
     
    11191136for bin_name=binary_list %loop on the list of binaries
    11201137    if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list
     1138        if ~isunix
     1139        Param.xml.(bin_name{1})=[regexprep(Param.xml.(bin_name{1}),'/','\') '.exe'];
     1140        end
    11211141        if exist(Param.xml.(bin_name{1}),'file')
    11221142            [path,name,ext]=fileparts(Param.xml.(bin_name{1}));
     
    11461166    end
    11471167end
    1148 display('files OK, processing...')
    11491168
    11501169%% set the list of files and check them
     
    11601179end
    11611180set(handles.civ,'UserData',filecell);%store for futur use of status callback
    1162 
     1181display('files OK, processing...')
    11631182
    11641183%% create subfolders for log, cmx, nml, xml, bat
     
    11711190end
    11721191
    1173    
    11741192%% get information on input images or movies
    11751193nbfield=numel(i1_civ1);
     
    11911209checkframe=strcmp(TimeUnit,'frame');
    11921210batch_file_list=[];%should be renamed file_list, can be used for xml or bash files
    1193  
     1211NomTypeIma=get(handles.NomType,'String');
    11941212for ifile=1:nbfield
    11951213    for j=1:nbslice
     
    12201238            Param.Civ1.ImageWidth=ImageInfoA_civ1.Width;
    12211239            Param.Civ1.ImageHeight=ImageInfoA_civ1.Height;
    1222             Param.Civ1.FrameIndexA=i1_civ1(ifile);
    1223             Param.Civ1.FrameIndexB=i2_civ1(ifile);
     1240            if strcmp(NomTypeIma,'*')
     1241                Param.Civ1.FrameIndexA=i1_civ1(ifile);
     1242                Param.Civ1.FrameIndexB=i2_civ1(ifile);
     1243            else% case of movies indexed with i, the frame index is then in j
     1244                Param.Civ1.FrameIndexA=j1_civ1(j);
     1245                Param.Civ1.FrameIndexB=j2_civ1(j);
     1246            end
    12241247            % read mask )parameters
    12251248            if Param.Civ1.CheckMask % the lines below should be changed with the new gui
     
    12941317            Param.Civ2.ImageWidth=ImageInfoA_civ2.Width;
    12951318            Param.Civ2.ImageHeight=ImageInfoA_civ2.Height;
    1296             Param.Civ2.FrameIndexA=i1_civ2(ifile);
    1297             Param.Civ2.FrameIndexB=i2_civ2(ifile);           
     1319            if strcmp(NomTypeIma,'*')
     1320                Param.Civ2.FrameIndexA=i1_civ2(ifile,j);
     1321                Param.Civ2.FrameIndexB=i2_civ2(ifile,j);
     1322            else% case of movies indexed with i, the frame index is then in j
     1323                Param.Civ2.FrameIndexA=j1_civ2(ifile,j);
     1324                Param.Civ2.FrameIndexB=j2_civ2(ifile,j);
     1325            end
    12981326        end
    12991327       
     
    16801708%% get the root name and check dir
    16811709RootPath=get(handles.RootPath,'String');
    1682 SubdirImages=get(handles.SubdirImages,'String');
     1710SubDirImages=get(handles.SubDirImages,'String');
    16831711RootFile=get(handles.RootFile,'String');
    1684 filecell.filebase=fullfile(RootPath,SubdirImages,RootFile);
     1712filecell.filebase=fullfile(RootPath,SubDirImages,RootFile);
    16851713if isempty(filecell.filebase)
    16861714    errormsg='please open an image with the upper menu option Open/Browse...';
     
    17031731% subdir_civ2=[ '.' subdir_civ2];
    17041732if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir
    1705 subdir_civ1=[SubdirImages '.' subdir_civ1];
    1706 subdir_civ2=[SubdirImages '.' subdir_civ2];
     1733subdir_civ1=[SubDirImages '.' subdir_civ1];
     1734subdir_civ2=[SubDirImages '.' subdir_civ2];
    17071735
    17081736%% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV
     
    19782006    for ifile=1:nbfield
    19792007        for j=1:nbslice
    1980              filename=fullfile_uvmat(RootPath,SubdirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j));
     2008             filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j));
    19812009            idetect(j)=exist(filename,'file')==2;
    19822010            filecell.ima1.civ1(ifile,j)={filename}; %first image
    1983             filename=fullfile_uvmat(RootPath,SubdirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j));
     2011            filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j));
    19842012            idetect_1(j)=exist(filename,'file')==2;
    19852013            filecell.ima2.civ1(ifile,j)={filename};%second image
     
    21962224        for ifile=1:nbfield
    21972225            for j=1:nbslice
    2198                 filename=fullfile_uvmat(RootPath,[],RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j));
     2226                filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j));
    21992227                idetect_2(j)=exist(filename,'file')==2;
    22002228                filecell.ima1.civ2(ifile,j)={filename};%first image
     
    22142242        for ifile=1:nbfield
    22152243            for j=1:nbslice
    2216                 filename=fullfile_uvmat(RootPath,[],RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j));
     2244                filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j));
    22172245                idetect_3(j)=exist(filename,'file')==2;
    22182246                filecell.ima2.civ2(ifile,j)={filename};%first image
     
    22712299    end
    22722300end
    2273 set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubdirImages],''));%suppress the root  SuddirImages;);%update the edit box
    2274 set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubdirImages],''));%update the edit box
     2301set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubDirImages],''));%suppress the root  SuddirImages;);%update the edit box
     2302set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubDirImages],''));%update the edit box
    22752303
    22762304% For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED
    22772305if strcmp(CivMode,'CivX')
    2278     if isequal(NomType_ima1,'*')%case of movie files
    2279         NomType_imanew1='_i';
    2280     else
    2281         NomType_imanew1=NomType_ima1;
    2282     end
    2283     if isequal(NomType_ima2,'*')%case of movie files
    2284         NomType_imanew2='_i';
    2285     else
    2286         NomType_imanew2=NomType_ima2;
    2287     end
     2306    NomType_imanew1=NomType_ima1;
     2307    NomType_imanew2=NomType_ima2;
    22882308    if ~isequal(ext_ima,'.png')
    2289         %%type of image file
    2290         type_ima1='none';%default
    2291         movieobject1=[];%default
    2292         if strcmpi(ext_ima,'.avi')
    2293             if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
    2294                 type_ima1='movie';
    2295                 movieobject1=mmreader([filecell.filebase ext_ima]);
    2296             else
    2297                 type_ima1='avi';
    2298             end
    2299         elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    2300             form=imformats(ext_ima(2:end));
    2301             if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2302                 if isequal(NomType_ima1,'*');
    2303                     type_ima1='multimage';%image series in a single image file
     2309        if checkbox(1) %if civ1 is performed
     2310             [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ1{1});
     2311            check_j=0;
     2312            if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage')
     2313                if max(j1_civ1)>1
     2314                    check_j=1;
     2315                    NomType_imanew1='_1_1';
    23042316                else
    2305                     type_ima1='image';
     2317                    NomType_imanew1='_1';
    23062318                end
    23072319            end
    2308         end
    2309         type_ima2='none';%default
    2310         movieobject2=[];
    2311         if strcmpi(ext_ima,'.avi')
    2312             if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)
    2313                 type_ima2='movie';
    2314                 movieobject2=mmreader([filecell.filebase ext_ima]);
    2315             else
    2316                 type_ima2='avi';
    2317             end
    2318         elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))
    2319             form=imformats(ext_ima(2:end));
    2320             if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    2321                 if isequal(NomType_ima1,'*');
    2322                     type_ima2='multimage';%image series in a single image file
    2323                 else
    2324                     type_ima2='image';
    2325                 end
    2326             end
    2327         end
    2328         if checkbox(1) %if civ1 is performed
    23292320            h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar
    23302321            for ifile=1:nbfield
    23312322                waitbar(ifile/nbfield);
    23322323                for j=1:nbslice
    2333                     filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));
     2324                    filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));
    23342325                    if ~exist(filename,'file')
    2335                         A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1);
    2336                         imwrite(A,filename,'BitDepth',16);
     2326                        if check_j
     2327                        A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ1(j));
     2328                        else
     2329                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ1(ifile));
     2330                        end
     2331                        imwrite(uint16(sum(A,3)),filename,'BitDepth',16);
    23372332                    end
    23382333                    filecell.ima1.civ1(ifile,j)={filename};
    2339                     filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j));
     2334                    filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew1,i2_civ1(ifile),[],j2_civ1(j));
    23402335                    if ~exist(filename,'file')
    2341                         A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2);
    2342                         imwrite(A,filename,'BitDepth',16);
     2336                         if check_j
     2337                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j2_civ1(j));
     2338                        else
     2339                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i2_civ1(ifile));
     2340                         end
     2341                        imwrite(uint16(sum(A,3)),filename,'BitDepth',16);
    23432342                    end
    23442343                    filecell.ima2.civ1(ifile,j)={filename};
     
    23482347        end
    23492348        if checkbox(4) %if civ2 is performed
     2349             [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ2{1});
     2350            check_j=0;
     2351            if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage')
     2352                if max(j1_civ2)>1
     2353                    check_j=1;
     2354                    NomType_imanew1='_1_1';
     2355                else
     2356                    NomType_imanew1='_1';
     2357                end
     2358            end
    23502359            h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar
    23512360            for ifile=1:nbfield
    23522361                waitbar(ifile/nbfield);
    23532362                for j=1:nbslice
    2354                     filename=fullfile_uvmat(RootPath,[],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));
     2363                    filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));
    23552364                    if ~exist(filename,'file')
    2356                         A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile));
    2357                         imwrite(A,filename,'BitDepth',16);
     2365                        if check_j
     2366                        A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j));
     2367                        else
     2368                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile));
     2369                        end
     2370                        imwrite(uint16(sum(A,3)),filename,'BitDepth',16);
    23582371                    end
    23592372                    filecell.ima1.civ2(ifile,j)={filename};
    2360                     filename=fullfile_uvmat(RootPath,[],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));
     2373                    filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));
    23612374                    if ~exist(filename,'file')
    2362                         A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile));
    2363                         imwrite(A,filename,'BitDepth',16);
     2375                        if check_j
     2376                        A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j));
     2377                        else
     2378                            A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile));
     2379                        end
     2380                        imwrite(uint16(sum(A,3)),filename,'BitDepth',16);
    23642381                    end
    23652382                    filecell.ima2.civ2(ifile,j)={filename};
     
    23732390%------------------------------------------------------------------------
    23742391% --- determine the list of index pairs of processing file
    2375 function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
     2392function [i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=...
    23762393    find_pair_indices(handles,ref_i,ref_j,mode)
    23772394%------------------------------------------------------------------------
     
    23942411if isequal (mode,'series(Di)')
    23952412    lastfield=str2double(get(handles.nb_field,'String'));
    2396     num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers
    2397     num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i));
    2398     num_a_civ1=ref_j;
    2399     num_b_civ1=ref_j;
    2400     num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i));
    2401     num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i));
    2402     num_a_civ2=ref_j;
    2403     num_b_civ2=ref_j;   
     2413    i1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers
     2414    i2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i));
     2415    j1_civ1=ref_j;
     2416    j2_civ1=ref_j;
     2417    i1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i));
     2418    i2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i));
     2419    j1_civ2=ref_j;
     2420    j2_civ2=ref_j;   
    24042421   
    24052422    % adjust the first and last field number
    24062423    lastfield=str2double(get(handles.nb_field,'String'));
    24072424    if isnan(lastfield)
    2408         indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1));
     2425        indsel=find((i1_civ1 >= 1)&(i1_civ2 >= 1));
    24092426    else
    2410         indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1));
     2427        indsel=find((i2_civ1 <= lastfield)&(i2_civ2 <= lastfield)&(i1_civ1 >= 1)&(i1_civ2 >= 1));
    24112428    end
    24122429    if length(indsel)>=1
     
    24162433        set(handles.last_i,'String',num2str(ref_i(lastind)))
    24172434        ref_i=ref_i(indsel);
    2418         num1_civ1=num1_civ1(indsel);
    2419         num1_civ2=num1_civ2(indsel);
    2420         num2_civ1=num2_civ1(indsel);
    2421         num2_civ2=num2_civ2(indsel);
     2435        i1_civ1=i1_civ1(indsel);
     2436        i1_civ2=i1_civ2(indsel);
     2437        i2_civ1=i2_civ1(indsel);
     2438        i2_civ2=i2_civ2(indsel);
    24222439    end
    24232440elseif isequal (mode,'series(Dj)')
    24242441    lastfield_j=str2double(get(handles.nb_field2,'String'));
    2425     num1_civ1=ref_i;% set of first image numbers
    2426     num2_civ1=ref_i;
    2427     num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j));
    2428     num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j));
    2429     num1_civ2=ref_i;
    2430     num2_civ2=ref_i;
    2431     num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j));
    2432     num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j));
     2442    i1_civ1=ref_i;% set of first image numbers
     2443    i2_civ1=ref_i;
     2444    j1_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j));
     2445    j2_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j));
     2446    i1_civ2=ref_i;
     2447    i2_civ2=ref_i;
     2448    j1_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j));
     2449    j2_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j));
    24332450    % adjust the first and last field number
    24342451    if isnan(lastfield_j)
    2435         indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1));
     2452        indsel=find((j1_civ1 >= 1)&(j1_civ2 >= 1));
    24362453    else
    2437         indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1));
     2454        indsel=find((j2_civ1 <= lastfield_j)&(j2_civ2 <= lastfield_j)&(j1_civ1 >= 1)&(j1_civ2 >= 1));
    24382455    end
    24392456    if length(indsel)>=1
     
    24432460        set(handles.last_j,'String',num2str(ref_j(lastind)))
    24442461        ref_j=ref_j(indsel);
    2445         num_a_civ1=num_a_civ1(indsel);
    2446         num_b_civ1=num_b_civ1(indsel);
    2447         num_a_civ2=num_a_civ2(indsel);
    2448         num_b_civ2=num_b_civ2(indsel);
     2462        j1_civ1=j1_civ1(indsel);
     2463        j2_civ1=j2_civ1(indsel);
     2464        j1_civ2=j1_civ2(indsel);
     2465        j2_civ2=j2_civ2(indsel);
    24492466    end
    24502467elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D)
    24512468    displ_num=get(handles.ListPairCiv1,'UserData');
    2452     num1_civ1=ref_i;
    2453     num2_civ1=ref_i;
    2454     num_a_civ1=displ_num(1,index_civ1);
    2455     num_b_civ1=displ_num(2,index_civ1);
    2456     num1_civ2=ref_i;
    2457     num2_civ2=ref_i;
    2458     num_a_civ2=displ_num(1,index_civ2);
    2459     num_b_civ2=displ_num(2,index_civ2);
     2469    i1_civ1=ref_i;
     2470    i2_civ1=ref_i;
     2471    j1_civ1=displ_num(1,index_civ1);
     2472    j2_civ1=displ_num(2,index_civ1);
     2473    i1_civ2=ref_i;
     2474    i2_civ2=ref_i;
     2475    j1_civ2=displ_num(1,index_civ2);
     2476    j2_civ2=displ_num(2,index_civ2);
    24602477elseif isequal(mode,'displacement')
    2461     num1_civ1=ref_i;
    2462     num2_civ1=ref_i;
    2463     num_a_civ1=ref_j;
    2464     num_b_civ1=ref_j;
    2465     num1_civ2=ref_i;
    2466     num2_civ2=ref_i;
    2467     num_a_civ2=ref_j;
    2468     num_b_civ2=ref_j;
     2478    i1_civ1=ref_i;
     2479    i2_civ1=ref_i;
     2480    j1_civ1=ref_j;
     2481    j2_civ1=ref_j;
     2482    i1_civ2=ref_i;
     2483    i2_civ2=ref_i;
     2484    j1_civ2=ref_j;
     2485    j2_civ2=ref_j;
    24692486end
    24702487
     
    26762693index_pair=get(handles.ListPairCiv1,'Value');
    26772694displ_num=get(handles.ListPairCiv1,'UserData');
    2678 % num_a=displ_num(1,index_pair);
    2679 % num_b=displ_num(2,index_pair);
    26802695list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs
    26812696if index_pair<=length(list_pair2)
     
    28162831
    28172832%% reads .nc subdirectoy and image numbers from the interface
    2818 SubDirImages=get(handles.SubdirImages,'String');
     2833SubDirImages=get(handles.SubDirImages,'String');
    28192834subdir_civ1=[SubDirImages get(handles.SubdirCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data
    28202835subdir_civ2=[SubDirImages get(handles.SubdirCiv2,'String')];%subdirectory subdir_civ2 for the netcdf data
    28212836ref_i=str2double(get(handles.ref_i,'String'));
     2837ref_j=[];
    28222838if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
    28232839    ref_j=0;
    2824 else
     2840elseif strcmp(get(handles.ref_j,'Visible'),'on')
    28252841    ref_j=str2double(get(handles.ref_j,'String'));
    2826     if isnan(ref_j)
    2827         ref_j=1;
    2828     end
     2842end
     2843if isempty(ref_j)
     2844    ref_j=1;
    28292845end
    28302846time=get(handles.ImaDoc,'UserData');%get the set of times
     
    28752891                testpair=1;
    28762892            else
    2877                 if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    2878                     errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1];
    2879                 else
     2893%                 if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
     2894%                     errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1];
     2895%                 else
    28802896                    errormsg=['no civ1 file available for the selected reference indices (i,j)= ' num2str(ref_i) ', ' num2str(ref_j) ' and subdirectory ' subdir_civ1];
    2881                 end
     2897%                 end
    28822898                set(handles.ListPairCiv1,'String',{''});
    28832899                %COMPLETER CAS STEREO
     
    35613577    ' -m ' nx_patch  ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB '  -xy  x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file
    35623578
    3563 %------------------------------------------------------------------------
    3564 %--read images and convert them to the uint16 format used for PIV
    3565 function A=read_image(filename,type_ima,num,movieobject)
    3566 %------------------------------------------------------------------------
    3567 %num is the view number needed for an avi movie
    3568 switch type_ima
    3569     case 'movie'
    3570         A=read(movieobject,num);
    3571     case 'avi'
    3572         mov=aviread(filename,num);
    3573         A=frame2im(mov(1));
    3574     case 'multimage'
    3575         A=imread(filename,num);
    3576     case 'image'
    3577         A=imread(filename);
    3578 end
    3579 siz=size(A);
    3580 if length(siz)==3;%color images
    3581     A=sum(double(A),3);
    3582     A=uint16(A);
    3583 end
     3579% %------------------------------------------------------------------------
     3580% %--read images and convert them to the uint16 format used for PIV
     3581% function A=read_image(filename,type_ima,num,movieobject)
     3582% %------------------------------------------------------------------------
     3583% %num is the view number needed for an avi movie
     3584% switch type_ima
     3585%     case 'movie'
     3586%         A=read(movieobject,num);
     3587%     case 'avi'
     3588%         mov=aviread(filename,num);
     3589%         A=frame2im(mov(1));
     3590%     case 'multimage'
     3591%         A=imread(filename,num);
     3592%     case 'image'
     3593%         A=imread(filename);
     3594% end
     3595% siz=size(A);
     3596% if length(siz)==3;%color images
     3597%     A=sum(double(A),3);
     3598%     A=uint16(A);
     3599% end
    35843600
    35853601
     
    38593875RootPath=get(handles.RootPath,'String');
    38603876RootFile=get(handles.RootFile,'String');
     3877SubDirImages=get(handles.SubDirImages,'String');
    38613878ref_i=str2num(get(handles.ref_i,'String'));
    38623879ref_j=str2num(get(handles.ref_j,'String'));
    38633880NomType=get(handles.NomType,'String');
    38643881ImaExt=get(handles.ImaExt,'String');
    3865 fileinput=fullfile_uvmat(RootPath,'',RootFile,ImaExt,NomType,ref_i,[],ref_j);
     3882fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j);
    38663883errormsg=display_file_name(handles,fileinput);
    38673884if ~isempty(errormsg)
     
    39573974function RootFile_Callback(hObject, eventdata, handles)
    39583975
    3959 function SubdirImages_Callback(hObject, eventdata, handles)
     3976function SubDirImages_Callback(hObject, eventdata, handles)
    39603977
    39613978
     
    41474164            else %Windows system
    41484165                filename=regexprep(filename,'\\','\\\\');
    4149                 cmd=['copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ1.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.civ1.cmx" \n')...
     4166                cmd=['copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ1.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')...
    41504167                    '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')...
    41514168                    regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_LOG\\\\$2.civ1.log" \n')... % redirect standard output to the log file
     
    42534270                    'rm ' regexprep(filename,'(.+)/(.+$)','$1/$2.cmx \n')];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx
    42544271            else
     4272                filename=regexprep(Param.OutputFile,'.nc','');
    42554273                filename=regexprep(filename,'\\','\\\\');
    42564274                cmd=[cmd 'copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ2.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')...
    4257                     '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')...
     4275                    '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')...
    42584276                     regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_LOG\\\\$2.civ2.log" \n')... % redirect standard output to the log file
    4259                     'del ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')];
    4260             end
     4277                    'del ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')];                       
     4278            end
     4279                 
    42614280        case 'CivAll'
    42624281            CivAllCmd=[CivAllCmd ' civ2 '];
     
    44414460
    44424461
    4443 
    4444 
    44454462%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    44464463% USELESS FUNCTIONS BELOW HERE,  TO CLEAN
    44474464%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4448 
    4449 
    4450 
    4451 
    44524465
    44534466%------------------------------------------------------------------------
     
    45464559
    45474560
    4548 
    45494561function nb_field2_Callback(hObject, eventdata, handles)
    4550 % hObject    handle to nb_field2 (see GCBO)
    4551 % eventdata  reserved - to be defined in a future version of MATLAB
    4552 % handles    structure with handles and user data (see GUIDATA)
    4553 
    4554 % Hints: get(hObject,'String') returns contents of nb_field2 as text
    4555 %        str2double(get(hObject,'String')) returns contents of nb_field2 as a double
    4556 
    45574562
    45584563
    45594564function last_j_Callback(hObject, eventdata, handles)
    4560 % hObject    handle to last_j (see GCBO)
    4561 % eventdata  reserved - to be defined in a future version of MATLAB
    4562 % handles    structure with handles and user data (see GUIDATA)
    4563 
    4564 % Hints: get(hObject,'String') returns contents of last_j as text
    4565 %        str2double(get(hObject,'String')) returns contents of last_j as a double
    4566 
    45674565
    45684566
    45694567function last_i_Callback(hObject, eventdata, handles)
    4570 % hObject    handle to last_i (see GCBO)
    4571 % eventdata  reserved - to be defined in a future version of MATLAB
    4572 % handles    structure with handles and user data (see GUIDATA)
    4573 
    4574 % Hints: get(hObject,'String') returns contents of last_i as text
    4575 %        str2double(get(hObject,'String')) returns contents of last_i as a double
     4568
Note: See TracChangeset for help on using the changeset viewer.