- Timestamp:
- May 23, 2015, 5:09:49 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/filter_tps.m
r809 r896 1 1 %'filter_tps': find the thin plate spline coefficients for interpolation-smoothing 2 2 %------------------------------------------------------------------------ 3 % [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain ,Rho,Threshold)3 % [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomainSize,Rho,Threshold) 4 4 % 5 5 % OUTPUT: … … 37 37 %======================================================================= 38 38 39 function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain ,Rho,Threshold)39 function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomainSize,Rho,Threshold) 40 40 41 41 %% adjust subdomain decomposition 42 42 warning off 43 NbVec=size(Coord,1); 44 NbCoord=size(Coord,2); 43 NbVec=size(Coord,1);% nbre of vectors in the field to interpolate 44 NbCoord=size(Coord,2);% space dimension 45 45 MinCoord=min(Coord,[],1);%lower coordinate bounds 46 46 MaxCoord=max(Coord,[],1);%upper coordinate bounds 47 47 Range=MaxCoord-MinCoord; 48 48 AspectRatio=Range(2)/Range(1); 49 NbSubDomain=NbVec/SubDomain ;50 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1); 51 NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1); 52 NbSubDomain=NbSubDomainX*NbSubDomainY; 49 NbSubDomain=NbVec/SubDomainSize;% estimated number of subdomains 50 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);% estimated number of subdomains in x 51 NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y 52 NbSubDomain=NbSubDomainX*NbSubDomainY;% new estimated number of subdomains in a matrix shape partition in subdomains 53 53 Siz(1)=Range(1)/NbSubDomainX;%width of subdomains 54 54 Siz(2)=Range(2)/NbSubDomainY;%height of subdomains 55 CentreX=linspace(MinCoord(1)+Siz(1)/2,MaxCoord(1)-Siz(1)/2,NbSubDomainX); 56 CentreY=linspace(MinCoord(2)+Siz(2)/2,MaxCoord(2)-Siz(2)/2,NbSubDomainY); 55 CentreX=linspace(MinCoord(1)+Siz(1)/2,MaxCoord(1)-Siz(1)/2,NbSubDomainX);% X positions of subdomain centres 56 CentreY=linspace(MinCoord(2)+Siz(2)/2,MaxCoord(2)-Siz(2)/2,NbSubDomainY);% Y positions of subdomain centres 57 57 [CentreX,CentreY]=meshgrid(CentreX,CentreY); 58 CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres 58 59 CentreY=reshape(CentreY,1,[]);% Y positions of subdomain centres 59 CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres60 60 61 61 %% smoothing parameter … … 63 63 64 64 %% default output 65 SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains 66 NbCentre=zeros(1,NbSubDomain);%number of interpolated values per subdomain, =0 by default 65 SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the boundaries of subdomains 66 Coord_tps=zeros(1,NbCoord,NbSubDomain);% initialize coordinates of interpolated data 67 U_tps=zeros(1,NbSubDomain);% initialize interpolated u component 68 V_tps=zeros(1,NbSubDomain);% initialize interpolated v component 69 NbCentre=zeros(1,NbSubDomain);%number of interpolated field values per subdomain, =0 by default 67 70 W_tps=[];%default (2 component case) 68 71 U_smooth=zeros(NbVec,1); % smoothed velocity U at the initial positions … … 73 76 check_empty=zeros(1,NbSubDomain); 74 77 78 75 79 %% calculate tps coeff in each subdomain 76 80 for isub=1:NbSubDomain 77 SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)]; 78 SubRange(2,:,isub)=[CentreY(isub)-0.55*Siz(2) CentreY(isub)+0.55*Siz(2)]; 81 SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)];%bounds of subdomain #isub in x coordinate 82 SubRange(2,:,isub)=[CentreY(isub)-0.55*Siz(2) CentreY(isub)+0.55*Siz(2)];%bounds of subdomain #isub in y coordinate 79 83 ind_sel_previous=[]; 80 ind_sel=0; 84 ind_sel=0;%initialize set of vector indices in the subdomain 81 85 %increase iteratively the subdomain if it contains less than SubDomainNbVec/4 source vectors 82 86 while numel(ind_sel)>numel(ind_sel_previous) 83 ind_sel_previous=ind_sel; 87 ind_sel_previous=ind_sel;% record the set of selected vector indices for next iteration 84 88 ind_sel=find(Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub)); 85 % if no vector in the subdomain , skip the subdomain89 % if no vector in the subdomain #isub, skip the subdomain 86 90 if isempty(ind_sel) 87 91 check_empty(isub)=1; 88 U_tps(1,isub)=0;%define U_tps and V_tps by default 89 V_tps(1,isub)=0; 90 break 91 % if too few selected vectors, increase the subrange for next iteration 92 elseif numel(ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous); 92 break % go to next subdomain 93 % if too few selected vectors, increase the subrange for next iteration 94 elseif numel(ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous); 93 95 SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4; 94 96 SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4; 97 % subdomain includes enough vectors, perform tps interpolation 95 98 else 96 99 [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),rho); 97 100 [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel,:),V(ind_sel),rho); 98 UDiff=U_smooth_sub-U(ind_sel); 99 VDiff=V_smooth_sub-V(ind_sel); 100 NormDiff=UDiff.*UDiff+VDiff.*VDiff; 101 UDiff=U_smooth_sub-U(ind_sel);% difference between interpolated U component and initial value 102 VDiff=V_smooth_sub-V(ind_sel);% difference between interpolated V component and initial value 103 NormDiff=UDiff.*UDiff+VDiff.*VDiff;% Square of difference norm 101 104 ind_ind_sel=1:numel(ind_sel);%default 102 105 if exist('Threshold','var')&&~isempty(Threshold) … … 113 116 V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub; 114 117 nb_select(ind_sel)=nb_select(ind_sel)+1; 115 display( 'good')118 display(['tps done in subdomain # ' num2str(isub) ' among ' num2str(NbSubDomain)]) 116 119 break 117 118 elseif numel(ind_ind_sel)<SubDomain /4 && ~isequal( ind_sel,ind_sel_previous);120 % if too few selected vectors, increase the subrange for next iteration 121 elseif numel(ind_ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous); 119 122 SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4; 120 123 SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4; 121 124 % else interpolation-smoothing is done again with the selected vectors 122 125 else 123 126 [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),U(ind_sel(ind_ind_sel)),rho); … … 130 133 V_tps(1:NbCentre(isub)+3,isub)=V_tps_sub; 131 134 nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+1; 132 display( 'good2')135 display(['tps redone after elimination of erratic vectors in subdomain # ' num2str(isub) ' among ' num2str(NbSubDomain)]) 133 136 break 134 137 end … … 144 147 U_tps(:,ind_empty)=[]; 145 148 V_tps(:,ind_empty)=[]; 149 NbCentre(ind_empty)=[]; 146 150 end 147 151 -
trunk/src/proj_field.m
r895 r896 1287 1287 Dist=Distx.*Distx+Disty.*Disty; 1288 1288 for ivar=1:numel(VarVal) 1289 VarVal{ivar}(Dist> 2*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data1289 VarVal{ivar}(Dist>4*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data 1290 1290 end 1291 1291 … … 1336 1336 Dist=Distx.*Distx+Disty.*Disty; 1337 1337 for ivar=1:numel(VarVal) 1338 VarVal{ivar}(Dist> 2*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data1338 VarVal{ivar}(Dist>4*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data 1339 1339 end 1340 1340 -
trunk/src/read_field.m
r890 r896 167 167 UName=''; 168 168 VName=''; 169 if numel(Field.ListVarName)>NbCoord % if there are variables beyond coord (1 D plots) 169 170 for ilist=1:numel(ListVar) 170 171 Field.VarAttribute{ilist+NbCoord}.Role=Role{ilist}; … … 189 190 end 190 191 end 192 191 193 if ~isempty(NormName)% remove U and V if norm has been calculated and U and V are not needed as variables 192 194 ind_var_U=find(strcmp(UName,ListVar));%check previous listing of variable r.UName … … 216 218 Field.VarAttribute=[cell(1,numel(Field.ListDimName)) Field.VarAttribute] 217 219 end 220 end 218 221 case 'video' 219 222 if strcmp(class(ParamIn),'VideoReader') -
trunk/src/read_rdvision.m
r809 r896 91 91 data=m.Data; 92 92 %%%%%%%BRICOLAGE in case of unreadable .sqb file 93 % ind=[60 63:152];%indices of bin files94 % lengthimage=w*h*bpp;% lengthof an image record on the binary file93 % ind=[144 149:646];%indices of bin files 94 % lengthimage=w*h*bpp;% lengthof an image record on the binary file 95 95 % for ii=1:32*numel(ind) 96 96 % data(ii).offset=mod(ii-1,32)*2*lengthimage+lengthimage;%Dalsa_2 -
trunk/src/series.m
r895 r896 1565 1565 answer=msgbox_uvmat('INPUT_Y-N','Number of cores =1: select the compiled version .sh for multi-core processing. Proceed with the .m version?'); 1566 1566 if ~strcmp(answer,'Yes') 1567 errormsg='Action launch interrupted ';1567 errormsg='Action launch interrupted by user'; 1568 1568 return 1569 1569 end … … 1571 1571 else 1572 1572 answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''}); 1573 if isempty(answer) 1574 errormsg='Action launch interrupted by user'; 1575 return 1576 end 1573 1577 NbCore=str2double(answer{1}); 1574 1578 extra_oar=answer{2}; -
trunk/src/series/civ_series.m
r895 r896 328 328 if ~isempty(RUNHandle)% update the waitbar in interactive mode with GUI series (checkrun=1) 329 329 update_waitbar(WaitbarHandle,ifield/NbField) 330 if get(RUNHandle,'Value')&&~strcmp(get(RUNHandle,'BusyAction'),'queue')330 if ~strcmp(get(RUNHandle,'BusyAction'),'queue') 331 331 disp('program stopped by user') 332 332 break … … 355 355 % if Civ1 computation is requested 356 356 if isfield (Param.ActionInput,'Civ1') 357 disp('civ1 started') 357 358 par_civ1=Param.ActionInput.Civ1; 358 359 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) … … 496 497 %% Fix1 497 498 if isfield (Param.ActionInput,'Fix1') 499 disp('fix1 started') 498 500 if ~isfield (Param.ActionInput,'Civ1')% if we use existing Civ1, remove previous data beyond Civ1 499 501 Fix1_attr=find(strcmp('Fix1',Data.ListGlobalAttribute)); … … 519 521 %% Patch1 520 522 if isfield (Param.ActionInput,'Patch1') 523 disp('patch1 started') 521 524 if check_civx 522 525 errormsg='Civ Matlab input needed for patch'; … … 559 562 Data.Civ1_V_smooth(ind_good)=Vres; 560 563 Data.Civ1_FF(ind_good)=FFres; 564 disp('patch1 performed') 561 565 end 562 566 563 567 %% Civ2 564 568 if isfield (Param.ActionInput,'Civ2') 569 disp('civ2 started') 565 570 par_civ2=Param.ActionInput.Civ2; 566 571 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) … … 751 756 Data.Civ2_C=reshape(ctable,[],1); 752 757 Data.Civ2_F=reshape(F,[],1); 758 disp('civ2 performed') 753 759 elseif ~isfield(Data,'ListVarName') % we start there, using existing Civ2 data 754 760 if exist('ncfile','var') … … 773 779 %% Fix2 774 780 if isfield (Param.ActionInput,'Fix2') 781 disp('fix2 started') 775 782 list_param=fieldnames(Param.ActionInput.Fix2)'; 776 783 Fix2_param=regexprep(list_param,'^.+','Fix2_$0');% insert 'Fix1_' before each string in ListFixParam … … 804 811 Data.CivStage=Data.CivStage+1; 805 812 end 806 807 813 end 808 814 809 815 %% Patch2 810 816 if isfield (Param.ActionInput,'Patch2') 817 disp('patch2 started') 811 818 list_param=fieldnames(Param.ActionInput.Patch2)'; 812 819 list_param(strcmp('TestPatch2',list_param))=[];% remove the parameter TestCiv1 from the list … … 841 848 Data.Civ2_FF(ind_good)=FFres; 842 849 Data.CivStage=Data.CivStage+1; 850 disp('patch2 performed') 843 851 end 844 852
Note: See TracChangeset
for help on using the changeset viewer.