Changeset 370 for trunk/src


Ignore:
Timestamp:
Jan 13, 2012, 10:51:16 AM (13 years ago)
Author:
sommeria
Message:

bug corrected in civ_uvmat civ2, opening new files made more convenient in civ

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r368 r370  
    2323%TODO: search range
    2424
    25 % Last Modified by GUIDE v2.5 09-Jan-2012 20:42:45
     25% Last Modified by GUIDE v2.5 13-Jan-2012 08:01:20
    2626% Begin initialization code - DO NOT EDIT
    2727gui_Singleton = 1;
     
    249249end
    250250set(handles.RootName,'BackgroundColor',[1 1 1])%paint RootName back to white to indicate that the file input is finished
     251
    251252% -----------------------------------------------------------------------
    252 % --- Prepare the GUI for the compiled CivX program
    253 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 program
    271 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 
    287253% -----------------------------------------------------------------------
    288254% --- Open the help html file
     
    351317    end
    352318    if strcmp(Data.Conventions,'uvmat/civdata')% case of new civ data,
    353         set(handles.MenuMatlab,'checked','on') %select civ/Matlab by default
    354         MenuMatlab_Callback([],[], handles)
     319        set(handles.ListProgram,'Value',2) %select civ/Matlab by default
     320        ListProgram_Callback([],[], handles)
    355321        if ~isempty(Data.CivStage)%test for civ files
    356322            ind_opening=Data.CivStage;
     
    362328        end
    363329    elseif ~isempty(Data.absolut_time_T0')% case of  civx data,
    364         set(handles.MenuCivX,'checked','on') %select Cix by default
    365         MenuCivX_Callback([],[], handles)
     330        set(handles.ListProgram,'Value',1) %select Cix by default
     331        ListProgram_Callback([],[], handles)
    366332        if ~isempty(Data.fix2)
    367333            ind_opening=5;
     
    444410%% scan the images if a civ file has been opened
    445411if ~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);
     413end
     414MinIndex_i=min(i1_series(i1_series>0));
     415MinIndex_j=min(j1_series(j1_series>0));
    448416MaxIndex_i=max(i1_series(i1_series>0));
    449417MaxIndex_j=max(j1_series(j1_series>0));
     
    569537set(handles.NomType,'String',NomTypeIma)
    570538set(handles.ref_i,'String',num2str(num_ref_i))
     539set(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
     543first_i=str2num(get(handles.first_i,'String'));
     544last_i=str2num(get(handles.last_i,'String'));
     545if ind_opening~=0 || first_i<MinIndex_i || last_i>MaxIndex_i
    571546set(handles.first_i,'String',num2str(num_ref_i));
    572547set(handles.last_i,'String',num2str(num_ref_i));%
    573 set(handles.ref_j,'String',num2str(num_ref_j))
     548end
     549
     550%j index range
     551first_j=str2num(get(handles.first_j,'String'));
     552last_j=str2num(get(handles.last_i,'String'));
     553if ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j
    574554set(handles.first_j,'String',num2str(num_ref_j));
    575555set(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)
     556end
     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'};
     560if 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
    582567end
    583568set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1)
    584 
    585569update_CivOptions(handles,1)
    586570
     
    623607    SubdirCiv1=SubDir;
    624608    SubdirCiv2=SubDir;
    625     set(SubdirCiv1,'String',SubDir)
    626     set(SubdirCiv2,'String',SubDir)
     609    set(handles.SubdirCiv1,'String',SubDir)
     610    set(handles.SubdirCiv2,'String',SubDir)
    627611else% currently selected subdir preserved
    628     SubDirCiv1=get(handles.SubdirCiv1,'String');
    629     SubDirCiv2=get(handles.SubdirCiv2,'String');
    630     if isempty(SubDirCiv1)% default subdir name='CIV'
     612    SubdirCiv1=get(handles.SubdirCiv1,'String');
     613    SubdirCiv2=get(handles.SubdirCiv2,'String');
     614    if isempty(SubdirCiv1)% default subdir name='CIV'
    631615        set(handles.SubdirCiv1,'String','CIV');
    632         SubDirCiv1='CIV';
    633     end
    634     if isempty(SubDirCiv2)% default subdir name='CIV'
     616        SubdirCiv1='CIV';
     617    end
     618    if isempty(SubdirCiv2)% default subdir name='CIV'
    635619        set(handles.SubdirCiv2,'String','CIV');
    636         SubDirCiv2='CIV';
     620        SubdirCiv2='CIV';
    637621    end
    638622end
    639623
    640624%% update the subdirectory menus
    641 ValueCiv1=find(strcmp(SubDirCiv1,listdir));%search the index of subdir in the cell listdir
     625ValueCiv1=find(strcmp(SubdirCiv1,listdir));%search the index of subdir in the cell listdir
    642626if isempty(ValueCiv1)% if the input subdir is not found
    643627    ValueCiv1=numel(listdir)+1;%new subdirectory requested for civ1
    644628end
    645 ValueCiv2=find(strcmp(SubDirCiv2,listdir));%search the index of subdir in the cell listdir
     629ValueCiv2=find(strcmp(SubdirCiv2,listdir));%search the index of subdir in the cell listdir
    646630if isempty(ValueCiv2)% if the input subdir is not found
    647631    ValueCiv2=numel(listdir)+1;%new subdirectory requested for civ2
     
    11121096
    11131097%% 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
     1103ListProgram=get(handles.ListProgram,'String');
     1104CivMode=ListProgram{get(handles.ListProgram,'Value')};
    11191105binary_list={};
    11201106switch CivMode
     
    41664152end
    41674153
    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 prog
    4177 %     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 %         end
    4190 %         set(handles.num_Rho,'Style','edit')
    4191 %         set(handles.num_Rho,'String','1')
    4192 %         set(handles.BATCH,'Enable','on')
    4193 %     case 'CivUvmat'
    4194 %       
    4195 % end
    4196 
    41974154%------------------------------------------------------------------------
    41984155function cmd=cmd_civ1(filename,Param)
     
    46154572
    46164573function NomType_Callback(hObject, eventdata, handles)
     4574
     4575
     4576% --- Executes on selection change in ListProgram.
     4577function ListProgram_Callback(hObject, eventdata, handles)
     4578ListProgram=get(handles.ListProgram,'String');
     4579Program=ListProgram{get(handles.ListProgram,'value')};
     4580switch 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'})
     4601end
     4602
     4603
     4604% --- Executes on button press in TestCiv2.
     4605function TestCiv2_Callback(hObject, eventdata, handles)
  • trunk/src/civ_matlab.m

    r369 r370  
    215215    [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy);
    216216    GridX=reshape(GridX,[],1);
    217     GridY=reshape(GridY,[],1);
     217    GridY=reshape(GridY,[],1); 
    218218    Shiftx=zeros(size(GridX));% shift expected from civ1 data
    219219    Shifty=zeros(size(GridX));
     
    254254    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   
    255255    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;
    260260    end
    261261    % caluclate velocity data (y and v in indices, reverse to y component)
     
    494494if CheckDecimal
    495495    mesh=0.2;%mesh in pixels for subpixel image interpolation
     496    CheckDeformation=isfield(par_civ,'CheckDeformation')&& par_civ.CheckDeformation==1;
    496497end
    497498% vector=[0 0];%default
    498499for ivec=1:nbvec
    499     iref=par_civ.Grid(ivec,1);% xindex on the image A for the middle of the correlation box
    500     jref=par_civ.Grid(ivec,2);% yindex on the image B for the middle of the correlation box
     500    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
    501502    if ~(checkmask && par_civ.Mask(jref,iref)<=20) %velocity not set to zero by the black mask
    502503        if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth||...
     
    520521            image1_crop=image1_crop-image1_mean;%substract the mean
    521522            image2_crop=image2_crop-image2_mean;
    522             if isfield(par_civ,'CheckDecimal')&& par_civ.CheckDecimal==1
     523            if CheckDecimal
    523524                xi=(1:mesh:size(image1_crop,2));
    524525                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
    526534                xi=(1:mesh:size(image2_crop,2));
    527535                yi=(1:mesh:size(image2_crop,1))';
     
    544552                    utable(ivec)=vector(1)*mesh+shiftx(ivec);
    545553                    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)
    548556                    iref=round(xtable(ivec));% image index for the middle of the vector
    549557                    jref=round(ytable(ivec));
Note: See TracChangeset for help on using the changeset viewer.