Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r368 r370 23 23 %TODO: search range 24 24 25 % Last Modified by GUIDE v2.5 09-Jan-2012 20:42:4525 % Last Modified by GUIDE v2.5 13-Jan-2012 08:01:20 26 26 % Begin initialization code - DO NOT EDIT 27 27 gui_Singleton = 1; … … 249 249 end 250 250 set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished 251 251 252 % ----------------------------------------------------------------------- 252 % --- Prepare the GUI for the compiled CivX program253 function MenuCivX_Callback(hObject, eventdata, handles)254 set(handles.MenuMatlab,'checked','off')255 set(handles.MenuCivX,'checked','on')256 %set(handles.thresh_patch1,'Visible','off')257 % set(handles.thresh_text1,'Visible','off')258 set(handles.num_MaxDiff,'Visible','off')259 set(handles.num_Nx,'Visible','on')260 set(handles.num_Ny,'Visible','on')261 set(handles.title_Nx,'Visible','on')262 set(handles.title_Ny,'Visible','on')263 set(handles.title_MaxDiff,'Visible','off')264 set(handles.num_Rho,'Style','edit')265 set(handles.num_Rho,'String','1')266 set(handles.BATCH,'Enable','on')267 % -----------------------------------------------------------------------268 269 % -----------------------------------------------------------------------270 % --- Prepare the GUI for the Matlab PIV program271 function MenuMatlab_Callback(hObject, eventdata, handles)272 % -----------------------------------------------------------------------273 set(handles.MenuMatlab,'checked','on')274 set(handles.MenuCivX,'checked','off')275 % if get(handles.CheckPatch1,'Value')276 set(handles.num_MaxDiff,'Visible','on')277 set(handles.title_MaxDiff,'Visible','on')278 set(handles.num_Nx,'Visible','off')279 set(handles.num_Ny,'Visible','off')280 set(handles.title_Nx,'Visible','off')281 set(handles.title_Ny,'Visible','off')282 set(handles.num_Rho,'Style','popupmenu')283 set(handles.num_Rho,'Value',1)284 set(handles.num_Rho,'String',{'1';'2'})285 % set(handles.BATCH,'Enable','off')286 287 253 % ----------------------------------------------------------------------- 288 254 % --- Open the help html file … … 351 317 end 352 318 if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data, 353 set(handles. MenuMatlab,'checked','on') %select civ/Matlab by default354 MenuMatlab_Callback([],[], handles)319 set(handles.ListProgram,'Value',2) %select civ/Matlab by default 320 ListProgram_Callback([],[], handles) 355 321 if ~isempty(Data.CivStage)%test for civ files 356 322 ind_opening=Data.CivStage; … … 362 328 end 363 329 elseif ~isempty(Data.absolut_time_T0')% case of civx data, 364 set(handles. MenuCivX,'checked','on') %select Cix by default365 MenuCivX_Callback([],[], handles)330 set(handles.ListProgram,'Value',1) %select Cix by default 331 ListProgram_Callback([],[], handles) 366 332 if ~isempty(Data.fix2) 367 333 ind_opening=5; … … 444 410 %% scan the images if a civ file has been opened 445 411 if ~isempty(NomTypeNc) 446 [RootPath,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,ImageType,Object]=find_file_series(imageinput); 447 end 412 [RootPath,tild,i1_series,tild,j1_series,tild,NomTypeIma,ImageType,Object]=find_file_series(imageinput); 413 end 414 MinIndex_i=min(i1_series(i1_series>0)); 415 MinIndex_j=min(j1_series(j1_series>0)); 448 416 MaxIndex_i=max(i1_series(i1_series>0)); 449 417 MaxIndex_j=max(j1_series(j1_series>0)); … … 569 537 set(handles.NomType,'String',NomTypeIma) 570 538 set(handles.ref_i,'String',num2str(num_ref_i)) 539 set(handles.ref_j,'String',num2str(num_ref_j)) 540 541 %% update i and j index range if a nc file has been opened or pb withmin max image indices: 542 % then set first and last to the inputfile index by default 543 first_i=str2num(get(handles.first_i,'String')); 544 last_i=str2num(get(handles.last_i,'String')); 545 if ind_opening~=0 || first_i<MinIndex_i || last_i>MaxIndex_i 571 546 set(handles.first_i,'String',num2str(num_ref_i)); 572 547 set(handles.last_i,'String',num2str(num_ref_i));% 573 set(handles.ref_j,'String',num2str(num_ref_j)) 548 end 549 550 %j index range 551 first_j=str2num(get(handles.first_j,'String')); 552 last_j=str2num(get(handles.last_i,'String')); 553 if ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j 574 554 set(handles.first_j,'String',num2str(num_ref_j)); 575 555 set(handles.last_j,'String',num2str(num_ref_j));% 576 % set(handles.civ,'UserData',CivData) 577 578 %% set the civ options depending on the input file content 579 ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; 580 for index = 1:ind_opening 581 set(handles.(ListOptions{index}),'value',0) 556 end 557 558 %% set the civ options depending on the input file content when a nc file has been opened 559 ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; 560 if ind_opening~=0 561 for index = 1:ind_opening 562 set(handles.(ListOptions{index}),'value',0) 563 end 564 for index = ind_opening+2:6 565 set(handles.(ListOptions{index}),'value',0) 566 end 582 567 end 583 568 set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) 584 585 569 update_CivOptions(handles,1) 586 570 … … 623 607 SubdirCiv1=SubDir; 624 608 SubdirCiv2=SubDir; 625 set( SubdirCiv1,'String',SubDir)626 set( SubdirCiv2,'String',SubDir)609 set(handles.SubdirCiv1,'String',SubDir) 610 set(handles.SubdirCiv2,'String',SubDir) 627 611 else% currently selected subdir preserved 628 Sub DirCiv1=get(handles.SubdirCiv1,'String');629 Sub DirCiv2=get(handles.SubdirCiv2,'String');630 if isempty(Sub DirCiv1)% default subdir name='CIV'612 SubdirCiv1=get(handles.SubdirCiv1,'String'); 613 SubdirCiv2=get(handles.SubdirCiv2,'String'); 614 if isempty(SubdirCiv1)% default subdir name='CIV' 631 615 set(handles.SubdirCiv1,'String','CIV'); 632 Sub DirCiv1='CIV';633 end 634 if isempty(Sub DirCiv2)% default subdir name='CIV'616 SubdirCiv1='CIV'; 617 end 618 if isempty(SubdirCiv2)% default subdir name='CIV' 635 619 set(handles.SubdirCiv2,'String','CIV'); 636 Sub DirCiv2='CIV';620 SubdirCiv2='CIV'; 637 621 end 638 622 end 639 623 640 624 %% update the subdirectory menus 641 ValueCiv1=find(strcmp(Sub DirCiv1,listdir));%search the index of subdir in the cell listdir625 ValueCiv1=find(strcmp(SubdirCiv1,listdir));%search the index of subdir in the cell listdir 642 626 if isempty(ValueCiv1)% if the input subdir is not found 643 627 ValueCiv1=numel(listdir)+1;%new subdirectory requested for civ1 644 628 end 645 ValueCiv2=find(strcmp(Sub DirCiv2,listdir));%search the index of subdir in the cell listdir629 ValueCiv2=find(strcmp(SubdirCiv2,listdir));%search the index of subdir in the cell listdir 646 630 if isempty(ValueCiv2)% if the input subdir is not found 647 631 ValueCiv2=numel(listdir)+1;%new subdirectory requested for civ2 … … 1112 1096 1113 1097 %% check if the binaries exist 1114 if isequal(get(handles.MenuMatlab,'checked'),'on') 1115 CivMode='Matlab'; 1116 else 1117 CivMode='CivX'; 1118 end 1098 % if isequal(get(handles.ListProgram,'Value'),2) 1099 % CivMode='Matlab'; 1100 % else 1101 % CivMode='CivX'; 1102 % end 1103 ListProgram=get(handles.ListProgram,'String'); 1104 CivMode=ListProgram{get(handles.ListProgram,'Value')}; 1119 1105 binary_list={}; 1120 1106 switch CivMode … … 4166 4152 end 4167 4153 4168 4169 %------------------------------------------------------------------------4170 % % --- Executes on button press in ListPairMode.4171 % function CivMode_Callback(hObject, eventdata, handles)4172 % %------------------------------------------------------------------------4173 % Listprog=get(handles.ListPairMode,'String');4174 % index=get(handles.ListPairMode,'Value');4175 % prog=Listprog{index};4176 % switch prog4177 % case 'MenuCivX'4178 % set(handles.thresh_patch1,'Visible','off')4179 % set(handles.thresh_text1,'Visible','off')4180 % set(handles.num_MaxDiff,'Visible','off')4181 % set(handles.title_MaxDiff,'Visible','off')4182 % set(handles.num_Rho,'Style','edit')4183 % set(handles.num_Rho,'String','1')4184 % set(handles.BATCH,'Enable','on')4185 % case 'CivAll'4186 % if get(handles.CheckPatch1,'Value')4187 % set(handles.thresh_patch1,'Visible','on')4188 % set(handles.thresh_text1,'Visible','on')4189 % end4190 % set(handles.num_Rho,'Style','edit')4191 % set(handles.num_Rho,'String','1')4192 % set(handles.BATCH,'Enable','on')4193 % case 'CivUvmat'4194 %4195 % end4196 4197 4154 %------------------------------------------------------------------------ 4198 4155 function cmd=cmd_civ1(filename,Param) … … 4615 4572 4616 4573 function NomType_Callback(hObject, eventdata, handles) 4574 4575 4576 % --- Executes on selection change in ListProgram. 4577 function ListProgram_Callback(hObject, eventdata, handles) 4578 ListProgram=get(handles.ListProgram,'String'); 4579 Program=ListProgram{get(handles.ListProgram,'value')}; 4580 switch Program 4581 case 'CivX' 4582 set(handles.num_MaxDiff,'Visible','off') 4583 set(handles.num_Nx,'Visible','on') 4584 set(handles.num_Ny,'Visible','on') 4585 set(handles.title_Nx,'Visible','on') 4586 set(handles.title_Ny,'Visible','on') 4587 set(handles.title_MaxDiff,'Visible','off') 4588 set(handles.num_Rho,'Style','edit') 4589 set(handles.num_Rho,'String','1') 4590 set(handles.BATCH,'Enable','on') 4591 case 'Matlab' 4592 set(handles.num_MaxDiff,'Visible','on') 4593 set(handles.title_MaxDiff,'Visible','on') 4594 set(handles.num_Nx,'Visible','off') 4595 set(handles.num_Ny,'Visible','off') 4596 set(handles.title_Nx,'Visible','off') 4597 set(handles.title_Ny,'Visible','off') 4598 set(handles.num_Rho,'Style','popupmenu') 4599 set(handles.num_Rho,'Value',1) 4600 set(handles.num_Rho,'String',{'1';'2'}) 4601 end 4602 4603 4604 % --- Executes on button press in TestCiv2. 4605 function TestCiv2_Callback(hObject, eventdata, handles) -
trunk/src/civ_matlab.m
r369 r370 215 215 [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy); 216 216 GridX=reshape(GridX,[],1); 217 GridY=reshape(GridY,[],1); 217 GridY=reshape(GridY,[],1); 218 218 Shiftx=zeros(size(GridX));% shift expected from civ1 data 219 219 Shifty=zeros(size(GridX)); … … 254 254 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 255 255 if par_civ2.CheckDeformation 256 DUDX=DUDX./nbval;257 DUDY=DUDY./nbval;258 DVDX=DVDX./nbval;259 DVDY=DVDY./nbval;256 par_civ2.DUDX=DUDX./nbval; 257 par_civ2.DUDY=DUDY./nbval; 258 par_civ2.DVDX=DVDX./nbval; 259 par_civ2.DVDY=DVDY./nbval; 260 260 end 261 261 % caluclate velocity data (y and v in indices, reverse to y component) … … 494 494 if CheckDecimal 495 495 mesh=0.2;%mesh in pixels for subpixel image interpolation 496 CheckDeformation=isfield(par_civ,'CheckDeformation')&& par_civ.CheckDeformation==1; 496 497 end 497 498 % vector=[0 0];%default 498 499 for ivec=1:nbvec 499 iref= par_civ.Grid(ivec,1);% xindex on the image A for the middle of the correlation box500 jref= par_civ.Grid(ivec,2);% yindex on the image B for the middle of the correlation box500 iref=round(par_civ.Grid(ivec,1)+0.5);% xindex on the image A for the middle of the correlation box 501 jref=round(par_civ.ImageHeight-par_civ.Grid(ivec,2)+0.5);% yindex on the image B for the middle of the correlation box 501 502 if ~(checkmask && par_civ.Mask(jref,iref)<=20) %velocity not set to zero by the black mask 502 503 if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth||... … … 520 521 image1_crop=image1_crop-image1_mean;%substract the mean 521 522 image2_crop=image2_crop-image2_mean; 522 if isfield(par_civ,'CheckDecimal')&& par_civ.CheckDecimal==1523 if CheckDecimal 523 524 xi=(1:mesh:size(image1_crop,2)); 524 525 yi=(1:mesh:size(image1_crop,1))'; 525 image1_crop=interp2(image1_crop,xi,yi); 526 if CheckDeformation 527 [XI,YI]=meshgrid(xi-ceil(size(image1_crop,2)/2),yi-ceil(size(image1_crop,1)/2)); 528 XIant=XI-par_civ.DUDX(ivec)*XI-par_civ.DUDY(ivec)*YI+ceil(size(image1_crop,2)/2); 529 YIant=YI-par_civ.DVDX(ivec)*XI-par_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2); 530 image1_crop=interp2(image1_crop,XIant,YIant); 531 else 532 image1_crop=interp2(image1_crop,xi,yi); 533 end 526 534 xi=(1:mesh:size(image2_crop,2)); 527 535 yi=(1:mesh:size(image2_crop,1))'; … … 544 552 utable(ivec)=vector(1)*mesh+shiftx(ivec); 545 553 vtable(ivec)=vector(2)*mesh+shifty(ivec); 546 xtable(ivec)=iref+utable(ivec)/2 ;% convec flow (velocity taken at the point middle from imgae1 and 2)547 ytable(ivec)=jref+vtable(ivec)/2 ;554 xtable(ivec)=iref+utable(ivec)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) 555 ytable(ivec)=jref+vtable(ivec)/2-0.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge) 548 556 iref=round(xtable(ivec));% image index for the middle of the vector 549 557 jref=round(ytable(ivec));
Note: See TracChangeset
for help on using the changeset viewer.