Changeset 1201 for trunk/src/uvmat.m
- Timestamp:
- Mar 23, 2026, 4:49:29 PM (3 hours ago)
- File:
-
- 1 edited
-
trunk/src/uvmat.m (modified) (31 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r1200 r1201 1 %'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization1 %'uvmat': function associated with the master GUI 'uvmat.fig' for the visualisation of images and data fields 2 2 %------------------------------------------------------------------------ 3 3 % function huvmat=uvmat(input) … … 220 220 221 221 %% EXPORT menu 222 export_menu={' as field in workspace';'in new figure';'on existing axis';'make movie';'more...'};222 export_menu={'field in workspace';'field in new figure';'field on existing axis';'make movie';'create mirror data tree';'more...'}; 223 223 224 224 %% load the list of previously browsed files in menus Open, Open_1 and TransformName … … 363 363 CoordinatesPanelHeight=100; 364 364 ScalarPanelHeight=150; 365 FieldIndicesHeight=220; 366 NavigateHeight=120; 367 TransformHeight=100; 368 ObjectsHeight=150; 365 369 Interval=2; 366 370 … … 433 437 434 438 %% 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;439 pos(1)=1.2*ColumnWidth+50;%axis x position 440 pos(2)=50;%axis y position 441 pos(3)=size_uvmat(3)-2.2*ColumnWidth-100;%axis width 438 442 pos(4)=pos_InputFile(2)-50-Interval; 439 443 set(handles.PlotAxes,'Units','pixels') … … 441 445 %set(handles.PlotAxes,'Units','normalized') 442 446 UvData=get(handles.uvmat,'UserData'); 443 UvData.PosColorbar([1 3])=[pos(1)+pos(3)+10 1 0]/size_uvmat(3);447 UvData.PosColorbar([1 3])=[pos(1)+pos(3)+10 15]/size_uvmat(3);%x position and width of the colorbar 444 448 UvData.PosColorbar([2 4])=[pos(2)+pos(3)/4 pos(3)/2]/size_uvmat(4); 445 449 set(handles.uvmat,'UserData',UvData) 446 450 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 452 set(handles.FieldIndices,'Units','pixels') 453 pos_1(1)=Interval; % set 'Scalar' to the right of the fig 454 pos_1(2)=pos_InputFile(2)-FieldIndicesHeight-Interval; 455 pos_1(3)=1.2*ColumnWidth; % set 'Scalar' to the lower edge of frame 'Coordinates' if visible 456 pos_1(4)=FieldIndicesHeight; 457 set(handles.FieldIndices,'Position',pos_1) 458 459 %% reset position of Navigation 460 set(handles.Navigation,'Units','pixels') 461 pos_2(1)=Interval; % set 'Scalar' to the right of the fig 462 pos_2(2)=pos_1(2)-NavigateHeight-Interval; 463 pos_2(3)=1.2*ColumnWidth; % set 'Scalar' to the lower edge of frame 'Coordinates' if visible 464 pos_2(4)=NavigateHeight; 465 set(handles.Navigation,'Position',pos_2) 466 467 %% reset position of Transform 468 set(handles.Transform,'Units','pixels') 469 pos_3(1)=Interval; % set 'Scalar' to the right of the fig 470 pos_3(2)=pos_2(2)-TransformHeight-Interval; 471 pos_3(3)=1.2*ColumnWidth; % set 'Scalar' to the lower edge of frame 'Coordinates' if visible 472 pos_3(4)=TransformHeight; 473 set(handles.Transform,'Position',pos_3) 474 475 %% reset position of Objects 476 set(handles.Objects,'Units','pixels') 477 pos_4(1)=Interval; % set 'Scalar' to the right of the fig 478 pos_4(2)=pos_3(2)-ObjectsHeight-Interval; 479 pos_4(3)=1.2*ColumnWidth; % set 'Scalar' to the lower edge of frame 'Coordinates' if visible 480 pos_4(4)=ObjectsHeight; 481 set(handles.Objects,'Position',pos_4) 482 483 %% reset position of Histogram 484 set(handles.Histogram_txt,'Units','pixels') 485 set(handles.HistoMenu,'Units','pixels') 486 set(handles.LogLinHisto,'Units','pixels') 487 set(handles.HistoAxes,'Units','pixels') 488 set(handles.Histogram_txt,'FontSize',16) 489 set(handles.Histogram_txt,'Position',[Interval pos_4(2)-20-Interval 0.5*ColumnWidth-Interval 20]) 490 set(handles.HistoMenu,'Position',[2*Interval+0.5*ColumnWidth pos_4(2)-20-Interval 0.35*ColumnWidth-Interval 20]) 491 set(handles.LogLinHisto,'Position',[3*Interval+0.85*ColumnWidth pos_4(2)-20-Interval 0.35*ColumnWidth-Interval 20]) 492 set(handles.HistoAxes,'Position',[40 pos_4(2)-220-Interval 1.2*ColumnWidth-40 180]) 493 458 494 459 495 %------------------------------------------------------------------------ … … 831 867 else 832 868 current_dir=pwd;%current working dir 869 export_fct_name=get(handles.MenuExportCustom,'label'); 833 870 cd(fullfile(fileparts(which('uvmat')),'export_fct')) 834 871 export_handle=str2func(export_fct_name);% pick the relevant export fct in the folder UVMAT/export_fct … … 853 890 854 891 % ----------------------------------------------------------------------- 892 % --- called by menu bar Projection object/points 855 893 function Menupoints_Callback(hObject, eventdata, handles) 856 894 %------------------------------------------------------------------------ … … 861 899 862 900 % ----------------------------------------------------------------------- 863 % --- Callback of the Menu command line 864 %------------------------------------------------------------------------ 901 % --- % --- called by menu bar Projection object/line 865 902 function Menuline_Callback(hObject, eventdata, handles) 866 903 %------------------------------------------------------------------------ … … 871 908 872 909 % ----------------------------------------------------------------------- 873 % --- Callback of the Menu command line_x 874 %------------------------------------------------------------------------ 910 % --- called by menu bar Projection object/line_x 875 911 function Menuline_x_Callback(hObject, eventdata, handles) 912 %------------------------------------------------------------------------ 876 913 877 914 data.Type='line_x'; … … 881 918 882 919 % ----------------------------------------------------------------------- 883 % --- Callback of the Menu command line_y 884 % ----------------------------------------------------------------------- 920 % --- called by menu bar Projection object/line_y 885 921 function Menuline_y_Callback(hObject, eventdata, handles) 922 %------------------------------------------------------------------------ 886 923 887 924 data.Type='line_y'; … … 899 936 900 937 %------------------------------------------------------------------------ 938 % --- called by menu bar Projection object/ 901 939 function Menupolygon_Callback(hObject, eventdata, handles) 902 940 %------------------------------------------------------------------------ … … 915 953 916 954 %------------------------------------------------------------------------ 955 % --- called by menu bar Projection object/ 917 956 function Menuellipse_Callback(hObject, eventdata, handles) 918 957 %------------------------------------------------------------------------ … … 923 962 924 963 %------------------------------------------------------------------------ 925 function MenuMaskObject_Callback(hObject, eventdata, handles) 964 % --- called by menu bar Projection object/ 965 function MenuMaskObject_Callback(hObject, eventdata, handles)% TO DELETE 926 966 %------------------------------------------------------------------------ 927 967 data.Type='polygon'; … … 932 972 933 973 %------------------------------------------------------------------------ 974 % --- called by menu bar Projection object/plane_xy: to project fields on a horizontal plane x,y 934 975 function Menuplane_Callback(hObject, eventdata, handles) 935 976 %------------------------------------------------------------------------ … … 939 980 create_object(data,handles) 940 981 941 % -------------------------------------------------------------------- 982 % ----------------------------------------------------------------------- 983 % --- called by menu bar Projection object/plane_z: to project fields on a vertical plane 942 984 function Menuplane_z_Callback(hObject, eventdata, handles) 985 %------------------------------------------------------------------------ 943 986 data.Type='plane_z'; 944 987 data.ProjMode='projection';%default … … 947 990 948 991 %------------------------------------------------------------------------ 992 % --- called by menu bar Projection object/volume (to check !!) 949 993 function Menuvolume_Callback(hObject, eventdata, handles) 950 994 %------------------------------------------------------------------------ … … 989 1033 end 990 1034 if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh) 991 %data.RangeX=[UvData.Field.XMin UvData.Field.XMax];992 1035 data.DX=UvData.Field.CoordMesh; 993 1036 data.DY=UvData.Field.CoordMesh; … … 1067 1110 %------------------------------------------------------------------------ 1068 1111 function MenuBrowseObject_Callback(hObject, eventdata, handles) 1112 % --- called by menu bar Projection object/browse... 1069 1113 %------------------------------------------------------------------------ 1070 1114 %get the object file … … 1098 1142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1099 1143 %------------------------------------------------------------------------ 1144 % --- called by menu bar Tools/ruler 1100 1145 function MenuRuler_Callback(hObject, eventdata, handles) 1101 1146 %------------------------------------------------------------------------ … … 1112 1157 1113 1158 %------------------------------------------------------------------------ 1159 % --- called by menu bar Tools/geometry calibration 1114 1160 function MenuCalib_Callback(hObject, eventdata, handles) 1115 1161 %------------------------------------------------------------------------ … … 1140 1186 1141 1187 1142 % -------------------------------------------------------------------- 1143 % --- set the slice plane ro the set of slice planes when volume scan is used1188 % ----------------------------------------------------------------------- 1189 % --- called by menu bar Tools/set slice calibrationset the slice plane ro the set of slice planes when volume scan is used 1144 1190 function MenuSetSlice_Callback(hObject, eventdata, handles) 1145 % -------------------------------------------------------------------- 1191 % ----------------------------------------------------------------------- 1146 1192 %% suppress the second input field if exists 1147 1193 if get(handles.SubField,'Value') … … 1480 1526 delete(hset_slice) 1481 1527 1482 %----------------------------------------------------------------------- 1528 %------------------------------------------------------------------------ 1529 % --- called by menu bar Tools/LIF calibration 1483 1530 function MenuLIFCalib_Callback(hObject, eventdata, handles) 1484 1531 %------------------------------------------------------------------------ … … 1598 1645 end 1599 1646 XmlData.LIFCalib.RefLineCoord=LineData{3}.Coord; 1600 1601 %% rescale the image1602 % [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 edge1607 %UvData.Field.A=double(UvData.Field.A).*(1+coeff_quad*(X.*X+Y.*Y));1608 1647 1609 1648 %% display the current image in polar axes with origin at the illumination source … … 1656 1695 AX=DataPol.radius; 1657 1696 AY=DataPol.theta; 1658 % dX=(AX(2)-AX(1))/(npx-1);1659 % dY=(AY(1)-AY(2))/(npy-1);%mesh of new pixels1660 1697 [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 1661 1698 A=R.*Anorm; … … 1678 1715 gamma_coeff=NaN(1,npy); 1679 1716 fitlength=NaN(1,npy); 1680 %[ThetaMask,RMask] = cart2pol(MaskData.Coord(:,1)-x0,MaskData.Coord(:,2)-y0);1681 %ThetaMask=ThetaMask*180/pi1682 1717 for iY=1:npy% loop on the y index of the image in polar coordinate 1683 1718 ALine=A(iY,:);%profile of image luminosity log (vs radial index) … … 1790 1825 end 1791 1826 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 1829 function MenuMask_Callback(hObject, eventdata, handles) 1830 %------------------------------------------------------------------------ 1831 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 1832 1833 %% selects the appropriate projection objects 1834 select=false(1,numel(UvData.ProjObject));% selection flag on the list of projection objects, false by default 1835 for 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 1840 end 1841 val=find(select);% indices of the selected objects 1842 if isempty(val) 1843 msgbox_uvmat('ERROR','projection objects with ProjMode=mask_inside or mask_outside must be first created'); 1844 return 1845 else 1846 ProjObject=UvData.ProjObject(val);%list of appropriate objects to use 1847 end 1848 set(handles.ListObject,'Value',val);% indicate the used object in the list 1849 1850 %% initialise the flag image for mask 1851 if ~isfield(UvData.Field,'A') 1852 msgbox_uvmat('ERROR','an image needs to be opened to set the mask size'); 1853 return 1854 end 1855 npx=size(UvData.Field.A,2); 1856 npy=size(UvData.Field.A,1); 1857 xi=0.5:npx-0.5; 1858 yi=0.5:npy-0.5; 1859 [Xi,Yi]=meshgrid(xi,yi); 1860 flag=true(npy,npx); 1861 1862 %% scan the list of the selected projection objects 1863 for 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 1941 end 1942 imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (PIV vectors not computed when imflag<200) 1943 imflag=flip(imflag,1); 1944 1945 %% display the mask image for checking 1946 hfigmask=figure; 1947 set(hfigmask,'Name','mask image') 1948 vec=linspace(0,1,256);%define a linear greyscale colormap 1949 map=[vec' vec' vec']; 1950 colormap(map) 1951 image(imflag); 1952 1953 %% propose a mask name 1954 RootPath=get(handles.RootPath,'String'); 1955 SubDir=get(handles.SubDir,'String'); 1956 maskindex=get(handles.masklevel,'Value'); 1957 mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex); 1958 answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); 1959 1960 %% save the mask as requested 1961 if ~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 1808 1967 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 1979 end 1980 set(handles.ListObject,'Value',1) 1981 1982 %------------------------------------------------------------------------ 1983 %-- open the GUI set_grid.fig to create grid (TODO: check the relevance) 1925 1984 function MenuGrid_Callback(hObject, eventdata, handles) 1926 1985 %------------------------------------------------------------------------ … … 1934 1993 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; 1935 1994 UvData=get(handles.uvmat,'UserData'); 1936 % CoordList=get(handles.TransformName,'String');1937 % val=get(handles.TransformName,'Value');1938 1995 set_grid(FileName,UvData.Field);% call the set_object interface 1939 1996 1940 1997 %------------------------------------------------------------------------ 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 1943 1999 function MenuRelabelFrames_Callback(hObject, eventdata, handles) 1944 2000 %------------------------------------------------------------------------ 1945 2001 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 1946 2002 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; … … 1981 2037 case 'rdvision'%TO CHECK****** 1982 2038 check_time_rdvision(FileName,XmlData) 1983 case 'telopsIR' 1984 2039 case 'telopsIR' 1985 2040 DirContent=dir(fullfile(RootPath,SubDir)); 1986 2041 NbFiles=0; … … 4249 4304 end 4250 4305 end 4251 4306 4252 4307 set(handles.uvmat,'UserData',UvData) 4253 4308 … … 4374 4429 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4375 4430 % display menus and plot histograms 4376 test_v=0;4431 %test_v=0; 4377 4432 if ~isempty(menu_histo) 4378 4433 set(handles.HistoMenu,'Value',1) 4379 4434 set(handles.HistoMenu,'String',menu_histo) 4380 set(handles.Histogram ,'Visible','on')4435 set(handles.Histogram_txt,'Visible','on') 4381 4436 set(handles.HistoMenu,'Visible','on') 4382 4437 set(handles.LogLinHisto,'Visible','on') … … 6290 6345 function LogLinHisto_Callback(hObject, eventdata, handles) 6291 6346 HistoMenu_Callback(hObject, eventdata, handles) 6347 6348 6349 % -------------------------------------------------------------------- 6350 function 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.
