Changeset 576 for trunk/src


Ignore:
Timestamp:
Mar 4, 2013, 8:13:53 AM (12 years ago)
Author:
sommeria
Message:

grid improved for civ: computation done closer to the edge. set_grid improved.

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/browse_data.m

    r571 r576  
    9393    end
    9494    scan_campaign(handles,Campaign)
    95 %     SourceDir_Callback([],[], handles)
    96    set(handles.edit_xml,'Visible','off')
    97    set(handles.HELP,'Visible','off')
    9895   set(handles.OK,'Visible','on')
    9996   set(handles.Cancel,'Visible','on')
  • trunk/src/civ.m

    r575 r576  
    33263326%------------------------------------------------------------------------
    33273327% --- function called to look for grid files
    3328 function [nbslice, flag_mask]=get_grid(filebase,handles)
    3329 %------------------------------------------------------------------------
    3330 flag_mask=0;%default
     3328function [nbslice, flag_grid]=get_grid(filebase,handles)
     3329%------------------------------------------------------------------------
     3330flag_grid=0;%default
    33313331nbslice=1;
    33323332[Path,Name]=fileparts(filebase);
    33333333currentdir=pwd;
    33343334cd(Path);%move in the dir of the root name filebase
    3335 maskfiles=dir([Name '_*grid_*.grid']);%look for mask files
     3335gridfiles=dir([Name '_*grid_*.grid']);%look for grid files
    33363336cd(currentdir);%come back to the current working directory
    3337 if ~isempty(maskfiles)
    3338     flag_mask=1;
    3339     maskname=maskfiles(1).name;% take the first mask file in the list
    3340     [Path2,Name,ext]=fileparts(maskname);
     3337if ~isempty(gridfiles)
     3338    flag_grid=1;
     3339    gridname=gridfiles(1).name;% take the first grid file in the list
     3340    [Path2,Name,ext]=fileparts(gridname);
    33413341    Namedouble=double(Name);
    33423342    val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
    3343     ind_mask=findstr('grid',Name);
    3344     i=ind_mask-1;
     3343    ind_grid=findstr('grid',Name);
     3344    i=ind_grid-1;
    33453345    while val(i)==0 && i>0
    33463346        i=i-1;
    33473347    end
    3348     nbslice=str2double(Name(i+1:ind_mask-1));
     3348    nbslice=str2double(Name(i+1:ind_grid-1));
    33493349    if ~isnan(nbslice) && Name(i)=='_'
    3350         flag_mask=1;
     3350        flag_grid=1;
    33513351    else
    33523352        msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2])
     
    34153415%------------------------------------------------------------------------
    34163416value=get(hObject,'Value');
    3417 hparent=get(hObject,'parent');
     3417hparent=get(hObject,'parent');%handles of the parent panel
    34183418hchildren=get(hparent,'children');
    3419 handle_txtbox=findobj(hchildren,'tag','txt_Grid');
     3419handle_txtbox=findobj(hchildren,'tag','Grid');% look for the grid name box in the same panel
    34203420handle_dx=findobj(hchildren,'tag','num_Dx');
    34213421handle_dy=findobj(hchildren,'tag','num_Dy');
     
    34353435            filebase=filegrid;
    34363436        end
    3437         [FileName, PathName, filterindex] = uigetfile( ...
     3437        [FileName, PathName] = uigetfile( ...
    34383438            {'*.grid', ' (*.grid)';
    34393439            '*.grid',  '.grid files '; ...
     
    34683468    hchildren=get(handles.Civ2,'children');
    34693469    handle_checkbox=findobj(hchildren,'tag','CheckGrid');
    3470     handle_txtbox=findobj(hchildren,'tag','txt_Grid');
     3470    handle_txtbox=findobj(hchildren,'tag','Grid');
    34713471    handle_dx=findobj(hchildren,'tag','num_Dx');
    34723472    handle_dy=findobj(hchildren,'tag','num_Dy');
     
    34823482        set(handle_txtbox,'Visible','on')
    34833483        set(handle_txtbox,'String',filegrid)
    3484 %     else
    3485 %         set(handle_checkbox,'Value',0);
    3486 %         set(handles.CheckGrid,'Value',0);
    3487 %         set(handle_dx,'Visible','on');
    3488 %         set(handle_dy,'Visible','on');
    3489 %          set(handle_title_dx,'Visible','on');
    3490 %         set(handle_title_dy,'Visible','on');
    3491 %         set(handle_txtbox,'Visible','off')
    34923484    end
    34933485end
     
    35323524    set(handles.CheckMask,'Value',1)
    35333525    end
    3534 %     switch parent_tag
    3535 % %         case 'Fix1'
    3536 % %             stage=2;
    3537 %         case 'Civ2'
    3538 %              stage=3;
    3539 % %         case 'Fix2'
    3540 % %             stage=4;
    3541 %     end
    3542 %     set(handles.Mask(stage:end),'Visible','on')
    3543 %     set(handles.Mask(stage:end),'String',filemask)
    3544 %     set(handles.CheckMask(stage:end),'Value',1)
    35453526else
    35463527    set(hObject,'Value',0);
     
    35483529end
    35493530
    3550 
     3531%------------------------------------------------------------------------
    35513532% --- Executes on button press in get_gridpatch1.
    35523533function get_gridpatch1_Callback(hObject, eventdata, handles)
     3534%------------------------------------------------------------------------
    35533535filebase=get(handles.RootPath,'String');
    35543536[FileName, PathName, filterindex] = uigetfile( ...
  • trunk/src/civ_matlab.m

    r575 r576  
    5151check_civ1=0;%default
    5252check_patch1=0;%default
    53 %         ImageFileA=Param.Civ1.ImageA;
    54 %         ImageFileB=Param.Civ1.ImageB;
    55 %         if isfield(Param,'Civ2')
    56 %             ImageFileA_civ2=Param.Civ2.ImageA;
    57 %              ImageFileB_civ2=Param.Civ2.ImageB;
    58 %         end
     53
    5954% case of input Param set by an xml file (batch mode)
    6055if ischar(Param)
    6156    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(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
    8657end
    8758
     
    11687    % caluclate velocity data (y and v in indices, reverse to y component)
    11788    [xtable ytable utable vtable ctable F result_conv errormsg] = civ (par_civ1);
    118    
    119     % to try the reverse_pair method, uncomment below
    120     %     [xtable1 ytable1 utable1 vtable1 ctable1 F1 result_conv1 errormsg1] = civ (Param.Civ1);
    121     %     Param.Civ1.reverse_pair=1;
    122     %     [xtable2 ytable2 utable2 vtable2 ctable2 F2 result_conv2 errormsg2] = civ (Param.Civ1);
    123     %     xtable=[xtable1; xtable2];
    124     %     ytable=[ytable1; ytable2];
    125     %     utable=[utable1; -utable2];
    126     %     vtable=[vtable1; -vtable2];
    127     %     ctable=[ctable1; ctable2];
    128     %     F=[F1; F2];
    129     %     result_conv=[result_conv1; result_conv2];
    130     %     errormsg=[errormsg1; errormsg2];
    13189    if ~isempty(errormsg)
    13290        return
     
    271229        end
    272230    end
    273     ibx2=ceil(par_civ2.CorrBoxSize(1)/2);
    274     iby2=ceil(par_civ2.CorrBoxSize(2)/2);
    275     isx2=ibx2+4;% search ara +-4 pixels around the guess
    276     isy2=iby2+4;
    277     % shift from par_civ2.filename_nc1
    278     % shiftx=velocity interpolated at position
    279     miniy=max(1+isy2,1+iby2);
    280     minix=max(1+isx2,1+ibx2);
    281     maxiy=min(size(par_civ2.ImageA,1)-isy2,size(par_civ2.ImageA,1)-iby2);
    282     maxix=min(size(par_civ2.ImageA,2)-isx2,size(par_civ2.ImageA,2)-ibx2);
    283     [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy);
    284     GridX=reshape(GridX,[],1);
    285     GridY=reshape(GridY,[],1);
    286     Shiftx=zeros(size(GridX));% shift expected from civ1 data
    287     Shifty=zeros(size(GridX));
    288     nbval=zeros(size(GridX));
     231    %     ibx2=ceil(par_civ2.CorrBoxSize(1)/2);
     232    %     iby2=ceil(par_civ2.CorrBoxSize(2)/2);
     233    %     isx2=ibx2+4;% search ara +-4 pixels around the guess
     234    %     isy2=iby2+4;
     235    %     % shift from par_civ2.filename_nc1
     236    %     % shiftx=velocity interpolated at position
     237    %     miniy=max(1+isy2,1+iby2);
     238    %     minix=max(1+isx2,1+ibx2);
     239    %     maxiy=min(size(par_civ2.ImageA,1)-isy2,size(par_civ2.ImageA,1)-iby2);
     240    %     maxix=min(size(par_civ2.ImageA,2)-isx2,size(par_civ2.ImageA,2)-ibx2);
     241    %     [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy);
     242    %     GridX=reshape(GridX,[],1);
     243    %     GridY=reshape(GridY,[],1);
     244    if isfield(par_civ2,'Grid')% grid points set as input file
     245        if ischar(par_civ2.Grid)%read the grid file if the input is a file name
     246            par_civ2.Grid=dlmread(par_civ2.Grid);
     247            par_civ2.Grid(1,:)=[];%the first line must be removed (heading in the grid file)
     248        end
     249    else% automatic grid
     250        minix=floor(par_civ2.Dx/2)-0.5;
     251        maxix=minix+par_civ2.Dx*floor((par_civ2.ImageWidth-1)/par_civ2.Dx);
     252        miniy=floor(par_civ2.Dy/2)-0.5;
     253        maxiy=minix+par_civ2.Dy*floor((par_civ2.ImageHeight-1)/par_civ2.Dy);
     254        [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy);
     255        par_civ2.Grid(:,1)=reshape(GridX,[],1);
     256        par_civ2.Grid(:,2)=reshape(GridY,[],1);
     257    end
     258    Shiftx=zeros(size(par_civ2.Grid,1));% shift expected from civ1 data
     259    Shifty=zeros(size(par_civ2.Grid,1));
     260    nbval=zeros(size(par_civ2.Grid,1));
    289261    if par_civ2.CheckDeformation
    290         DUDX=zeros(size(GridX));
    291         DUDY=zeros(size(GridX));
    292         DVDX=zeros(size(GridX));
    293         DVDY=zeros(size(GridX));
     262        DUDX=zeros(size(par_civ2.Grid,1));
     263        DUDY=zeros(size(par_civ2.Grid,1));
     264        DVDX=zeros(size(par_civ2.Grid,1));
     265        DVDY=zeros(size(par_civ2.Grid,1));
    294266    end
    295267    NbSubDomain=size(Data.Civ1_SubRange,3);
     
    316288        mask=imread(par_civ2.Mask);
    317289    end
    318     par_civ2.SearchBoxSize(1)=2*isx2+1;
    319     par_civ2.SearchBoxSize(2)=2*isy2+1;
     290    ibx2=ceil(par_civ2.CorrBoxSize(1)/2);
     291    iby2=ceil(par_civ2.CorrBoxSize(2)/2);
     292    %     isx2=ibx2+4;% search ara +-4 pixels around the guess
     293    %     isy2=iby2+4;
     294    par_civ2.SearchBoxSize(1)=2*ibx2+9;% search ara +-4 pixels around the guess
     295    par_civ2.SearchBoxSize(2)=2*iby2+9;
     296    %par_civ2.SearchBoxSize(1)=2*isx2+1;
     297    %par_civ2.SearchBoxSize(2)=2*isy2+1;
    320298    par_civ2.SearchBoxShift=[Shiftx(nbval>=1)./nbval(nbval>=1) Shifty(nbval>=1)./nbval(nbval>=1)];
    321 %     par_civ2.SearchBoxShift(2)=Shifty(nbval>=1)./nbval(nbval>=1);
    322299    par_civ2.Grid=[GridX(nbval>=1)-par_civ2.SearchBoxShift(:,1)/2 GridY(nbval>=1)-par_civ2.SearchBoxShift(:,2)/2];% grid taken at the extrapolated origin of the displacement vectors
    323300    if par_civ2.CheckDeformation
     
    329306    % caluclate velocity data (y and v in indices, reverse to y component)
    330307    [xtable ytable utable vtable ctable F] = civ (par_civ2);
    331     %     diff_squared=(utable-par_civ2.Shiftx).*(utable-par_civ2.Shiftx)+(vtable+par_civ2.Shifty).*(vtable+par_civ2.Shifty);
    332     %     F(diff_squared>=4)=4; %flag vectors whose distance to the guess exceeds 2 pixels
    333308    list_param=(fieldnames(Param.Civ2))';
    334309    list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'};
     
    350325    end
    351326    Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param {'Civ2_Time','Civ2_Dt'}];
    352     %     Data.Civ2_Time=par_civ2.Time;
    353     %     Data.Civ2_Dt=par_civ2.Dt;
    354327    nbvar=numel(Data.ListVarName);
    355328    Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];%  cell array containing the names of the fields to record
     
    475448%methods perform better and will maybe be implemented in the future.
    476449
    477 %% prepare grid
     450%% prepare measurement grid
     451if isfield(par_civ,'Grid')% grid points set as input
     452    if ischar(par_civ.Grid)%read the drid file if the input is a file name
     453        par_civ.Grid=dlmread(par_civ.Grid);
     454        par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file)
     455    end
     456else% automatic grid
     457    minix=floor(par_civ.Dx/2)-0.5;
     458    maxix=minix+par_civ.Dx*floor((par_civ.ImageWidth-1)/par_civ.Dx);
     459    miniy=floor(par_civ.Dy/2)-0.5;
     460    maxiy=minix+par_civ.Dy*floor((par_civ.ImageHeight-1)/par_civ.Dy);
     461    [GridX,GridY]=meshgrid(minix:par_civ.Dx:maxix,miniy:par_civ.Dy:maxiy);
     462    par_civ.Grid(:,1)=reshape(GridX,[],1);
     463    par_civ.Grid(:,2)=reshape(GridY,[],1);
     464end
     465nbvec=size(par_civ.Grid,1);
     466
     467%% prepare correlation and search boxes
    478468ibx2=ceil(par_civ.CorrBoxSize(1)/2);
    479469iby2=ceil(par_civ.CorrBoxSize(2)/2);
     
    482472shiftx=round(par_civ.SearchBoxShift(:,1));
    483473shifty=-round(par_civ.SearchBoxShift(:,2));% sign minus because image j index increases when y decreases
    484 if isfield(par_civ,'Grid')
    485     if ischar(par_civ.Grid)%read the drid file if the input is a file name
    486         par_civ.Grid=dlmread(par_civ.Grid);
    487         par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file)
    488     end
    489 else% automatic measurement grid
    490 %     ibx2=ceil(par_civ.Bx/2);
    491 %     iby2=ceil(par_civ.By/2);
    492 %     isx2=ceil(par_civ.Searchx/2);
    493 %     isy2=ceil(par_civ.Searchy/2);
    494     miniy=max(1+isy2+shifty,1+iby2);
    495     minix=max(1+isx2-shiftx,1+ibx2);
    496     maxiy=min(par_civ.ImageHeight-isy2+shifty,par_civ.ImageHeight-iby2);
    497     maxix=min(par_civ.ImageWidth-isx2-shiftx,par_civ.ImageWidth-ibx2);
    498     [GridX,GridY]=meshgrid(minix:par_civ.Dx:maxix,miniy:par_civ.Dy:maxiy);
    499     par_civ.Grid(:,1)=reshape(GridX,[],1);
    500     par_civ.Grid(:,2)=reshape(GridY,[],1);
    501 end
    502 nbvec=size(par_civ.Grid,1);
    503 if numel(shiftx)==1
     474if numel(shiftx)==1% case of a unique shift for the whole field( civ1)
    504475    shiftx=shiftx*ones(nbvec,1);
    505476    shifty=shifty*ones(nbvec,1);
    506477end
     478
    507479%% Default output
    508480xtable=par_civ.Grid(:,1);
     
    561533    %  20>=mask: velocity=0
    562534checkmask=0;
     535MinA=min(min(par_civ.ImageA));
     536MinB=min(min(par_civ.ImageB));
    563537if isfield(par_civ,'Mask') && ~isempty(par_civ.Mask)
    564538   checkmask=1;
     
    569543  %  check_noflux=(par_civ.Mask<100) ;%TODO: to implement
    570544    check_undefined=(par_civ.Mask<200 & par_civ.Mask>=20 );
    571     par_civ.ImageA(check_undefined)=min(min(par_civ.ImageA));% put image A to zero (i.e. the min image value) in the undefined  area
    572     par_civ.ImageB(check_undefined)=min(min(par_civ.ImageB));% put image B to zero (i.e. the min image value) in the undefined  area
     545    par_civ.ImageA(check_undefined)=MinA;% put image A to zero (i.e. the min image value) in the undefined  area
     546    par_civ.ImageB(check_undefined)=MinB;% put image B to zero (i.e. the min image value) in the undefined  area
    573547end
    574548
     
    587561    jref=round(par_civ.ImageHeight-par_civ.Grid(ivec,2)+0.5);% yindex on the image B for the middle of the correlation box
    588562    if ~(checkmask && par_civ.Mask(jref,iref)<=20) %velocity not set to zero by the black mask
    589         if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth||...
    590               jref+shifty(ivec)-isy2<1||jref+shifty(ivec)+isy2>par_civ.ImageHeight|| iref+shiftx(ivec)-isx2<1 || iref+shiftx(ivec)+isx2>par_civ.ImageWidth  % we are outside the image
    591             F(ivec)=3;
    592         else
    593             image1_crop=par_civ.ImageA(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2);%extract a subimage (correlation box) from image A
    594             image2_crop=par_civ.ImageB(jref+shifty(ivec)-isy2:jref+shifty(ivec)+isy2,iref+shiftx(ivec)-isx2:iref+shiftx(ivec)+isx2);%extract a larger subimage (search box) from image B
     563%         if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth||...
     564%               jref+shifty(ivec)-isy2<1||jref+shifty(ivec)+isy2>par_civ.ImageHeight|| iref+shiftx(ivec)-isx2<1 || iref+shiftx(ivec)+isx2>par_civ.ImageWidth  % we are outside the image
     565%             F(ivec)=3;
     566%         else
     567            F(ivec)=0;
     568            subrange1_x=iref-ibx2:iref+ibx2;% x indices defining the first subimage
     569            subrange1_y=jref-iby2:jref+iby2;% y indices defining the first subimage
     570            subrange2_x=iref+shiftx(ivec)-isx2:iref+shiftx(ivec)+isx2;%x indices defining the second subimage
     571            subrange2_y=jref+shifty(ivec)-isy2:jref+shifty(ivec)+isy2;%y indices defining the second subimage
     572            image1_crop=MinA*ones(numel(subrange1_y),numel(subrange1_x));% default value=min of image A
     573            image2_crop=MinA*ones(numel(subrange2_y),numel(subrange2_x));% default value=min of image A
     574            check1_x=subrange1_x>=1 & subrange1_x<=par_civ.ImageWidth;% check which points in the subimage 1 are contained in the initial image 1
     575            check1_y=subrange1_y>=1 & subrange1_y<=par_civ.ImageHeight;
     576            check2_x=subrange2_x>=1 & subrange2_x<=par_civ.ImageWidth;% check which points in the subimage 2 are contained in the initial image 2
     577            check2_y=subrange2_y>=1 & subrange2_y<=par_civ.ImageHeight;
     578            image1_crop(check1_y,check1_x)=par_civ.ImageA(subrange1_y(check1_y),subrange1_x(check1_x));%extract a subimage (correlation box) from image A
     579            image2_crop(check2_y,check2_x)=par_civ.ImageB(subrange2_y(check2_y),subrange2_x(check2_x));%extract a larger subimage (search box) from image B
    595580            image1_mean=mean(mean(image1_crop));
    596581            image2_mean=mean(mean(image2_crop));
     
    603588                F(ivec)=3;
    604589            end
    605         end     
     590%         end     
    606591        if F(ivec)~=3
    607592            image1_crop=image1_crop-image1_mean;%substract the mean
  • trunk/src/find_field_cells.m

    r575 r576  
    2020%              _warnflag: index of warnflag   
    2121%      .FieldRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation  or derivatives (tps) is needed to calculate the requested field
    22 %      .Operation = operation to be performed to finalise the field cell after projection
     22%      .FieldName = operation to be performed to finalise the field cell after projection
    2323%      .SubCheck=0 /1 indicate that the field must be substracted (second  entry in uvmat)
    2424% NbDim: array with the length of CellVarIndex, giving the space dimension of each field cell
     
    8787Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks
    8888FieldRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default
    89 Operation=cell(size(Role)); % fieldRequest set to {} by default
     89FieldName=cell(size(Role)); % fieldRequest set to {} by default
    9090CheckSub=zeros(size(Role));% =1 for fields to substract
    9191Role=regexprep(Role,' ','scalar'); % Role set to 'scalar' by default
     
    9898            FieldRequest{ivar}=Data.VarAttribute{ivar}.FieldRequest;
    9999        end
    100         if isfield(Data.VarAttribute{ivar},'Operation')
    101             Operation{ivar}=Data.VarAttribute{ivar}.Operation;
     100        if isfield(Data.VarAttribute{ivar},'FieldName')
     101            FieldName{ivar}=Data.VarAttribute{ivar}.FieldName;
    102102        end
    103103        if isfield(Data.VarAttribute{ivar},'CheckSub')
     
    318318            CellInfo{icell}.FieldRequest=FieldRequest{ivar};
    319319        end
    320         if ~isempty(Operation{ivar})
    321             CellInfo{icell}.Operation=Operation{ivar};
     320        if ~isempty(FieldName{ivar})
     321            CellInfo{icell}.FieldName=FieldName{ivar};
    322322        end
    323323        if CheckSub(ivar)==1
  • trunk/src/proj_field.m

    r575 r576  
    861861%project on a plane
    862862% AJOUTER flux,circul,error
    863  function  [ProjData,errormsg] = proj_plane(FieldData, ObjectData)
     863function  [ProjData,errormsg] = proj_plane(FieldData, ObjectData)
    864864%-----------------------------------------------------------------
    865865
     
    11851185                        FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_warnflag});
    11861186                    end
    1187                     [VarVal,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([coord_X coord_Y],FieldData,CellInfo{icell}.Operation,XI,YI);
     1187                    [VarVal,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([coord_X coord_Y],FieldData,CellInfo{icell}.FieldName,XI,YI);
    11881188                    if isfield(CellInfo{icell},'CheckSub') && CellInfo{icell}.CheckSub && ~isempty(vector_x_proj)
    11891189                        ProjData.(ProjData.ListVarName{vector_x_proj})=ProjData.(ProjData.ListVarName{vector_x_proj})-VarVal{1};
     
    12211221                XI=XI+ObjectData.Coord(1,1);
    12221222                YI=YI+ObjectData.Coord(1,2);
    1223                 [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbSites,SubRange,FieldVar,CellInfo{icell}.Operation,cat(3,XI,YI));   
     1223                [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbSites,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI));   
    12241224                ListFieldProj=(fieldnames(DataOut))';
    12251225                VarDimName=cell(size(ListFieldProj));
  • trunk/src/read_civdata.m

    r517 r576  
    116116    Field.VarAttribute{ivar}.FieldRequest=FieldRequest;
    117117    if strcmp(role{var_ind(ivar)},'vector_x')
    118         Field.VarAttribute{ivar}.Operation=FieldNames;
     118        Field.VarAttribute{ivar}.FieldName=FieldNames;
    119119        ivar_U=ivar;
    120120    end
    121121    if strcmp(role{var_ind(ivar)},'vector_x_tps')
    122         Field.VarAttribute{ivar}.Operation=FieldNames;
     122        Field.VarAttribute{ivar}.FieldName=FieldNames;
    123123        ivar_U_tps=ivar;
    124124    end
  • trunk/src/read_field.m

    r575 r576  
    4141    if isfield(ParamIn,'FieldName')
    4242        if ischar(ParamIn.FieldName)
    43             ParamIn.FieldName={ParamIn.FieldName};
     43            InputField={ParamIn.FieldName};
    4444        else
    4545            InputField= ParamIn.FieldName;
  • trunk/src/set_grid.m

    r342 r576  
    2222function varargout = set_grid(varargin)
    2323
    24 % Last Modified by GUIDE v2.5 23-Apr-2010 15:44:47
     24% Last Modified by GUIDE v2.5 01-Mar-2013 22:41:43
    2525
    2626% Begin initialization code - DO NOT PLOT
     
    3232                   'gui_LayoutFcn',  [] , ...
    3333                   'gui_Callback',   []);
    34 % if nargin & isstr(varargin{1})
    35 %     gui_State.gui_Callback = str2func(varargin{1});
    36 % end
     34               
    3735if nargin && ischar(varargin{1})
    3836    gui_State.gui_Callback = str2func(varargin{1});
     
    4341    gui_mainfcn(gui_State, varargin{:});
    4442end
    45 % End initialization code - DO NOT PLOT
    4643
    4744%-------------------------------------------------------------------
     
    5451%'data': read from an existing object selected in the interface
    5552%      .TITLE : class of object ('POINTS','LINE',....)
    56 %      .DX,DY,DZ; meshes for regular grids
     53%      .num_DX,num_DY,DZ; meshes for regular grids
    5754%      .Coord: object position coordinates
    5855%      .ParentButton: handle of the uicontrol object calling the interface
     
    6057%  if =[] or absent, no plot (mask mode in uvmat)
    6158% parameters on the uvmat interface (obtained by 'get_plot_handle.m')
    62 function set_grid_OpeningFcn(hObject, eventdata, handles,inputfile,CoordType)
     59function set_grid_OpeningFcn(hObject, eventdata, handles,InputFile,InputField)
    6360
    6461% Choose default command line output for set_grid
     
    6865guidata(hObject, handles);
    6966
    70 %default
    71 % set(hObject,'Unit','Normalized')% set the unit normalized to the screen size
    72 % set(hObject,'Position',[0.7 0.1 0.25 0.5])%set the position of the set_grid interface
     67%default
    7368set(hObject,'DeleteFcn',@closefcn)
    74 % set(handles.TITLE,'Value',1)
    75 %set(handles.ObjectStyle,'Value',1)
    76 %set(handles.ProjMode,'Value',1)
    77 set(handles.MenuCoord,'ListboxTop',1)
    78 set(handles.MenuCoord,'Value',1);
    79 set(handles.MenuCoord,'String',{'phys';'px'});
    80 if exist('inputfile','var')& ~isempty(inputfile)
    81    set(handles.image_1,'String',inputfile)
    82    set(handles.image_2,'String',inputfile)
    83 end
    84 if exist('CoordType','var')
    85     if strcmp(CoordType,'px')
    86         set(handles.MenuCoord,'Value',2)
    87     end
     69set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
     70set(handles.CoordType,'ListboxTop',1)
     71set(handles.CoordType,'Value',1);
     72set(handles.CoordType,'String',{'phys';'px'});
     73if exist('InputFile','var')
     74   set(handles.ImageA,'String',InputFile)
     75end
     76
     77%% use InputField input from uvmat
     78check_pixel=0;
     79if exist('InputField','var')
     80    if strcmp(InputField.CoordUnit,'pixel')
     81        set(handles.CoordType,'Value',2)
     82        set(handles.TxtWarning,'Visible','on')
     83        Mesh=20;%default mesh in pixel
     84        check_pixel=1;
     85    else
     86        set(handles.CoordType,'Value',1)
     87        InputField.CoordMesh=20*InputField.CoordMesh; % about 20 pixels
     88        % adjust the mesh to a value 1, 2 , 5 *10^n
     89        ord=10^(floor(log10(InputField.CoordMesh)));%order of magnitude
     90        if InputField.CoordMesh/ord>=5
     91            Mesh=5*ord;
     92        elseif InputField.CoordMesh/ord>=2
     93            Mesh=2*ord;
     94        else
     95            Mesh=ord;
     96        end
     97    end
     98    Input.DX=Mesh;
     99    Input.DY=Mesh;
     100    Input.XMin=(Mesh/2)*ceil(InputField.XMin/(Mesh/2))-0.5*check_pixel;
     101    Input.XMax=Input.XMin+Mesh*floor((InputField.XMax-Input.XMin)/Mesh)-0.5*check_pixel;
     102    Input.YMin=(Mesh/2)*ceil(InputField.YMin/(Mesh/2))-0.5*check_pixel;
     103    Input.YMax=Input.YMin+Mesh*floor((InputField.YMax-Input.YMin)/Mesh)-0.5*check_pixel;
     104    errormsg=fill_GUI(Input,handles);
    88105end
    89106
     
    93110varargout{1} = handles.output;
    94111varargout{2}=handles;
    95 
    96 
    97 %-----------------------------------------------------
    98 % --- Executes on button press in import.
    99 function import_Callback(hObject, eventdata, handles)
    100 %get the object file
    101 oldfile='';
    102 huvmat=findobj('Tag','uvmat');
    103 if isempty(huvmat)
    104     huvmat=findobj(allchild(0),'Name','series');
    105 end
    106 hchild=get(huvmat,'Children');
    107 hrootpath=findobj(hchild,'Tag','RootPath');
    108 oldfile=get(hrootpath,'String');
    109 if iscell(oldfile)
    110     oldfile=oldfile{1};
    111 end
    112 %[FileName,PathName] = uigetfile('*.civ','Select a .civ file',oldfile)
    113 [FileName, PathName, filterindex] = uigetfile( ...
    114        {'*.xml;*.mat', ' (*.xml,*.mat)';
    115        '*.xml',  '.xml files '; ...
    116         '*.mat',  '.mat matlab files '}, ...
    117         'Pick a file',oldfile);
    118 fileinput=[PathName FileName];%complete file name
    119 testblank=findstr(fileinput,' ');%look for blanks
    120 if ~isempty(testblank)
    121     errordlg('forbidden input file name: contain blanks')
    122     return
    123 end
    124 sizf=size(fileinput);
    125 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
    126 
    127 %read the file
    128  t=xmltree(fileinput);
    129  s=convert(t);
    130 testmode=0;
    131 if isfield(s,'ProjMode')
    132         menu=get(handles.ProjMode,'String');
    133         for iline=1:length(menu)
    134             if isequal(menu{iline},s.ProjMode)
    135                 set(handles.ProjMode,'Value',iline)
    136                 testmode=1;
    137                 break
    138             end
    139         end
    140 end
    141 
    142 ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes
    143 if isfield(s,'CoordType')
    144     if isequal(s.CoordType,'phys')
    145         set(handles.MenuCoord,'Value',1)
    146     elseif isequal(s.CoordType,'px')
    147         set(handles.MenuCoord,'Value',2)
    148     else
    149         warndlg('unknown CoordType (px or phys) in set_grid.m')
    150     end
    151 end
    152 if isfield(s,'XMax')
    153     set(handles.XMax,'String',s.XMax)
    154 end
    155 if isfield(s,'XMin')
    156     set(handles.XMin,'String',s.XMin)
    157 end
    158 if isfield(s,'YMax')
    159     set(handles.YMax,'String',s.YMax)
    160 end
    161 if isfield(s,'YMin')
    162     set(handles.YMin,'String',s.YMin)
    163 end
    164 if isfield(s,'DX')
    165     set(handles.DX,'String',s.DX)
    166 end
    167 if isfield(s,'DY')
    168     set(handles.DY,'String',s.DY)
    169 end
    170 if ~isfield(s,'Coord')
    171     XObject='0';%default
    172     YObject='0';
    173 elseif ischar(s.Coord)
    174     line=str2num(s.Coord);
    175     XObject=num2str(line(1));
    176     YObject=num2str(line(2));
    177 else
    178     for i=1:length(s.Coord)
    179         line=str2num(s.Coord{i});
    180         XObject{i}=num2str(line(1));
    181         YObject{i}=num2str(line(2));
    182     end
    183 end
    184 set(handles.XObject,'String',XObject)
    185 set(handles.YObject,'String',YObject)
    186 %METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_grid_Opening
    187112
    188113%----------------------------------------------------
     
    196121    if isequal(tag,'edit')
    197122        set(parent_button,'BackgroundColor',[0.7 0.7 0.7]);
    198     else 
     123    else
    199124        set(parent_button,'BackgroundColor',[0 1 0]);
    200125    end
     
    204129% --- Executes on button press in plot: PLOT the defined object and its projected field
    205130function plot_Callback(hObject, eventdata, handles)
    206 grid_pix_A=get_grid(handles);
    207 huvmat=uvmat(get(handles.image_1,'String'));
     131[grid_pix_A,grid_pix_B,grid_phys]=get_grid(read_GUI(handles.set_grid));
     132huvmat=findobj(allchild(0),'tag','uvmat');
    208133hhuvmat=guidata(huvmat);
    209 set(hhuvmat.transform_fct,'Value',1)
    210 uvmat('run0_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
    211 axes(hhuvmat.axes3);
     134axes(hhuvmat.PlotAxes);
    212135hold on
    213 plot(grid_pix_A(:,1),grid_pix_A(:,2),'.')
    214 
    215 % --- Executes on button press in plot_2.
    216 function plot_2_Callback(hObject, eventdata, handles)
    217 [grid_pix_A,grid_pix_B]=get_grid(handles);
    218 huvmat=uvmat(get(handles.image_2,'String'));
    219 hhuvmat=guidata(huvmat);
    220 set(hhuvmat.transform_fct,'Value',1)
    221 uvmat('run0_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
    222 axes(hhuvmat.axes3);
    223 hold on
    224 plot(grid_pix_B(:,1),grid_pix_B(:,2),'.')
    225 
    226 
    227 
    228 % --- Executes on button press in MenuCoord.
    229 function MenuCoord_Callback(hObject, eventdata, handles)
    230 
     136UvData=get(huvmat,'UserData');
     137if isfield(UvData.Field, 'CoordUnit')&& strcmp(UvData.Field.CoordUnit,'pixel')
     138    plot(grid_pix_A(:,1),grid_pix_A(:,2),'.')
     139else
     140    plot(grid_phys(:,1),grid_phys(:,2),'.')
     141end
     142
     143%% display grid in second image defiend
     144if ~isempty(grid_pix_B)
     145    hviewfield=view_field(get(handles.imageB,'String'));
     146    hhviewfield=guidata(hviewfield);
     147    axes(hhviewfield.PlotAxes);
     148    hold on
     149    if isfield(UvData.Field, 'CoordUnit')&& strcmp(UvData.Field.CoordUnit,'pixel')
     150        plot(grid_pix_B(:,1),grid_pix_B(:,2),'.')
     151    else
     152        plot(grid_phys(:,1),grid_phys(:,2),'.')
     153    end
     154end
     155
     156%------------------------------------------------------------------------
     157% --- Executes on button press in CoordType.
     158function CoordType_Callback(hObject, eventdata, handles)
     159%------------------------------------------------------------------------
     160set(handles.num_XMin,'String','')
     161set(handles.num_XMax,'String','')
     162set(handles.num_DX,'String','')
     163set(handles.num_YMin,'String','')
     164set(handles.num_YMax,'String','')
     165set(handles.num_DY,'String','')
     166set(handles.num_Z,'String','')
     167if isequal(get(handles.CoordType,'Value'),2)
     168    set(handles.TxtWarning,'visible','on')
     169else
     170    set(handles.TxtWarning,'visible','on')
     171end
    231172
    232173%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    247188
    248189% ------------------------------------------------------
    249 function save_Callback(hObject, eventdata, handles)
     190function Save_Callback(hObject, eventdata, handles)
    250191% ------------------------------------------------------
    251 [grid_pix_A,grid_pix_B]=get_grid(handles);
     192[grid_pix_A,grid_pix_B]=get_grid(read_GUI(handles.set_grid));
     193
    252194
    253195 %ECRIRE FICHIERS
    254196nbpointsA=size(grid_pix_A);
    255 XA=grid_pix_A(:,1);
     197XA=grid_pix_A(:,1);%index=position+0.5 rounded at the nearest integer value
    256198YA=grid_pix_A(:,2);
    257199unitcolumn=32*ones(size(XA));
     
    263205textgrid={tete;txt};
    264206textout=char(textgrid);
    265 imageA=get(handles.image_1,'String');
     207imageA=get(handles.ImageA,'String');
    266208RootPath=fileparts_uvmat(imageA);
    267 %[Pathsub]=name2display(imageA);
    268209Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(RootPath,'gridA.grid'));
    269 % Answer = inputdlg('grid file name (*.grid)',' ',1,{fullfile(Pathsub,'gridA.grid')},'on');
    270210dlmwrite(Answer,textout,'');
    271211msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']);
    272212if ~isempty(grid_pix_B)
    273213    nbpointsB=size(grid_pix_B);
    274     XB=grid_pix_B(:,1);
    275     YB=grid_pix_B(:,2);
     214    XB=round(grid_pix_B(:,1)+0.5);%index=position+0.5 rounded at the nearest integer value
     215    YB=round(grid_pix_B(:,2)+0.5);
    276216    unitcolumn=32*ones(size(XB));
    277217    Xchar=num2str(XB);
     
    287227end
    288228
    289 %-------------------------
    290 function [grid_pix_A,grid_pix_B]=get_grid(handles)
    291 %Object=read_set_object(handles);%read the set_grid interface;
     229
     230%------------------------------------------------------------------------
     231function [grid_pix_A,grid_pix_B,grid_phys]=get_grid(GUI)
     232%------------------------------------------------------------------------
    292233grid_pix_B=[];%default
    293 DX=str2num(get(handles.DX,'String'));
    294 DY=str2num(get(handles.DY,'String'));
    295 XMin=str2num(get(handles.XMin,'String'));
    296 XMax=str2num(get(handles.XMax,'String'));
    297 YMin=str2num(get(handles.YMin,'String'));
    298 YMax=str2num(get(handles.YMax,'String'));
    299 array_realx=XMin:DX:XMax;
    300 array_realy=YMin:DY:YMax;
    301 nx_patch=length(array_realx);
    302 ny_patch=length(array_realy);
    303 [grid_realx,grid_realy]=meshgrid(array_realx,array_realy);
    304 grid_real(:,1)=reshape(grid_realx,nx_patch*ny_patch,1);
    305 grid_real(:,2)=reshape(grid_realy,nx_patch*ny_patch,1);
    306 grid_real(:,3)=zeros(nx_patch*ny_patch,1);
    307  
    308 imageA=get(handles.image_1,'String');
    309 imageB=get(handles.image_2,'String');
    310 testB=1;
    311 if isempty(imageA) || isequal(imageA,'')
    312     if isempty(imageB) || isequal(imageB,'')
    313         msgbox_uvmat('ERROR','at least one image file name must be introduced')
    314     else
    315         imageA=imageB;
    316         testB=0;
    317     end
    318 end
    319 if isempty(imageB) || isequal(imageB,'') || isequal(imageA,imageB)
    320     testB=0;
    321 end
    322 
    323 testexist=exist(imageA,'file');
    324 if isequal(testexist,0)
     234array_x=GUI.XMin:GUI.DX:GUI.XMax;% array of x values
     235array_y=GUI.YMin:GUI.DY:GUI.YMax;% array of y values
     236[grid_x,grid_y]=meshgrid(array_x,array_y);% matrices of x and y values
     237grid_x=reshape(grid_x,[],1); %matrix of x  values reshaped in line
     238grid_y=reshape(grid_y,[],1);%matrix of y values reshaped in line
     239% grid_z=zeros(nx_patch*ny_patch,1);% plane coordinates (TODO: 3D grids)
     240
     241%% check the input image A
     242if ~exist(GUI.ImageA,'file')
    325243    msgbox_uvmat('ERROR',['input image file' imageA 'does not exist'])
    326244    return
    327245end
    328 %[Pathsub,RootFile,field_count,str2,str_a,str_b,FileExt,NomType,SubDir]=name2display(imageA);
    329 [RootPath,~,RootFile,~,~,~,~,FileExt]=fileparts_uvmat(imageA);
    330 form=imformats(FileExt(2:end));
    331 if isempty(form)% if the extension corresponds to an image format recognized by Matlab
    332      msgbox_uvmat('ERROR',['error: ' imageA ' is not an image name recognized by Matlab '])
    333      return
    334 end
    335 fileAxml=[fullfile(RootPath,RootFile) '.xml'];
    336 [XmlDataA,error]=imadoc2struct(fileAxml);
    337 if isfield(XmlDataA,'GeometryCalib')
    338      tsaiA=XmlDataA.GeometryCalib;
    339  else
    340      msgbox_uvmat('WARNING','no geometric calibration available for image A')
    341      tsaiA=[];
    342 end
    343 MenuCoord=get(handles.MenuCoord,'String');
    344 val=get(handles.MenuCoord,'Value');
    345 if isempty(tsaiA)||strcmp(MenuCoord{val},'px')
    346     grid_imaA(:,1)=grid_real(:,1);
    347     grid_imaA(:,2)=grid_real(:,2);
    348 else
    349     [grid_imaA(:,1),grid_imaA(:,2)]=px_XYZ(tsaiA,grid_real(:,1),grid_real(:,2),0);
    350 end
    351     A=imread(imageA);
    352    siz=size(A);
    353    npxA=siz(2);
    354    npyA=siz(1);
    355 
    356 flagA=grid_imaA(:,1)>0 & grid_imaA(:,1)<npxA & grid_imaA(:,2)>0 & grid_imaA(:,2)<npyA;
    357 
    358 if testB
    359     testexist=exist(imageB,'file');
    360     if isequal(testexist,0)
    361         msgbox_uvmat('ERROR',['input image file' imageB 'does not exist'])
     246[FileType,tild,VideoObject]=get_file_type(GUI.ImageA);
     247switch FileType
     248    case {'image','multimage','video','mmreader'}% case of input image or movie OK
     249    otherwise
     250        msgbox_uvmat('ERROR',['error: ' GUI.ImageA ' is not an image type recognized by Matlab '])
    362251        return
    363     end
    364     %[RootPath,RootFile,field_count,str2,str_a,str_b,FileExt,NomType,SubDir]=name2display(imageB);
    365     [RootPath,~,RootFile,~,~,~,~,FileExt]=fileparts_uvmat(imageB);
    366     form=imformats(FileExt(2:end));
    367     if isempty(form)% if the extension corresponds to an image format recognized by Matlab
    368         msgbox_uvmat('ERROR',['error: ' imageB ' is not an image name recognized by Matlab '])
     252end
     253[RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(GUI.ImageA);
     254
     255%% transform to pixels if the grid is defined in phys coordinates
     256grid_x_imaA=grid_x;%default grid in image A coordinates
     257grid_y_imaA=grid_y;
     258% MenuCoord=get(handles.CoordType,'String');% type of coordinates for grid definition, phys or pixel
     259if strcmp(GUI.CoordType,'phys')
     260    fileAxml=fullfile(RootPath,[SubDir '.xml']);% new convention for xml name
     261    if ~exist(fileAxml,'file')
     262        fileAxml=[fullfile(RootPath,RootFile) '.xml'];% old convention for xml name
     263    end
     264    tsaiA=[];%default
     265    if exist(fileAxml,'file')
     266        [XmlDataA,errormsg]=imadoc2struct(fileAxml);
     267        if ~isempty(errormsg)
     268            msgbox_uvmat('ERROR',['error in ' fileAxml ': ' errormsg])
     269            return
     270        end
     271        if isfield(XmlDataA,'GeometryCalib')
     272            tsaiA=XmlDataA.GeometryCalib;
     273        end
     274    end
     275    if isempty(tsaiA)
     276        msgbox_uvmat('WARNING','no geometric calibration available for image A, phys =pixel')
     277    else
     278        [grid_x_imaA,grid_y_imaA]=px_XYZ(tsaiA,grid_x,grid_y,GUI.Z);
     279    end
     280end
     281
     282%% detect the grid points which are inside image A
     283A=read_image(GUI.ImageA,FileType,VideoObject,1);
     284npxA=size(A,2);
     285npyA=size(A,1);
     286flag=grid_x_imaA>=1 & grid_x_imaA<=npxA & grid_y_imaA>=1 & grid_y_imaA<=npyA;% ='true' inside the image
     287
     288%% detect the grid points which are inside image B if relevant (use for stereo PIV)
     289if isfield(GUI,'ImageB')
     290    if ~exist(imageB,'file')
     291        msgbox_uvmat('ERROR',['input image file' GUI.ImageB 'does not exist'])
    369292        return
    370293    end
    371     fileBxml=[fullfile(RootPath,RootFile) '.xml'];
    372     [XmlDataB,error]=imadoc2struct(fileBxml);
    373     if isfield(XmlDataB,'GeometryCalib')
    374         tsaiB=XmlDataB.GeometryCalib;
    375     else
    376         msgbox_uvmat('WARNING','no geometric calibration available for image B')
    377         tsaiB=[];
    378     end
    379     %[error,Heading,NomType_read,ext_ima_read,time,TimeUnit,mode,NbSlice,...
    380     %     npxB,npyB,tsaiB]=read_imadoc(fileBxml,0);
    381     [grid_imaB(:,1),grid_imaB(:,2)]=px_XYZ(tsaiB,grid_real(:,1),grid_real(:,2),0);
    382     %     if isempty(npxB)|isempty(npyB)
    383     B=imread(imageB);
    384     siz=size(B);
    385     npxB=siz(2);
    386     npyB=siz(1);
    387     %     end
    388     flagB=grid_imaB(:,1)>0 & grid_imaB(:,1)<npxB & grid_imaB(:,2)>0 & grid_imaB(:,2)<npyB;
    389 end
    390 if testB
    391     ind_good=find(flagA==1&flagB==1);
    392     XimaB=grid_imaB(ind_good,1);
    393     YimaB=grid_imaB(ind_good,2);
    394 else
    395     ind_good=find(flagA==1);
    396 end
    397 XimaA=grid_imaA(ind_good,1);
    398 YimaA=grid_imaA(ind_good,2);
    399 
    400 grid_real_x=grid_real(ind_good,1);
    401 grid_real_y=grid_real(ind_good,2);
    402 nx_patch_new=length(grid_real_x);
    403 grid_real2(:,1)=grid_real_x;
    404 grid_real2(:,2)=grid_real_y;
    405 grid_real2(:,3)=zeros(nx_patch_new,1);
    406 if isempty(tsaiA)||strcmp(MenuCoord{val},'px')
    407     grid_pix_A(:,1)=grid_real2(:,1);
    408    grid_pix_A(:,2)= grid_real2(:,2);
    409 else
    410     [grid_pix_A(:,1),grid_pix_A(:,2)]=px_XYZ(tsaiA,grid_real2(:,1),grid_real2(:,2));
    411 end
    412 if testB
    413     [grid_pix_B(:,1),grid_pix_B(:,2)]=px_XYZ(tsaiB,grid_real2(:,1),grid_real2(:,2));
    414 end
    415 
     294    [RootPathB,SubDirB,RootFileB,tild,tild,tild,tild,FileExt]=fileparts_uvmat(GUI.ImageB);
     295    fileBxml=fullfile(RootPathB,[SubDirB '.xml']);% new convention for xml name
     296    if ~exist(fileBxml,'file')
     297        fileBxml=[fullfile(RootPathB,RootFileB) '.xml'];% old convention for xml name
     298    end
     299    tsaiB=[];%default
     300    if exist(fileBxml,'file')
     301        [XmlDataB,errormsg]=imadoc2struct(fileBxml);
     302        if ~isempty(errormsg)
     303            msgbox_uvmat('ERROR',['error in ' fileAxml ': ' errormsg])
     304            return
     305        end
     306        if isfield(XmlDataB,'GeometryCalib')
     307            tsaiB=XmlDataB.GeometryCalib;
     308        end
     309    end
     310    if isempty(tsaiB)
     311        msgbox_uvmat('WARNING','no geometric calibration available for image B, phys =pixel')
     312        grid_x_imaB=grid_x;
     313        grid_y_imaB=grid_y;
     314    else
     315        [grid_x_imaB,grid_y_imaB]=px_XYZ(tsaiB,grid_x,grid_y,GUI.Z);
     316    end
     317    B=imread(GUI.ImageB);
     318    npxB=size(B,2);
     319    npyB=size(B,1);
     320    flagB=grid_x_imaB>=1 & grid_x_imaB<=npxB & grid_y_imaB>=1 & grid_y_imaB<=npyB;
     321    flag=flagA & flagB;
     322    grid_pix_B(:,1)=round(grid_x_imaB(flag));
     323    grid_pix_B(:,2)=round(grid_y_imaB(flag));
     324end
     325
     326grid_x_imaA=grid_x_imaA(flag);
     327grid_y_imaA=grid_y_imaA(flag);
     328grid_pix_A=[grid_x_imaA grid_y_imaA];
     329grid_x=grid_x(flag);
     330grid_y=grid_y(flag);
     331grid_phys=[grid_x grid_y];
     332
     333
     334function GetImageB_Callback(hObject, eventdata, handles)
     335if isequal(get(handles.GetImageB,'Value'),1)
     336    set(handles.ImageB,'Visible','on')
     337    [FileName, PathName, filterindex] = uigetfile( ...
     338            {'*.*', 'All Files (*.*)'}, ...
     339            'Pick the second image file',fileparts(fileparts(get(handles.ImageA,'String'))));
     340        ImageB=fullfile(PathName,FileName);
     341        [FileType,tild,VideoObject]=get_file_type(ImageB);
     342    switch FileType
     343        case {'image','multimage','video','mmreader'}% case of input image or movie OK
     344            set(handles.ImageB,'String',ImageB)
     345        otherwise
     346            msgbox_uvmat('ERROR',['error: ' imageB ' is not an image type recognized by Matlab '])
     347            return
     348    end
     349else
     350    set(handles.ImageB,'Visible','off')
     351end
    416352
    417353
     
    430366
    431367
     368function ImageA_Callback(hObject, eventdata, handles)
     369% hObject    handle to ImageA (see GCBO)
     370% eventdata  reserved - to be defined in a future version of MATLAB
     371% handles    structure with handles and user data (see GUIDATA)
     372
     373% Hints: get(hObject,'String') returns contents of ImageA as text
     374%        str2double(get(hObject,'String')) returns contents of ImageA as a double
  • trunk/src/uvmat.m

    r575 r576  
    216216
    217217%% load the list of previously browsed files in menus Open, Open_1 and transform_fct
    218  dir_perso=prefdir; % path to the directory .matlab for personal data
    219  profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
     218 dir_perso=prefdir; % path to the directory .matlab containing the personal data of the current user
     219 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmat_perso.mat' in .matlab
    220220 if exist(profil_perso,'file')
    221221     h=load (profil_perso);
    222222     if isfield(h,'MenuFile')% load the menu of previously opened files
    223223         for ifile=1:min(length(h.MenuFile),5)
    224              eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
    225              eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});'])
     224             set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile});
     225             set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',h.MenuFile{ifile});
    226226         end
     227     end
     228     if isfield(h,'RootPath')
     229         set(handles.RootPath,'UserData',h.RootPath); %store the previous campaign in the UserData of RootPath
    227230     end
    228231     if isfield(h,'transform_fct') && iscell(h.transform_fct) % load the menu of transform fct set by user
     
    335338[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    336339oldfile=fullfile(RootPath,SubDir);
    337 if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
    338          dir_perso=prefdir;
    339          profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    340          if exist(profil_perso,'file')
    341               h=load (profil_perso);
    342              if isfield(h,'MenuFile_1')
    343                   oldfile=h.MenuFile_1;
    344              end
    345          end
     340if isempty(oldfile) %loads the previously stored file name and set it as default in the file_input box
     341    oldfile=get(handles.RootPath,'UserData');
    346342end
    347343[FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile);
     
    357353function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
    358354% -----------------------------------------------------------------------
    359 CampaignPath=fileparts(fileparts(get(handles.RootPath,'String')));
     355RootPath=get(handles.RootPath,'String');
     356if isempty(RootPath)
     357    RootPath=get(handles.RootPath,'UserData');%use Rootpath recored from the personal file at uvmat opening
     358end
     359CampaignPath=fileparts(fileparts(RootPath));
    360360DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK');
    361361if ~ischar(DirFull)|| ~exist(DirFull,'dir')
     
    447447set(handles.MenuFile_4_1,'Label',MenuFile_4)
    448448set(handles.MenuFile_5_1,'Label',MenuFile_5)
    449 dir_perso=prefdir;
    450 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    451 if exist(profil_perso,'file')
    452     save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
    453 else
    454     txt=ver('MATLAB');
    455     Release=txt.Release;
    456     relnumb=str2double(Release(3:4));
    457     if relnumb >= 14
    458         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
    459     else
    460         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
    461     end
    462 end
     449% dir_perso=prefdir;
     450% profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     451% if exist(profil_perso,'file')
     452%     save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
     453% else
     454%     txt=ver('MATLAB');
     455%     Release=txt.Release;
     456%     relnumb=str2double(Release(3:4));
     457%     if relnumb >= 14
     458%         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
     459%     else
     460%         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
     461%     end
     462% end
    463463
    464464% --------------------------------------------------------------------
     
    787787end
    788788for ifile=1:min(length(MenuFile),5)
    789     eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
    790     eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',MenuFile{ifile});'])
     789    set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile});
     790    set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',MenuFile{ifile});
    791791end
    792792dir_perso=prefdir;
    793793profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    794794if exist(profil_perso,'file')
    795     save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat
     795    save (profil_perso,'MenuFile','RootPath','-append'); %store the file names for future opening of uvmat
    796796else
    797     save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat
     797    save (profil_perso,'MenuFile','RootPath','-V6'); %store the file names for future opening of uvmat
    798798end
    799799
     
    14111411        choice_value=get(handles.transform_fct,'Value');
    14121412        transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
    1413 %         transform_list=get(handles.transform_fct,'UserData');
    1414 %         transform=transform_list{choice_value};
    14151413        transform=get(handles.path_transform,'UserData');
    14161414        if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
     
    14411439            axes(handles.PlotAxes)
    14421440            hold on   
    1443             size(flagmask)
    1444            % MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
    14451441            MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask)));
    1446 %             set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
    14471442            set(handles.CheckMask,'UserData',MaskData)
    14481443        end
     
    19321927
    19331928%px to phys or other transform on field
    1934 % menu_transform=get(handles.transform_fct,'String');
    1935 % choice_value=get(handles.transform_fct,'Value');
    1936 % transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
    1937 % transform_list=get(handles.transform_fct,'UserData');
    19381929transform=get(handles.path_transform,'UserData');
    19391930if  ~isempty(transform)
     
    20672058        list_fields=get(handles.FieldName,'String');% list menu fields
    20682059        FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field
     2060        % if get_field... is selected, the GUI get_field will be used to enter fields
    20692061        if ~strcmp(FieldName,'get_field...')
    20702062            if get(handles.FixVelType,'Value')
     
    20732065            end
    20742066        end
     2067        % case of input vector field, get the scalar used for vector color
    20752068        if ~isempty(regexp(FieldName,'^vec('))
    20762069            list_code=get(handles.ColorCode,'String');% list menu fields
     
    21322125end
    21332126Field{1}.ZIndex=z_index; %used for multiplane 3D calibration
    2134 % end
     2127
    21352128
    21362129%% choose and read a second field FileName_1 if defined
     
    24612454end
    24622455
     2456%UvData.Field=get_bounds(UvData.Field);
    24632457
    24642458%% get bounds and mesh (needed  to propose default options for projection objects)
     
    33913385%-------------------------------------------------------
    33923386%
    3393 % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    33943387if isequal(get(handles.edit_vect,'Value'),1)
    33953388    test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
     
    34033396    set(handles.CheckZoom,'Value',0)
    34043397    set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
    3405 %     set(handles.create,'Value',0)
    3406 %     set(handles.create,'BackgroundColor',[0 1 0])
    34073398    set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
    34083399    set(gcf,'Pointer','arrow')
    3409 %     UvData.MouseAction='edit_vect';
    34103400else
    34113401    set(handles.record,'Visible','off')
     
    41434133function edit_object_Callback(hObject, eventdata, handles)
    41444134%-------------------------------------------------------------------
    4145 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    41464135hset_object=findobj(allchild(0),'Tag','set_object');
    41474136if get(handles.edit_object,'Value')
     
    49034892[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    49044893FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    4905 CoordList=get(handles.transform_fct,'String');
    4906 val=get(handles.transform_fct,'Value');
    4907 set_grid(FileName,CoordList{val});% call the set_object interface
     4894UvData=get(handles.uvmat,'UserData');
     4895% CoordList=get(handles.transform_fct,'String');
     4896% val=get(handles.transform_fct,'Value');
     4897set_grid(FileName,UvData.Field);% call the set_object interface
    49084898
    49094899
Note: See TracChangeset for help on using the changeset viewer.