Changeset 1201 for trunk/src/uvmat.m


Ignore:
Timestamp:
Mar 23, 2026, 4:49:29 PM (3 hours ago)
Author:
sommeria
Message:

various improvements...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r1200 r1201  
    1 %'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization
     1%'uvmat': function associated with the master GUI 'uvmat.fig' for the visualisation of images and data fields
    22%------------------------------------------------------------------------
    33% function huvmat=uvmat(input)
     
    220220
    221221%% EXPORT menu
    222 export_menu={'as field in workspace';'in new figure';'on existing axis';'make movie';'more...'};
     222export_menu={'field in workspace';'field in new figure';'field on existing axis';'make movie';'create mirror data tree';'more...'};
    223223
    224224%% load the list of previously browsed files in menus Open, Open_1 and TransformName
     
    363363CoordinatesPanelHeight=100;
    364364ScalarPanelHeight=150;
     365FieldIndicesHeight=220;
     366NavigateHeight=120;
     367TransformHeight=100;
     368ObjectsHeight=150;
    365369Interval=2;
    366370
     
    433437
    434438%% reset position and scale of axis
    435 pos(1)=0.2*size_uvmat(3)+35;
    436 pos(2)=50;
    437 pos(3)=0.77*size_uvmat(3)-1.2*ColumnWidth;
     439pos(1)=1.2*ColumnWidth+50;%axis x position
     440pos(2)=50;%axis y position
     441pos(3)=size_uvmat(3)-2.2*ColumnWidth-100;%axis width
    438442pos(4)=pos_InputFile(2)-50-Interval;
    439443set(handles.PlotAxes,'Units','pixels')
     
    441445%set(handles.PlotAxes,'Units','normalized')
    442446UvData=get(handles.uvmat,'UserData');
    443 UvData.PosColorbar([1 3])=[pos(1)+pos(3)+10 10]/size_uvmat(3);
     447UvData.PosColorbar([1 3])=[pos(1)+pos(3)+10 15]/size_uvmat(3);%x position and width of the colorbar
    444448UvData.PosColorbar([2 4])=[pos(2)+pos(3)/4 pos(3)/2]/size_uvmat(4);
    445449set(handles.uvmat,'UserData',UvData)
    446450
    447 %% reset position of Field Indices TODO
    448 % set(handles.FieldIndices,'Units','pixels')
    449 % pos_4(1)=size_uvmat(3)-ColumnWidth;         % set 'Scalar' to the right of the fig
    450 % if strcmp(get(handles.Scalar,'Visible'),'on')
    451 %     pos_4(2)=pos_3(2)-ScalarPanelHeight-Interval; % set 'Scalar' to the lower edge of frame 'Coordinates' if visible
    452 % else
    453 %     pos_4(2)=pos_3(2)-Interval;% set 'Scalar' to the lower edge of frame 'text display' if  unvisible
    454 % end
    455 % pos_4(3)=ColumnWidth;
    456 % pos_4(4)=ScalarPanelHeight;
    457 % set(handles.Scalar,'Position',pos_4)
     451%% reset position of Field Indices
     452set(handles.FieldIndices,'Units','pixels')
     453pos_1(1)=Interval;         % set 'Scalar' to the right of the fig
     454pos_1(2)=pos_InputFile(2)-FieldIndicesHeight-Interval;     
     455pos_1(3)=1.2*ColumnWidth; % set 'Scalar' to the lower edge of frame 'Coordinates' if visible
     456pos_1(4)=FieldIndicesHeight;
     457set(handles.FieldIndices,'Position',pos_1)
     458
     459%% reset position of Navigation
     460set(handles.Navigation,'Units','pixels')
     461pos_2(1)=Interval;         % set 'Scalar' to the right of the fig
     462pos_2(2)=pos_1(2)-NavigateHeight-Interval;     
     463pos_2(3)=1.2*ColumnWidth; % set 'Scalar' to the lower edge of frame 'Coordinates' if visible
     464pos_2(4)=NavigateHeight;
     465set(handles.Navigation,'Position',pos_2)
     466
     467%% reset position of Transform
     468set(handles.Transform,'Units','pixels')
     469pos_3(1)=Interval;         % set 'Scalar' to the right of the fig
     470pos_3(2)=pos_2(2)-TransformHeight-Interval;     
     471pos_3(3)=1.2*ColumnWidth; % set 'Scalar' to the lower edge of frame 'Coordinates' if visible
     472pos_3(4)=TransformHeight;
     473set(handles.Transform,'Position',pos_3)
     474
     475%% reset position of Objects
     476set(handles.Objects,'Units','pixels')
     477pos_4(1)=Interval;         % set 'Scalar' to the right of the fig
     478pos_4(2)=pos_3(2)-ObjectsHeight-Interval;     
     479pos_4(3)=1.2*ColumnWidth; % set 'Scalar' to the lower edge of frame 'Coordinates' if visible
     480pos_4(4)=ObjectsHeight;
     481set(handles.Objects,'Position',pos_4)
     482
     483%% reset position of Histogram
     484set(handles.Histogram_txt,'Units','pixels')
     485set(handles.HistoMenu,'Units','pixels')
     486set(handles.LogLinHisto,'Units','pixels')
     487set(handles.HistoAxes,'Units','pixels')
     488set(handles.Histogram_txt,'FontSize',16)
     489set(handles.Histogram_txt,'Position',[Interval pos_4(2)-20-Interval 0.5*ColumnWidth-Interval 20])
     490set(handles.HistoMenu,'Position',[2*Interval+0.5*ColumnWidth pos_4(2)-20-Interval 0.35*ColumnWidth-Interval 20])
     491set(handles.LogLinHisto,'Position',[3*Interval+0.85*ColumnWidth pos_4(2)-20-Interval 0.35*ColumnWidth-Interval 20])
     492set(handles.HistoAxes,'Position',[40 pos_4(2)-220-Interval 1.2*ColumnWidth-40 180])
     493
    458494
    459495%------------------------------------------------------------------------
     
    831867else
    832868    current_dir=pwd;%current working dir
     869    export_fct_name=get(handles.MenuExportCustom,'label');
    833870    cd(fullfile(fileparts(which('uvmat')),'export_fct'))
    834871    export_handle=str2func(export_fct_name);% pick the relevant export fct in the folder UVMAT/export_fct
     
    853890
    854891% -----------------------------------------------------------------------
     892% --- called by menu bar Projection object/points
    855893function Menupoints_Callback(hObject, eventdata, handles)
    856894%------------------------------------------------------------------------
     
    861899
    862900% -----------------------------------------------------------------------
    863 % --- Callback of the Menu command line
    864 %------------------------------------------------------------------------
     901% --- % --- called by menu bar Projection object/line
    865902function Menuline_Callback(hObject, eventdata, handles)
    866903%------------------------------------------------------------------------
     
    871908
    872909% -----------------------------------------------------------------------
    873 % --- Callback of the Menu command line_x
    874 %------------------------------------------------------------------------
     910% --- called by menu bar Projection object/line_x
    875911function Menuline_x_Callback(hObject, eventdata, handles)
     912%------------------------------------------------------------------------
    876913
    877914data.Type='line_x';
     
    881918
    882919% -----------------------------------------------------------------------
    883 % --- Callback of the Menu command line_y
    884 % -----------------------------------------------------------------------
     920% --- called by menu bar Projection object/line_y
    885921function Menuline_y_Callback(hObject, eventdata, handles)
     922%------------------------------------------------------------------------
    886923
    887924data.Type='line_y';
     
    899936
    900937%------------------------------------------------------------------------
     938% --- called by menu bar Projection object/
    901939function Menupolygon_Callback(hObject, eventdata, handles)
    902940%------------------------------------------------------------------------
     
    915953
    916954%------------------------------------------------------------------------
     955% --- called by menu bar Projection object/
    917956function Menuellipse_Callback(hObject, eventdata, handles)
    918957%------------------------------------------------------------------------
     
    923962
    924963%------------------------------------------------------------------------
    925 function MenuMaskObject_Callback(hObject, eventdata, handles)
     964% --- called by menu bar Projection object/
     965function MenuMaskObject_Callback(hObject, eventdata, handles)% TO DELETE
    926966%------------------------------------------------------------------------
    927967data.Type='polygon';
     
    932972
    933973%------------------------------------------------------------------------
     974% --- called by menu bar Projection object/plane_xy: to project fields on a horizontal plane x,y
    934975function Menuplane_Callback(hObject, eventdata, handles)
    935976%------------------------------------------------------------------------
     
    939980create_object(data,handles)
    940981
    941 % --------------------------------------------------------------------
     982% -----------------------------------------------------------------------
     983% --- called by menu bar Projection object/plane_z: to project fields on a vertical plane
    942984function Menuplane_z_Callback(hObject, eventdata, handles)
     985%------------------------------------------------------------------------
    943986data.Type='plane_z';
    944987data.ProjMode='projection';%default
     
    947990
    948991%------------------------------------------------------------------------
     992% --- called by menu bar Projection object/volume (to check !!)
    949993function Menuvolume_Callback(hObject, eventdata, handles)
    950994%------------------------------------------------------------------------
     
    9891033    end
    9901034    if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh)
    991         %data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
    9921035        data.DX=UvData.Field.CoordMesh;
    9931036        data.DY=UvData.Field.CoordMesh;
     
    10671110%------------------------------------------------------------------------
    10681111function MenuBrowseObject_Callback(hObject, eventdata, handles)
     1112% --- called by menu bar Projection object/browse...
    10691113%------------------------------------------------------------------------
    10701114%get the object file
     
    10981142%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    10991143%------------------------------------------------------------------------
     1144% --- called by menu bar Tools/ruler
    11001145function MenuRuler_Callback(hObject, eventdata, handles)
    11011146%------------------------------------------------------------------------
     
    11121157
    11131158%------------------------------------------------------------------------
     1159% --- called by menu bar Tools/geometry calibration
    11141160function MenuCalib_Callback(hObject, eventdata, handles)
    11151161%------------------------------------------------------------------------
     
    11401186
    11411187
    1142 % --------------------------------------------------------------------
    1143 % --- set the slice plane ro the set of slice planes when volume scan is used
     1188% -----------------------------------------------------------------------
     1189% --- called by menu bar Tools/set slice calibrationset the slice plane ro the set of slice planes when volume scan is used
    11441190function MenuSetSlice_Callback(hObject, eventdata, handles)
    1145 % --------------------------------------------------------------------
     1191% -----------------------------------------------------------------------
    11461192%% suppress the second input field if exists
    11471193if get(handles.SubField,'Value')
     
    14801526delete(hset_slice)
    14811527
    1482 %-----------------------------------------------------------------------
     1528%------------------------------------------------------------------------
     1529% --- called by menu bar Tools/LIF calibration
    14831530function MenuLIFCalib_Callback(hObject, eventdata, handles)
    14841531%------------------------------------------------------------------------
     
    15981645end
    15991646XmlData.LIFCalib.RefLineCoord=LineData{3}.Coord;
    1600 
    1601 %% rescale the image
    1602 % [nby,nbx]=size(UvData.Field.A);
    1603 % x=linspace(UvData.Field.Coord_x(1),UvData.Field.Coord_x(2),nbx)-nbx/2;
    1604 % y=linspace(UvData.Field.Coord_y(1),UvData.Field.Coord_y(2),nby)-nby/2;
    1605 % [X,Y]=meshgrid(x,y);
    1606 %coeff_quad=0.15*4/(nbx*nbx);% image luminosity reduced by 10% at the edge
    1607 %UvData.Field.A=double(UvData.Field.A).*(1+coeff_quad*(X.*X+Y.*Y));
    16081647
    16091648%% display the current image in polar axes with origin at the  illumination source
     
    16561695AX=DataPol.radius;
    16571696AY=DataPol.theta;
    1658 % dX=(AX(2)-AX(1))/(npx-1);
    1659 % dY=(AY(1)-AY(2))/(npy-1);%mesh of new pixels
    16601697[R,Theta]=meshgrid(linspace(AX(1),AX(end),npx),linspace(AY(1),AY(end),npy));%matrix of radius and angles with the same size as DataPol
    16611698A=R.*Anorm;
     
    16781715gamma_coeff=NaN(1,npy);
    16791716fitlength=NaN(1,npy);
    1680 %[ThetaMask,RMask] = cart2pol(MaskData.Coord(:,1)-x0,MaskData.Coord(:,2)-y0);
    1681 %ThetaMask=ThetaMask*180/pi
    16821717for iY=1:npy% loop on the y index of the image in polar coordinate
    16831718    ALine=A(iY,:);%profile of image luminosity log (vs radial index)
     
    17901825end
    17911826
    1792 
    1793 
    1794 %------------------------------------------------------------------------
    1795     function MenuMask_Callback(hObject, eventdata, handles)
    1796         %------------------------------------------------------------------------
    1797         UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    1798         ListObj=UvData.ProjObject;
    1799         select=zeros(1,numel(ListObj));
    1800         for iobj=1:numel(ListObj);
    1801             if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
    1802                 select(iobj)=1;
    1803             end
    1804         end
    1805         val=find(select);
    1806         if isempty(val)
    1807             msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
     1827%------------------------------------------------------------------------
     1828% --- called by menu bar Tools/make mask: produces a mask image from existing projection objects with ProjMode='mask inside' or 'mask_outside
     1829function MenuMask_Callback(hObject, eventdata, handles)
     1830%------------------------------------------------------------------------
     1831UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
     1832
     1833%% selects the appropriate projection objects
     1834select=false(1,numel(UvData.ProjObject));% selection flag on the list of projection objects, false by default
     1835for iobj=1:numel(UvData.ProjObject)
     1836    if ismember(UvData.ProjObject{iobj}.ProjMode,{'mask_inside','mask_outside','inside'}) &&...
     1837            isfield(UvData.ProjObject{iobj},'Coord') && isfield(UvData.ProjObject{iobj},'Type')% avoid empty or other wrong objects in the list
     1838        select(iobj)=true;% select only the objects with appropriate projection mode
     1839    end
     1840end
     1841val=find(select);% indices of the selected objects
     1842if isempty(val)
     1843    msgbox_uvmat('ERROR','projection objects with ProjMode=mask_inside or mask_outside must be first created');
     1844    return
     1845else
     1846    ProjObject=UvData.ProjObject(val);%list of appropriate objects to use
     1847end
     1848set(handles.ListObject,'Value',val);% indicate the used object in the list
     1849
     1850%% initialise the flag image for mask
     1851if ~isfield(UvData.Field,'A')
     1852    msgbox_uvmat('ERROR','an image needs to be opened to set the mask size');
     1853    return
     1854end
     1855npx=size(UvData.Field.A,2);
     1856npy=size(UvData.Field.A,1);
     1857xi=0.5:npx-0.5;
     1858yi=0.5:npy-0.5;
     1859[Xi,Yi]=meshgrid(xi,yi);
     1860flag=true(npy,npx);
     1861
     1862%% scan the list of the selected projection objects
     1863for iobj=1:numel(ProjObject)
     1864    flagobj=true(npy,npx);
     1865    testphys=false; %coordinates in pixels by default
     1866    if isfield(ProjObject{iobj},'CoordUnit') && ~isequal(ProjObject{iobj}.CoordUnit,'pixel')
     1867        if isfield(UvData,'XmlData')
     1868            if isfield(UvData.XmlData{1},'GeometryCalib')
     1869                Calib=UvData.XmlData{1}.GeometryCalib;
     1870                testphys=true; %flag to transform object coordinates into pixels
     1871                Slice=[];% check for slices in 3D
     1872                if isfield(UvData.XmlData{1},'Slice')
     1873                    Slice=UvData.XmlData{1}.Slice;
     1874                end
     1875            end
     1876        end
     1877    end
     1878    X=ProjObject{iobj}.Coord(:,1);
     1879    Y=ProjObject{iobj}.Coord(:,2);
     1880    if testphys% transform the object into polygon, then to pixel coordinates       
     1881        if strcmp(ProjObject{iobj}.Type,'ellipse')% transform into polygon
     1882            perimeter=2*pi*ProjObject{iobj}.RangeX*ProjObject{iobj}.RangeY;
     1883            NbPoint=ceil(perimeter/UvData.Field.CoordMesh);% estimate the number of interpolation points according to estimated field mesh
     1884            Theta=2*pi*(1:NbPoint)/NbPoint; %set of  NbPoint angles       
     1885            X=X+ProjObject{iobj}.RangeX*cos(Theta);% correspondfing x positions
     1886            Y=Y+ProjObject{iobj}.RangeY*sin(Theta);% correspondfing y positions
     1887        elseif strcmp(ProjObject{iobj}.Type,'rectangle')%
     1888            RangeX=ProjObject{iobj}.RangeX;% half side of the rectangle
     1889            RangeY=ProjObject{iobj}.RangeY;% y axis of the ellipse
     1890            Xflag=[X-RangeX X+RangeX X+RangeX X-RangeX];% coordinates of the corners
     1891            Yflag=[Y-RangeY Y-RangeY Y+RangeY Y+RangeY];
     1892        else %polygon
     1893            Xflag=X';Yflag=Y';
     1894            Xflag=[Xflag X(1)];Yflag=[Yflag Y(1)];% close the polygon before interpolation
     1895        end
     1896        if ~strcmp(ProjObject{iobj}.Type,'ellipse')% interpolate between flag points
     1897            X=[]; Y=[];
     1898            for iflag=1:numel(Xflag)-1
     1899                SegmentLength=sqrt((Xflag(iflag+1)-Xflag(iflag))^2+(Yflag(iflag+1)-Yflag(iflag))^2);
     1900                NbPoint=ceil(SegmentLength/UvData.Field.CoordMesh);
     1901                X=[X Xflag(iflag)+((0:NbPoint-1)/NbPoint)*(Xflag(iflag+1)-Xflag(iflag))];% interpolate between 'flag points'
     1902                Y=[Y Yflag(iflag)+((0:NbPoint-1)/NbPoint)*(Yflag(iflag+1)-Yflag(iflag))];
     1903            end
     1904        end
     1905        ProjObject{iobj}.Type='polygon';
     1906        pos=[X' Y' zeros(numel(X),1)];% create the matrix for transform to pixel coordinates
     1907        % introduce the plane of cut in 3D case
     1908        if isfield(Slice,'SliceCoord') && length(Slice.SliceCoord)>=3
     1909            if isfield(Slice,'SliceAngle')&&~isequal(Slice.SliceAngle,[0 0 0])
     1910                om=norm(Slice.SliceAngle);%norm of rotation angle in radians
     1911                OmAxis=Slice.SliceAngle/om; %unit vector marking the rotation axis
     1912                cos_om=cos(pi*om/180);
     1913                sin_om=sin(pi*om/180);
     1914                pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
     1915            end
     1916            pos(:,1)=pos(:,1)+Slice.SliceCoord(1);
     1917            pos(:,2)=pos(:,2)+Slice.SliceCoord(2);
     1918            pos(:,3)=pos(:,3)+Slice.SliceCoord(3);
     1919        end
     1920        [X,Y]=px_XYZ(Calib,Slice,pos(:,1),pos(:,2),pos(:,3));% transform to pixel coordinates
     1921    end
     1922    if strcmp(ProjObject{iobj}.Type,'polygon')
     1923        flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
     1924    elseif isequal(ProjObject{iobj}.Type,'ellipse')
     1925        RangeX=max(ProjObject{iobj}.RangeX);
     1926        RangeY=max(ProjObject{iobj}.RangeY);
     1927        X2Max=RangeX*RangeX;
     1928        Y2Max=RangeY*RangeY;
     1929        distX=(Xi-ProjObject{iobj}.Coord(1,1));
     1930        distY=(Yi-ProjObject{iobj}.Coord(1,2));
     1931        flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
     1932    elseif isequal(ProjObject{iobj}.Type,'rectangle')
     1933        distX=abs(Xi-ProjObject{iobj}.Coord(1,1));
     1934        distY=abs(Yi-ProjObject{iobj}.Coord(1,2));
     1935        flagobj=distX>max(ProjObject{iobj}.RangeX) | distY>max(ProjObject{iobj}.RangeY);
     1936    end
     1937    if isequal(ProjObject{iobj}.ProjMode,'mask_outside')
     1938        flagobj=~flagobj;
     1939    end
     1940    flag=flag & flagobj;% concatene the mask flag
     1941end
     1942imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (PIV vectors not computed when imflag<200)
     1943imflag=flip(imflag,1);
     1944
     1945%% display the mask image for checking
     1946hfigmask=figure;
     1947set(hfigmask,'Name','mask image')
     1948vec=linspace(0,1,256);%define a linear greyscale colormap
     1949map=[vec' vec' vec'];
     1950colormap(map)
     1951image(imflag);
     1952
     1953%% propose a mask name
     1954RootPath=get(handles.RootPath,'String');
     1955SubDir=get(handles.SubDir,'String');
     1956maskindex=get(handles.masklevel,'Value');
     1957mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex);
     1958answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
     1959
     1960%% save the mask as requested
     1961if ~strcmp(answer,'Cancel')
     1962    mask_dir=fileparts(answer);
     1963    if ~exist(mask_dir,'dir')
     1964        [success,msg]=mkdir(mask_dir);
     1965        if success==0
     1966            msgbox_uvmat('ERROR',['cannot create ' mask_dir ': ' msg]);%error message for directory creation
    18081967            return
    1809         else
    1810             set(handles.ListObject,'Value',val);
    1811             flag=1;
    1812             if ~isfield(UvData.Field,'A')
    1813                 msgbox_uvmat('ERROR','an image needs to be opened to set the mask size');
    1814                 return
    1815             end
    1816             npx=size(UvData.Field.A,2);
    1817             npy=size(UvData.Field.A,1);
    1818             xi=0.5:npx-0.5;
    1819             yi=0.5:npy-0.5;
    1820             [Xi,Yi]=meshgrid(xi,yi);
    1821             for iobj=1:length(UvData.ProjObject)
    1822                 ObjectData=UvData.ProjObject{iobj};
    1823                 if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
    1824                     flagobj=1;
    1825                     testphys=0; %coordinates in pixels by default
    1826                     if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
    1827                         if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib')
    1828                             Calib=UvData.XmlData{1}.GeometryCalib;
    1829                             testphys=1;
    1830                         end
    1831                     end
    1832                     if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type')
    1833                         if isequal(ObjectData.Type,'polygon')
    1834                             X=ObjectData.Coord(:,1);
    1835                             Y=ObjectData.Coord(:,2);
    1836                             if testphys
    1837                                 pos=[X Y zeros(size(X))];
    1838                                 if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3
    1839                                     if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0])
    1840                                         om=norm(Calib.SliceAngle);%norm of rotation angle in radians
    1841                                         OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis
    1842                                         cos_om=cos(pi*om/180);
    1843                                         sin_om=sin(pi*om/180);
    1844                                         pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
    1845                                     end
    1846                                     pos(:,1)=pos(:,1)+Calib.SliceCoord(1);
    1847                                     pos(:,2)=pos(:,2)+Calib.SliceCoord(2);
    1848                                     pos(:,3)=pos(:,3)+Calib.SliceCoord(3);
    1849                                 end
    1850                                 [X,Y]=px_XYZ(Calib,Slice,pos(:,1),pos(:,2),pos(:,3));
    1851                             end
    1852                             flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
    1853                         elseif isequal(ObjectData.Type,'ellipse')
    1854                             if testphys
    1855                                 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
    1856                             end
    1857                             RangeX=max(ObjectData.RangeX);
    1858                             RangeY=max(ObjectData.RangeY);
    1859                             X2Max=RangeX*RangeX;
    1860                             Y2Max=RangeY*RangeY;
    1861                             distX=(Xi-ObjectData.Coord(1,1));
    1862                             distY=(Yi-ObjectData.Coord(1,2));
    1863                             flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
    1864                         elseif isequal(ObjectData.Type,'rectangle')
    1865                             if testphys
    1866                                 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
    1867                             end
    1868                             distX=abs(Xi-ObjectData.Coord(1,1));
    1869                             distY=abs(Yi-ObjectData.Coord(1,2));
    1870                             flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
    1871                         end
    1872                         if isequal(ObjectData.ProjMode,'mask_outside')
    1873                             flagobj=~flagobj;
    1874                         end
    1875                         flag=flag & flagobj;
    1876                     end
    1877                 end
    1878             end
    1879             %mask name
    1880             RootPath=get(handles.RootPath,'String');
    1881             SubDir=get(handles.SubDir,'String');
    1882             RootFile=get(handles.RootFile,'String');
    1883             if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
    1884                 RootFile(1)=[];
    1885             end
    1886             list=get(handles.masklevel,'String');
    1887             masknumber=num2str(length(list));
    1888             maskindex=get(handles.masklevel,'Value');
    1889             mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex);
    1890             imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
    1891             imflag=flipdim(imflag,1);
    1892            
    1893             %display the mask
    1894             hfigmask=figure;
    1895             set(hfigmask,'Name','mask image')
    1896             vec=linspace(0,1,256);%define a linear greyscale colormap
    1897             map=[vec' vec' vec'];
    1898             colormap(map)
    1899             image(imflag);
    1900             answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
    1901             if ~strcmp(answer,'Cancel')
    1902                 mask_dir=fileparts(answer);
    1903                 if ~exist(mask_dir,'dir')
    1904                     [success,msg]=mkdir(mask_dir);
    1905                     if success==0
    1906                         msgbox_uvmat('ERROR',['cannot create ' mask_dir ': ' msg]);%error message for directory creation
    1907                         return
    1908                     end
    1909                     [success,msg] = fileattrib(mask_dir,'+w','g','s');% allow writing access for the group of users, recursively in the folder
    1910                     if success==0
    1911                         msgbox_uvmat('WARNING',{['unable to set group write access to ' mask_dir ':']; msg});%error message for directory creation
    1912                     end
    1913                 end
    1914                 try
    1915                     imwrite(imflag,answer,'BitDepth',8);
    1916                 catch ME
    1917                     msgbox_uvmat('ERROR',ME.message)
    1918                 end
    1919             end
    1920             set(handles.ListObject,'Value',1)
    1921         end
    1922 
    1923 %------------------------------------------------------------------------
    1924 %-- open the GUI set_grid.fig to create grid
     1968        end
     1969        [success,msg] = fileattrib(mask_dir,'+w','g','s');% allow writing access for the group of users, recursively in the folder
     1970        if success==0
     1971            msgbox_uvmat('WARNING',{['unable to set group write access to ' mask_dir ':']; msg});%error message for directory creation
     1972        end
     1973    end
     1974    try
     1975        imwrite(imflag,answer,'BitDepth',8);
     1976    catch ME
     1977        msgbox_uvmat('ERROR',ME.message)
     1978    end
     1979end
     1980set(handles.ListObject,'Value',1)
     1981
     1982%------------------------------------------------------------------------
     1983%-- open the GUI set_grid.fig to create grid (TODO: check the relevance)
    19251984function MenuGrid_Callback(hObject, eventdata, handles)
    19261985%------------------------------------------------------------------------
     
    19341993FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    19351994UvData=get(handles.uvmat,'UserData');
    1936 % CoordList=get(handles.TransformName,'String');
    1937 % val=get(handles.TransformName,'Value');
    19381995set_grid(FileName,UvData.Field);% call the set_object interface
    19391996
    19401997%------------------------------------------------------------------------
    1941 %-- introduce a section FileSeries in the xml file ImaDoc to virtually relabel frames
    1942 % --------------------------------------------------------------------
     1998%--- called by menu bar Tools/relabel series: introduce a section FileSeries in the xml file ImaDoc to virtually relabel frames
    19431999function MenuRelabelFrames_Callback(hObject, eventdata, handles)
    1944 
     2000%------------------------------------------------------------------------
    19452001[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    19462002FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
     
    19812037    case 'rdvision'%TO CHECK******
    19822038        check_time_rdvision(FileName,XmlData)
    1983     case 'telopsIR'
    1984        
     2039    case 'telopsIR'     
    19852040        DirContent=dir(fullfile(RootPath,SubDir));
    19862041        NbFiles=0;
     
    42494304        end
    42504305    end
    4251    
     4306
    42524307    set(handles.uvmat,'UserData',UvData)
    42534308   
     
    43744429    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    43754430    % display menus and plot histograms
    4376     test_v=0;
     4431    %test_v=0;
    43774432    if ~isempty(menu_histo)
    43784433        set(handles.HistoMenu,'Value',1)
    43794434        set(handles.HistoMenu,'String',menu_histo)
    4380         set(handles.Histogram,'Visible','on')
     4435        set(handles.Histogram_txt,'Visible','on')
    43814436        set(handles.HistoMenu,'Visible','on')
    43824437        set(handles.LogLinHisto,'Visible','on')
     
    62906345function LogLinHisto_Callback(hObject, eventdata, handles)
    62916346HistoMenu_Callback(hObject, eventdata, handles)
     6347
     6348
     6349% --------------------------------------------------------------------
     6350function MenuCreateMirror_Callback(hObject, eventdata, handles)
     6351% hObject    handle to MenuCreateMirror (see GCBO)
     6352% eventdata  reserved - to be defined in a future version of MATLAB
     6353% handles    structure with handles and user data (see GUIDATA)
Note: See TracChangeset for help on using the changeset viewer.