Changeset 1103
- Timestamp:
- May 8, 2021, 11:01:15 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plot_field.m
r1098 r1103 865 865 866 866 %set for grey scale setting 867 ColorMap='default'; 867 868 if isfield(PlotParam.Scalar,'CheckBW') && ~isempty(PlotParam.Scalar.CheckBW) 868 BW=PlotParam.Scalar.CheckBW; %BW=0 color imposed, else gray scale imposed. 869 else % BW imposed automatically chosen 870 BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default 871 PlotParamOut.Scalar.CheckBW=BW; 872 end 873 869 ColorMap=PlotParam.Scalar.CheckBW; %BW=0 color imposed, else gray scale imposed. 870 elseif ((siz==2) && (isa(A,'uint8')|| isa(A,'uint16')))% non color images represented in gray scale by default 871 ColorMap='grayscale'; 872 end 873 PlotParamOut.Scalar.CheckBW=ColorMap; 874 874 % determine the plot option 'image' or 'contours' 875 875 CheckContour=0; %default … … 915 915 PlotParamOut.Scalar.Npx=size(A,2); 916 916 PlotParamOut.Scalar.Npy=size(A,1); 917 % if siz==2917 918 918 % case of contour plot 919 919 if CheckContour … … 946 946 y_cont=Coord_y(1):-sizpy:Coord_y(end); % pixel x coordinates for image display 947 947 948 %axes(haxes)% set the input axes handle as current axis949 950 % colormap(map);951 948 tag_axes=get(haxes,'Tag');% axes tag 952 949 Opacity=1; … … 972 969 %determine the color scale and map 973 970 caxis([abscontmin abscontmax]) 974 if BW971 if strcmp(ColorMap,'grayscale') 975 972 vec=linspace(0,1,(abscontmax-abscontmin)/interval);%define a greyscale colormap with steps interval 976 973 map=[vec' vec' vec']; 977 974 colormap(map); 978 else 979 colormap('jet'); % default matlab colormap ('jet') 975 elseif strcmp(ColorMap,'BuYlRd') 976 hh=load('BuYlRd.mat'); 977 colormap(hh.BuYlRd); 978 else 979 colormap(ColorMap); 980 980 end 981 981 else %usual images (no contour) 982 982 % set colormap for image display 983 if BW983 if strcmp(ColorMap,'grayscale') 984 984 vec=linspace(0,1,255);%define a linear greyscale colormap 985 985 map=[vec' vec' vec']; … … 988 988 A=uint16(sum(A,3));%sum the three color components for color images displayed with BW option 989 989 end 990 elseif strcmp(ColorMap,'BuYlRd') 991 hh=load('BuYlRd.mat'); 992 colormap(hh.BuYlRd); 990 993 else 991 994 if siz==3 && CheckFixScalar % true color images rescaled by MaxA 992 995 A=uint8(255*double(A)/double(MaxA)); 993 996 end 994 colormap( 'default'); % standard false colors for div, vort , scalar fields997 colormap(ColorMap); % standard false colors for div, vort , scalar fields 995 998 end 996 999 … … 1123 1126 if test_vec 1124 1127 %vector scale representation 1125 if size(vec_U,1)==numel(vec_Y) && size(vec_U,2)==numel(vec_X) ;% x, y coordinate variables1128 if size(vec_U,1)==numel(vec_Y) && size(vec_U,2)==numel(vec_X) % x, y coordinate variables 1126 1129 [vec_X,vec_Y]=meshgrid(vec_X,vec_Y); 1127 1130 end … … 1201 1204 1202 1205 % take flags into account: add flag colors to the list of colors 1203 sizlist=size(colorlist); 1204 nbcolor=sizlist(1); 1206 nbcolor=size(colorlist,1); 1205 1207 if test_black 1206 1208 nbcolor=nbcolor+1; … … 1223 1225 %plot vectors: 1224 1226 quiresetn(haxes,vec_X,vec_Y,vec_U,vec_V,scale,colorlist,col_vec); 1225 1226 1227 else 1227 1228 hvec=findobj(haxes,'Tag','vel'); … … 1231 1232 PlotParamOut=rmfield(PlotParamOut,'Vectors'); 1232 1233 end 1233 % nbvar=0;1234 1234 1235 1235 %store the coordinate extrema occupied by the field … … 1297 1297 alpha=0.3 ;%length arrow 1298 1298 rot=alpha*[cos(theta) -sin(theta); sin(theta) cos(theta)]'; 1299 1299 1300 %find the existing lines 1300 1301 h=findobj(haxes,'Tag','vel');% search existing lines in the current axes 1301 1302 sizh=size(h); 1302 %set(h,'EraseMode','xor');1303 1303 set(haxes,'NextPlot','replacechildren'); 1304 1304 1305 %drawnow1306 1305 %create lines (if no lines) or modify them 1307 1306 if ~isequal(size(col_vec),size(x)) 1308 1307 col_vec=ones(size(x));% case of error in col_vec input 1309 1308 end 1310 sizlist=size(colorlist); 1311 ncolor=sizlist(1); 1312 1313 for icolor=1:ncolor 1309 nbcolor=size(colorlist,1); 1310 1311 for icolor=1:nbcolor 1314 1312 %determine the line positions for each color icolor 1315 1313 ind=find(col_vec==icolor); … … 1363 1361 end 1364 1362 end 1365 if sizh(1) > 2*n color1366 for icolor=n color+1 : sizh(1)/2%delete additional objects1363 if sizh(1) > 2*nbcolor 1364 for icolor=nbcolor+1 : sizh(1)/2 %delete additional objects 1367 1365 delete(h(2*icolor-1)) 1368 1366 delete(h(2*icolor)) -
trunk/src/set_col_vec.m
r1093 r1103 1 1 %'set_col_vec': % sets the color code for vectors depending on a scalar and input parameters (used for plot_field) 2 2 %----------------------------------------------------------------------- 3 %function [colorlist,col_vec,minC,ColCode1,ColCode2,maxC]= colvec(colcode,vec_C)3 %function [colorlist,col_vec,minC,ColCode1,ColCode2,maxC]=set_col_vec(colcode,vec_C) 4 4 %----------------------------------------------------------------------- 5 5 %OUTPUT … … 8 8 %minC, maxC: min and max of vec_C 9 9 %ColCode1, ColCode2: absolute threshold in vec_C corresponding to colcode.ColCode1 and colcode.ColCode2 10 % 10 11 %INPUT 11 12 % colcode: struture setting the colorcode for vectors 12 13 % colcode.CName: 'ima_cor','black','white',... 13 % colcode.ColorCode ='black', 'white', 'rgb','brg', '64 colors' 14 % colcode.ColorCode ='black', 'white', 'rgb','brg', '64 colors','BuYlRd' 14 15 % colcode.CheckFixVecColor =0; thresholds scaling relative to min and max, =1 fixed thresholds 15 16 % colcode.MinVec; min … … 42 43 col_vec=ones(size(vec_C));%all vectors at color#1 by default 43 44 44 if ~isstruct(colcode),colcode=[];end ;45 if ~isstruct(colcode),colcode=[];end 45 46 colcode_out=colcode;%default 46 47 if isempty(vec_C) || ~isnumeric(vec_C) … … 55 56 colorlist=[0 0 1]; %blue 56 57 else 57 if strcmp(colcode.ColorCode,'black') 58 if strcmp(colcode.ColorCode,'black')% black vectors 58 59 colorlist(1,:)=[0 0 0];%black 59 elseif strcmp(colcode.ColorCode,'white') 60 elseif strcmp(colcode.ColorCode,'white')% white vectors 60 61 colorlist(1,:)=[1 1 1];%white 61 62 else … … 64 65 end 65 66 67 %% colored vectors 66 68 if check_multicolors 67 69 if (isfield(colcode,'CheckFixVecColor') && isequal(colcode.CheckFixVecColor,1)) … … 97 99 end 98 100 else 101 switch colcode.ColorCode 102 case '64 colors' 99 103 colorjet=jet;% ususal colormap from blue to red 100 sizlist=size(colorjet); 104 case 'BuYlRd' 105 hh=load('BuYlRd.mat'); 106 colorjet=hh.BuYlRd; 107 end 108 sizlist=size(colorjet,1); 101 109 indsel=ceil((sizlist(1)/64)*(1:64)); 102 110 colorlist(:,1)=colorjet(indsel,1); 103 111 colorlist(:,2)=colorjet(indsel,2); 104 112 colorlist(:,3)=colorjet(indsel,3); 105 sizlist=size(colorlist); 106 nblevel=sizlist(1); 113 nblevel=size(colorlist,1); 107 114 col2_1=maxC-minC; 108 115 col_vec=1+floor(nblevel*(vec_C-minC)/col2_1); -
trunk/src/uvmat.m
r1102 r1103 894 894 function MenuExportCustom_Callback(hObject, eventdata, handles) 895 895 export_fct_name=get(handles.MenuExportCustom,'label'); 896 current_dir=pwd;%current working dir 897 cd(fullfile(fileparts(which('uvmat')),'export_fct')) 898 export_handle=str2func(export_fct_name); 899 cd(current_dir) 900 export_handle(handles) 896 if strcmp(export_fct_name,'user export fct.') 897 MenuExportMore_Callback(hObject, eventdata, handles) 898 else 899 current_dir=pwd;%current working dir 900 cd(fullfile(fileparts(which('uvmat')),'export_fct')) 901 export_handle=str2func(export_fct_name); 902 cd(current_dir) 903 export_handle(handles) 904 end 901 905 902 906 % -------------------------------------------------------------------- … … 2425 2429 ColorType=FileInfo.ColorType;%='truecolor' for color images 2426 2430 end 2427 set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image 2431 if strcmp(ColorType,'truecolor') 2432 set(handles.CheckBW,'String',{'grayscale';'truecolor'}) 2433 else 2434 set(handles.CheckBW,'String',{'grayscale';'default';'jet';'BuYlRd'}) 2435 end 2436 if strcmp(ColorType,'grayscale') 2437 set(handles.CheckBW,'Value',1) 2438 else 2439 set(handles.CheckBW,'Value',2) 2440 end 2428 2441 2429 2442 %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) … … 5452 5465 function CheckFixScalar_Callback(hObject, eventdata, handles) 5453 5466 %------------------------------------------------------------------------ 5454 test=get(handles.CheckFixScalar,'Value'); 5455 if test 5456 % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) 5457 else 5458 % set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) 5467 if ~get(handles.CheckFixScalar,'Value') 5459 5468 update_plot(handles); 5460 5469 end … … 5478 5487 set(handles.num_IncrA,'Visible','on') 5479 5488 set(handles.num_IncrA,'String','')% refresh contour interval 5480 % set(handles.opacity_txt,'Visible','off')5481 % set(handles.num_Opacity,'Visible','off')5482 5489 else % option 'image' 5483 5490 set(handles.interval_txt,'Visible','off') 5484 5491 set(handles.num_IncrA,'Visible','off') 5485 % set(handles.opacity_txt,'Visible','on')5486 % set(handles.num_Opacity,'Visible','on')5487 5492 end 5488 5493 update_plot(handles); … … 5562 5567 enable_bounds='on'; 5563 5568 enable_scalar='on'; 5564 case '64 colors'5569 case {'64 colors','BuYlRd'} 5565 5570 enable_bounds='on'; 5566 5571 enable_scalar='on'; … … 6109 6114 6110 6115 6111 6112 % %TODO: use to modify fill_GUI6113 % %'write_plot_param': update the plotting parameters on the uvmat or view_field interface after a plotting operation6114 % function write_plot_param(handles,PlotParam)6115 % %% axes6116 % if isempty(PlotParam.Axes)6117 % set(handles.Axes,'Visible','off')6118 % set(handles.PlotAxes,'Visible','off')6119 % set(handles.text_display,'Visible','off')6120 % set(handles.TableDisplay,'Visible','on')6121 % else6122 % set(handles.Axes,'Visible','on')6123 % set(handles.PlotAxes,'Visible','on')6124 % set(handles.text_display,'Visible','on')6125 % % if isfield(handles,'TableDisplay')6126 % % set(handles.TableDisplay,'Visible','off')6127 % % end6128 % Coordinates=PlotParam.Axes;6129 % if isfield(Coordinates,'CheckFixAspectRatio')6130 % if Coordinates.CheckFixAspectRatio6131 % set(handles.CheckFixAspectRatio,'Value',1)6132 % else6133 % set(handles.CheckFixAspectRatio,'Value',0)6134 %6135 % end6136 % end6137 % if isfield(Coordinates,'AspectRatio')6138 % set(handles.num_AspectRatio,'String',num2str(Coordinates.AspectRatio))6139 % end6140 % if isfield(Coordinates,'MinX')6141 % set(handles.num_MinX,'String',num2str(Coordinates.MinX,4));6142 % set(handles.num_MaxX,'String',num2str(Coordinates.MaxX,4));6143 % set(handles.num_MinY,'String',num2str(Coordinates.MinY,4));6144 % set(handles.num_MaxY,'String',num2str(Coordinates.MaxY,4));6145 % else6146 % set(handles.num_MinX,'String','');6147 % set(handles.num_MaxX,'String','');6148 % set(handles.num_MinY,'String','');6149 % set(handles.num_MaxY,'String','');6150 % end6151 % end6152 %6153 % %% scalar or image parameters6154 % if isfield(PlotParam,'Scalar')6155 % set(handles.Scalar,'Visible','on')6156 % if isfield(PlotParam.Scalar,'MaxA')6157 % set(handles.num_MaxA,'String',num2str(PlotParam.Scalar.MaxA,3));6158 % end6159 % if isfield(PlotParam.Scalar,'MinA')6160 % set(handles.num_MinA,'String',num2str(PlotParam.Scalar.MinA,3));6161 % end6162 % if isfield(PlotParam.Scalar,'IncrA')6163 % set(handles.num_IncrA,'String',num2str(PlotParam.Scalar.IncrA,3))6164 % end6165 % set(handles.CheckBW,'Value',PlotParam.Scalar.CheckBW)6166 % if isfield(PlotParam.Scalar,'Opacity')&&isfield(handles,'num_Opacity')6167 % set(handles.num_Opacity,'String',num2str(PlotParam.Scalar.Opacity))6168 % end6169 % else6170 % set(handles.Scalar,'Visible','off')6171 % end6172 %6173 % %% parameter for vector field6174 % if isfield(PlotParam,'Vectors')6175 % set(handles.Vectors,'Visible','on')6176 % if isfield(PlotParam.Vectors,'VecScale')6177 % set(handles.num_VecScale,'String',num2str(PlotParam.Vectors.VecScale,3))6178 % end6179 % if isfield(PlotParam.Vectors,'MinC')&& isfield(PlotParam.Vectors,'MaxC')6180 % MinC=PlotParam.Vectors.MinC;6181 % MaxC=PlotParam.Vectors.MaxC;6182 % set(handles.num_MinVec,'String', num2str(MinC,3));6183 % set(handles.num_MaxVec,'String',num2str(MaxC,3));6184 % list=get(handles.ColorCode,'String');6185 % ichoice=get(handles.ColorCode,'Value');6186 % color_option=list{ichoice};6187 % test3color=strcmp(color_option,'rgb')||strcmp(color_option,'bgr');6188 % if test3color% need to update color thresholds6189 % set(handles.num_ColCode1,'Visible','on')6190 % set(handles.num_ColCode2,'Visible','on')6191 % set(handles.Slider1,'Visible','on')6192 % set(handles.Slider2,'Visible','on')6193 % set(handles.num_ColCode1,'String',num2str(PlotParam.Vectors.ColCode1,3))6194 % set(handles.num_ColCode2,'String',num2str(PlotParam.Vectors.ColCode2,3))6195 % set(handles.Slider1,'Value',(PlotParam.Vectors.ColCode1-MinC)/(MaxC-MinC))6196 % set(handles.Slider2,'Value',(PlotParam.Vectors.ColCode2-MinC)/(MaxC-MinC))6197 % else6198 % set(handles.num_ColCode1,'Visible','off')6199 % set(handles.num_ColCode2,'Visible','off')6200 % set(handles.Slider1,'Visible','off')6201 % set(handles.Slider2,'Visible','off')6202 % end6203 % end6204 % else6205 % set(handles.Vectors,'Visible','off')6206 % if isfield(handles,'edit_vect')6207 % set(handles.edit_vect,'Visible','off')6208 % set(handles.record,'Visible','off')6209 % end6210 % end6211 6212 6116 % -------------------------------------------------------------------- 6213 6117 % --- Executes on button press in CheckTable.
Note: See TracChangeset
for help on using the changeset viewer.