Changeset 493 for trunk/src


Ignore:
Timestamp:
Jul 16, 2012, 10:44:12 AM (12 years ago)
Author:
sommeria
Message:

various bugs repaired, tests in Windows OS

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r492 r493  
    341341
    342342%% case of netcdf file as input, get the civ processing stage and look for a coresponding image
     343imageinput=fileinput;%default
    343344if strcmp(ExtInput,'.nc')
    344345    NomTypeNc=NomTypeInput;
     
    351352        set(handles.RootFile_1,'Visible','Off');
    352353    end
     354    imageinput='';
    353355    Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB','fix','patch','civ2','fix2');
    354356    if isfield(Data,'Txt')
     
    359361    if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data,
    360362        set(handles.Program,'Value',2) %select civ/Matlab by default
    361         ListProgram_Callback([],[], handles)
     363        Program_Callback([],[], handles)
    362364        if ~isempty(Data.CivStage)%test for civ files
    363365            ind_opening=Data.CivStage;
     
    404406        end
    405407    end
     408    if ~exist(imageinput,'file')
    406409    imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1);
     410    end
    407411end
    408412
     
    419423            '*.*',  'All Files (*.*)'};
    420424        [FileName, PathName] = uigetfile( menu, 'Pick an input image file',fileparts(fileparts(fileinput)));
    421         fileinput=[PathName FileName];%complete file name
    422         if ~exist(fileinput,'file')
     425        imageinput=[PathName FileName];%complete file name
     426        if ~exist(imageinput,'file')
    423427            return %abandon of the browser is cancelled
    424428        end
     
    428432
    429433%% scan the image file series
    430 [FilePath,FileName,ImaExt]=fileparts(fileinput);
     434[FilePath,FileName,ImaExt]=fileparts(imageinput);
    431435% detect the file type, get the movie object if relevant, and look for the corresponding file series:
    432436% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    433 [RootPath,SubdirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject,i1,i2,j1,j2]=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]);
    434438switch FileType
    435439    case {'image','multimage','video','mmreader'}
     
    442446set(handles.RootFile,'String',RootFile)
    443447if strcmp(ExtInput,'.nc')
    444     SubDirCiv=regexprep(SubDir,[SubdirImages '^'],'');%suppress the root  SuddirImages;
     448    SubDirCiv=regexprep(SubDir,['^' SubdirImages],'');%suppress the root  SuddirImages;
    445449else
    446450    SubDirCiv= '.civ';
     
    450454browse=get(handles.RootPath,'UserData');
    451455browse.incr_pair=[0 0];%default
    452 
    453 %% fill reference indices from the input file indices
    454 num_ref_i=i1;%efaulmt ref index
    455 if ~isempty(i2)
    456     num_ref_i=floor((num_ref_i+i2)/2);
    457 end
    458 num_ref_j=j1;
    459 if ~isempty(j2)
    460     num_ref_j=floor((num_ref_j+j2)/2);
    461 end
    462456
    463457%% scan the images if a civ file has been opened
     
    467461MaxIndex_j=max(j1_series(j1_series>0));
    468462
     463%% fill reference indices from the input file indices
     464num_ref_i=str2num(get(handles.ref_i,'String'));
     465num_ref_j=str2num(get(handles.ref_j,'String'));
     466% for movies don't modify except if the current ref is outside index bounds
     467if 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
     476end
     477
    469478%% look for an image documentation file
    470479XmlFileName=find_imadoc(RootPath,SubDir,RootFile,ImaExt);
    471 % SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
    472 % filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
    473 % if ~exist(filexml,'file')
    474 %     filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
    475 %     if ~exist(filexml,'file')
    476 %         filexml=fullfile(RootPath,SubDir,[RootFile '.civ']);%very old convention: .civ file
    477 %         if ~exist(filexml,'file')
    478 %             filexml='';
    479 %         end
    480 %     end
    481 % end
    482480if isempty(XmlFileName)
    483481    if (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
     
    501499    [XmlData,warntext]=imadoc2struct(XmlFileName);
    502500    nom_type_read=[];
    503 %     if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
    504 %         [~,tild,tild,tild,tild,tild,tild,tild,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName);
    505 %         fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
    506 %         if ~exist(fullname,'file')
    507 %             msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
    508 %         end
    509 %     end
    510501    if isfield(XmlData,'Time') && ~isempty(XmlData.Time)
    511502        time=XmlData.Time;
     
    10791070end% default configuration
    10801071if ~isfield(s,'RunParam')
    1081     s.RunParam.Civ1Bin='bin/civ1';
    1082     s.RunParam.Civ2Bin='bin/civ2';
    1083     s.RunParam.FixBin='bin/fix_flag';
    1084     s.RunParam.PatchBin='bin/patch_up';
    1085     s.RunParam.CivmBin='bin/civ_matlab';
     1072    Param.xml.Civ1Bin=fullfile('bin','civ1');
     1073    Param.xml.Civ2Bin=fullfile('bin','civ2');
     1074    Param.xml.FixBin=fullfile('bin','fix_flag');
     1075    Param.xml.PatchBin=fullfile('bin','patch_up');
     1076    Param.xml.CivmBin=fullfile('bin','civ_matlab');
    10861077end
    10871078if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster
     
    10961087        end
    10971088    else
    1098         %standard configuration
    1099         Param.xml.Civ1Bin='bin/civ1';
    1100         Param.xml.Civ2Bin='bin/civ2';
    1101         Param.xml.FixBin='bin/fix_flag';
    1102         Param.xml.PatchBin='bin/patch_up';
    1103         s.RunParam.CivmBin='bin/civ_matlab';
     1089        %default configuration
     1090        Param.xml.Civ1Bin=fullfile('bin','civ1');
     1091        Param.xml.Civ2Bin=fullfile('bin','civ2');
     1092        Param.xml.FixBin=fullfile('bin','fix_flag');
     1093        Param.xml.PatchBin=fullfile('bin','patch_up');
     1094        Param.xml.CivmBin=fullfile('bin','civ_matlab');
    11041095        Param.xml.BatchMode='oar';% TODO : allow choice for sge
    11051096    end
     
    11071098    if isfield(s,'RunParam')
    11081099        Param.xml=s.RunParam;
    1109     else %standard default configuration
    1110         s.RunParam.Civ1Bin='bin/civ1';
    1111         s.RunParam.Civ2Bin='bin/civ2';
    1112         s.RunParam.FixBin='bin/fix_flag';
    1113         s.RunParam.PatchBin='bin/patch_up';
    1114         s.RunParam.CivmBin='bin/civ_matlab';
     1100    else %default configuration
     1101        Param.xml.Civ1Bin=fullfile('bin','civ1');
     1102        Param.xml.Civ2Bin=fullfile('bin','civ2');
     1103        Param.xml.FixBin=fullfile('bin','fix_flag');
     1104        Param.xml.PatchBin=fullfile('bin','patch_up');
     1105        Param.xml.CivmBin=fullfile('bin','civ_matlab');
    11151106    end
    11161107end
    11171108
    11181109%% check if the binaries exist : to move in civ_opening
    1119 % ListProgram=get(handles.Program,'String');
    1120 % Param.CivMode=ListProgram{get(handles.Program,'Value')};
    11211110binary_list={};
    11221111switch Param.Program
     
    19501939                for j=1:nbslice
    19511940                     filename=fullfile_uvmat(RootPath,subdir_civ1_new,RootFile_A,'.nc',NomType_nc,i1_civ1(ifile),i2_civ1(ifile),j1_civ1(j),j2_civ1(j));
    1952                    % filename=name_generator(filebase_A,i1_civ1(ifile),j1_civ1(j),'.nc',NomType_nc,1,i2_civ1(ifile),j2_civ1(j),subdir_civ1_new);%
    19531941                    detect=exist(filename,'file')==2;
    19541942                    if detect% if a netcdf file already exists
     
    28282816
    28292817%% reads .nc subdirectoy and image numbers from the interface
    2830 subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data
    2831 subdir_civ2=get(handles.SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data
     2818SubDirImages=get(handles.SubdirImages,'String');
     2819subdir_civ1=[SubDirImages get(handles.SubdirCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data
     2820subdir_civ2=[SubDirImages get(handles.SubdirCiv2,'String')];%subdirectory subdir_civ2 for the netcdf data
    28322821ref_i=str2double(get(handles.ref_i,'String'));
    28332822if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
  • trunk/src/civ_matlab.m

    r492 r493  
    6060if ischar(Param)
    6161    Param=xml2struct(Param); %if Param is the name of an xml file, read this file as a Matlab structure
    62     if isfield(Param,'Civ1')
    63         if strcmp(Param.Civ1.FileTypeA,'video')
    64             Param.Civ1.ImageA=VideoReader(Param.Civ1.ImageA);
    65         elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
    66             Param.Civ1.ImageA=mmreader(Param.Civ1.ImageA);
    67         end
    68         if strcmp(Param.Civ1.FileTypeB,'video')
    69             Param.Civ1.ImageB=VideoReader(Param.Civ1.ImageB);
    70         elseif strcmp(Param.Civ1.FileTypeB,'mmreader')
    71             Param.Civ1.ImageB=mmreader(Param.Civ1.ImageB);
    72         end
    73     end
    74     if isfield(Param,'Civ2')
    75         if strcmp(Param.Civ2.FileTypeA,'video')
    76             Param.Civ2.ImageA=VideoReader(Param.Civ2.ImageA);
    77         elseif strcmp(Param.Civ2.FileTypeA,'mmreader')
    78             Param.Civ2.ImageA=mmreader(Param.Civ2.ImageA);
    79         end
    80          if strcmp(Param.Civ2.FileTypeB,'video')
    81             Param.Civ2.ImageB=VideoReader(Param.Civ2.ImageB);
    82         elseif strcmp(Param.Civ2.FileTypeB,'mmreader')
    83             Param.Civ2.ImageB=mmreader(Param.Civ2.ImageB);
    84         end
    85     end
     62%     if isfield(Param,'Civ1')
     63%         if strcmp(Param.Civ1.FileTypeA,'video')
     64%             Param.Civ1.ImageA=VideoReader(regexprep(Param.Civ1.ImageA,'''','\'));% remove spurious ' appearing in Windows;
     65%         elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
     66%             Param.Civ1.ImageA=mmreader(regexprep(Param.Civ1.ImageA,'''','\'));% remove spurious ' appearing in Windows
     67%         end
     68%         if strcmp(Param.Civ1.FileTypeB,'video')
     69%             Param.Civ1.ImageB=VideoReader(regexprep(Param.Civ1.ImageB,'''','\'));% remove spurious ' appearing in Windows
     70%         elseif strcmp(Param.Civ1.FileTypeB,'mmreader')
     71%             Param.Civ1.ImageB=mmreader(regexprep(Param.Civ1.ImageB,'''','\'));% remove spurious ' appearing in Windows
     72%         end
     73%     end
     74%     if isfield(Param,'Civ2')
     75%         if strcmp(Param.Civ2.FileTypeA,'video')
     76%             Param.Civ2.ImageA=VideoReader(regexprep(Param.Civ2.ImageA,'''','\'));% remove spurious ' appearing in Windows;
     77%         elseif strcmp(Param.Civ2.FileTypeA,'mmreader')
     78%             Param.Civ2.ImageA=mmreader(regexprep(Param.Civ2.ImageA,'''','\'));% remove spurious ' appearing in Windows
     79%             if strcmp(Param.Civ2.FileTypeB,'video')
     80%                 Param.Civ2.ImageB=VideoReader(regexprep(Param.Civ2.ImageB,'''','\'));% remove spurious ' appearing in Windows
     81%             elseif strcmp(Param.Civ2.FileTypeB,'mmreader')
     82%                 Param.Civ2.ImageB=mmreader(regexprep(Param.Civ2.ImageB,'''','\'));% remove spurious ' appearing in Windows
     83%             end;
     84%         end
     85%     end
    8686end
    8787
     
    9090    %     check_civ1=1;% test for further use of civ1 results
    9191    % %% prepare images
     92
    9293    par_civ1=Param.Civ1;
    9394    if isfield(par_civ1,'reverse_pair')
     
    102103        end
    103104    else
    104         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           
    105             [Field,ParamOut,errormsg] = read_field(Param.Civ1.ImageA,par_civ1.FileTypeA,par_civ1.ImageA,par_civ1.FrameIndexA);
    106             if ~isempty(errormsg)
    107                 errormsg=['error in civ_matlab/read_field:' errormsg];
    108                 return
    109             end
    110             par_civ1.ImageA=Field.A;%= image matrix A in the first input field
    111         end
    112         if isfield(par_civ1,'ImageB')&& (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageB),'VideoReader'))
    113             [Field,ParamOut,errormsg] = read_field(Param.Civ1.ImageB,par_civ1.FileTypeB,par_civ1.ImageB,par_civ1.FrameIndexB);
    114             if ~isempty(errormsg)
    115                 errormsg=['error in civ_matlab/read_field:' errormsg];
    116                 return
    117             end
    118             par_civ1.ImageB=Field.A;%= image matrix A in the second input field
     105        if isfield(par_civ1,'ImageA')%&&...
     106            %    (ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')||strcmp(class(par_civ1.ImageA),'mmreader')) % case with no image: only the PIV grid is calculated           
     107             Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'''','\');
     108            [par_civ1.ImageA,ParamOut] = read_image(Param.Civ1.ImageA,par_civ1.FileTypeA,par_civ1.ImageA,par_civ1.FrameIndexA);
     109%             if ~isempty(errormsg)
     110%                 errormsg=['error in civ_matlab/read_field:' errormsg];
     111%                 return
     112%             end
     113            %par_civ1.ImageA=Field.A;%= image matrix A in the first input field
     114        end
     115        if isfield(par_civ1,'ImageB')%&& ...
     116              %  (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageB),'VideoReader')||strcmp(class(par_civ1.ImageB),'mmreader'))
     117             Param.Civ1.ImageB=regexprep(Param.Civ1.ImageB,'''','\');
     118            [par_civ1.ImageB,ParamOut] = read_image(Param.Civ1.ImageB,par_civ1.FileTypeB,par_civ1.ImageB,par_civ1.FrameIndexB);
     119%             if ~isempty(errormsg)
     120%                 errormsg=['error in civ_matlab/read_field:' errormsg];
     121%                 return
     122%             end
     123           % par_civ1.ImageB=Field.A;%= image matrix A in the second input field
    119124        end
    120125    end
     
    444449%
    445450%INPUT:
    446 % image1:first image (matrix)
     451% par_civ: structure of input parameters, with fields:
     452%  .CorrBoxSize
     453%  .SearchBoxSize
     454%  .SearchBoxShift
     455%  .ImageHeight
     456%  .ImageWidth
     457%  .Dx, Dy
     458%  .Grid
     459%  .Mask
     460%  .MinIma
     461%  .MaxIma
     462%  .image1:first image (matrix)
    447463% image2: second image (matrix)
    448464% ibx2,iby2: half size of the correlation box along x and y, in px (size=(2*iby2+1,2*ibx2+1)
  • trunk/src/read_field.m

    r472 r493  
    154154                ParamOut.FieldList={'get_field...'};
    155155            end
    156         case {'video','mmreader'}
    157             A=read(ParamIn,num);
     156        case 'video'
     157            if strcmp(class(ParamIn),'VideoReader')
     158                A=read(ParamIn,num);
     159            else
     160                ParamOut=VideoReader(FileName);
     161                A=read(ParamOut,num);
     162            end
     163        case 'mmreader'
     164            if strcmp(class(ParamIn),'mmreader')
     165                A=read(ParamIn,num);
     166            else
     167                ParamOut=mmreader(FileName);
     168                A=read(ParamOut,num);
     169            end
    158170        case 'vol'
    159171            A=imread(FileName);
  • trunk/src/read_image.m

    r453 r493  
    11%--read images or video objects
    2 function A=read_image(FileName,FileType,VideoObject,num)
     2function [A,ParamOut]=read_image(FileName,FileType,VideoObject,num)
    33%------------------------------------------------------------------------
    44%num is the view number needed for an avi movie
     5ParamOut=VideoObject;%default
    56switch FileType
    6     case {'video','mmreader'}
    7         A=read(VideoObject,num);
     7         case 'video'
     8            if strcmp(class(VideoObject),'VideoReader')
     9                A=read(VideoObject,num);
     10            else
     11                ParamOut=VideoReader(FileName);
     12                A=read(ParamOut,num);
     13            end
     14        case 'mmreader'
     15            if strcmp(class(VideoObject),'mmreader')
     16                A=read(VideoObject,num);
     17            else
     18                ParamOut=mmreader(FileName);
     19                A=read(ParamOut,num);
     20            end
    821    case 'multimage'
    922        A=imread(FileName,num);
  • trunk/src/struct2xml.m

    r453 r493  
    4747 if ischar(val)
    4848     [t,new_uid]=add(t,uid,'element',key);
     49     val=regexprep(val,'\','\\');
    4950     [t]=add(t,new_uid,'chardata',val);
    5051 elseif isnumeric(val)||islogical(val)
Note: See TracChangeset for help on using the changeset viewer.