- Timestamp:
- Jul 16, 2012, 10:44:12 AM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r492 r493 341 341 342 342 %% case of netcdf file as input, get the civ processing stage and look for a coresponding image 343 imageinput=fileinput;%default 343 344 if strcmp(ExtInput,'.nc') 344 345 NomTypeNc=NomTypeInput; … … 351 352 set(handles.RootFile_1,'Visible','Off'); 352 353 end 354 imageinput=''; 353 355 Data=nc2struct(fileinput,'ListGlobalAttribute','Conventions','absolut_time_T0','CivStage','Civ2_ImageA','Civ1_ImageA','Civ2_ImageB','Civ1_ImageB','fix','patch','civ2','fix2'); 354 356 if isfield(Data,'Txt') … … 359 361 if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data, 360 362 set(handles.Program,'Value',2) %select civ/Matlab by default 361 ListProgram_Callback([],[], handles)363 Program_Callback([],[], handles) 362 364 if ~isempty(Data.CivStage)%test for civ files 363 365 ind_opening=Data.CivStage; … … 404 406 end 405 407 end 408 if ~exist(imageinput,'file') 406 409 imageinput=fullfile_uvmat(RootPath,regexprep(SubDir,'.civ(_?)(\d*)$',''),RootFile,'.png',NomTypeIma,i1,[],j1); 410 end 407 411 end 408 412 … … 419 423 '*.*', 'All Files (*.*)'}; 420 424 [FileName, PathName] = uigetfile( menu, 'Pick an input image file',fileparts(fileparts(fileinput))); 421 fileinput=[PathName FileName];%complete file name422 if ~exist( fileinput,'file')425 imageinput=[PathName FileName];%complete file name 426 if ~exist(imageinput,'file') 423 427 return %abandon of the browser is cancelled 424 428 end … … 428 432 429 433 %% scan the image file series 430 [FilePath,FileName,ImaExt]=fileparts( fileinput);434 [FilePath,FileName,ImaExt]=fileparts(imageinput); 431 435 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 432 436 % 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]); 434 438 switch FileType 435 439 case {'image','multimage','video','mmreader'} … … 442 446 set(handles.RootFile,'String',RootFile) 443 447 if strcmp(ExtInput,'.nc') 444 SubDirCiv=regexprep(SubDir,[ SubdirImages '^'],'');%suppress the root SuddirImages;448 SubDirCiv=regexprep(SubDir,['^' SubdirImages],'');%suppress the root SuddirImages; 445 449 else 446 450 SubDirCiv= '.civ'; … … 450 454 browse=get(handles.RootPath,'UserData'); 451 455 browse.incr_pair=[0 0];%default 452 453 %% fill reference indices from the input file indices454 num_ref_i=i1;%efaulmt ref index455 if ~isempty(i2)456 num_ref_i=floor((num_ref_i+i2)/2);457 end458 num_ref_j=j1;459 if ~isempty(j2)460 num_ref_j=floor((num_ref_j+j2)/2);461 end462 456 463 457 %% scan the images if a civ file has been opened … … 467 461 MaxIndex_j=max(j1_series(j1_series>0)); 468 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 477 469 478 %% look for an image documentation file 470 479 XmlFileName=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 dir473 % if ~exist(filexml,'file')474 % filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy475 % if ~exist(filexml,'file')476 % filexml=fullfile(RootPath,SubDir,[RootFile '.civ']);%very old convention: .civ file477 % if ~exist(filexml,'file')478 % filexml='';479 % end480 % end481 % end482 480 if isempty(XmlFileName) 483 481 if (strcmp(FileType,'video') || strcmp(FileType,'mmreader')) … … 501 499 [XmlData,warntext]=imadoc2struct(XmlFileName); 502 500 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 file504 % [~,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 % end509 % end510 501 if isfield(XmlData,'Time') && ~isempty(XmlData.Time) 511 502 time=XmlData.Time; … … 1079 1070 end% default configuration 1080 1071 if ~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'); 1086 1077 end 1087 1078 if strcmp(Param.RunMode,'cluster') %computation dispatched on a cluster … … 1096 1087 end 1097 1088 else 1098 % standardconfiguration1099 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'); 1104 1095 Param.xml.BatchMode='oar';% TODO : allow choice for sge 1105 1096 end … … 1107 1098 if isfield(s,'RunParam') 1108 1099 Param.xml=s.RunParam; 1109 else % standarddefault configuration1110 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'); 1115 1106 end 1116 1107 end 1117 1108 1118 1109 %% check if the binaries exist : to move in civ_opening 1119 % ListProgram=get(handles.Program,'String');1120 % Param.CivMode=ListProgram{get(handles.Program,'Value')};1121 1110 binary_list={}; 1122 1111 switch Param.Program … … 1950 1939 for j=1:nbslice 1951 1940 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);%1953 1941 detect=exist(filename,'file')==2; 1954 1942 if detect% if a netcdf file already exists … … 2828 2816 2829 2817 %% 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 2818 SubDirImages=get(handles.SubdirImages,'String'); 2819 subdir_civ1=[SubDirImages get(handles.SubdirCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data 2820 subdir_civ2=[SubDirImages get(handles.SubdirCiv2,'String')];%subdirectory subdir_civ2 for the netcdf data 2832 2821 ref_i=str2double(get(handles.ref_i,'String')); 2833 2822 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') -
trunk/src/civ_matlab.m
r492 r493 60 60 if ischar(Param) 61 61 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 end68 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 end73 end74 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 end85 end62 % 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 86 86 end 87 87 … … 90 90 % check_civ1=1;% test for further use of civ1 results 91 91 % %% prepare images 92 92 93 par_civ1=Param.Civ1; 93 94 if isfield(par_civ1,'reverse_pair') … … 102 103 end 103 104 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 119 124 end 120 125 end … … 444 449 % 445 450 %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) 447 463 % image2: second image (matrix) 448 464 % 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 154 154 ParamOut.FieldList={'get_field...'}; 155 155 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 158 170 case 'vol' 159 171 A=imread(FileName); -
trunk/src/read_image.m
r453 r493 1 1 %--read images or video objects 2 function A=read_image(FileName,FileType,VideoObject,num)2 function [A,ParamOut]=read_image(FileName,FileType,VideoObject,num) 3 3 %------------------------------------------------------------------------ 4 4 %num is the view number needed for an avi movie 5 ParamOut=VideoObject;%default 5 6 switch 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 8 21 case 'multimage' 9 22 A=imread(FileName,num); -
trunk/src/struct2xml.m
r453 r493 47 47 if ischar(val) 48 48 [t,new_uid]=add(t,uid,'element',key); 49 val=regexprep(val,'\','\\'); 49 50 [t]=add(t,new_uid,'chardata',val); 50 51 elseif isnumeric(val)||islogical(val)
Note: See TracChangeset
for help on using the changeset viewer.