Changeset 405 for trunk/src/set_col_vec.m
- Timestamp:
- May 1, 2012, 10:08:36 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/set_col_vec.m
r356 r405 11 11 % colcode: struture setting the colorcode for vectors 12 12 % colcode.CName: 'ima_cor','black','white',... 13 % colcode. ListColorCode ='black', 'white', 'rgb','brg', '64 colors'13 % colcode.ColorCode ='black', 'white', 'rgb','brg', '64 colors' 14 14 % colcode.CheckFixVecColor =0; thresholds scaling relative to min and max, =1 fixed thresholds 15 15 % colcode.MinVec; min … … 22 22 function [colorlist,col_vec,colcode_out]=set_col_vec(colcode,vec_C) 23 23 col_vec=[]; 24 if ~isstruct(colcode),colcode=[];end; 24 25 colcode_out=colcode;%default 25 26 if isempty(vec_C) || ~isnumeric(vec_C) 26 colorlist=[0 0 1]; %blue 27 colorlist=[0 0 1]; %blue 27 28 col_vec=ones(size(vec_C)); 28 29 return 29 30 end 30 if (isfield(colcode,'CheckFixVecColor') && isequal(colcode.CheckFixVecColor,1)) 31 minC=colcode.MinVec; 32 maxC=colcode.MaxVec; 31 32 33 34 % colcode_out.ColCode1=ColCode1; 35 % colcode_out.ColCode2=ColCode2; 36 %% uniform color plot 37 check_multicolors=0; 38 col_vec=ones(size(vec_C));%all vectors at color#1 by default 39 %default input parameters 40 if ~isfield(colcode,'ColorCode') || isempty(colcode.ColorCode) 41 colorlist=[0 0 1]; %blue 33 42 else 34 minC=min(vec_C); 35 maxC=max(vec_C); 43 if strcmp(colcode.ColorCode,'black') 44 colorlist(1,:)=[0 0 0];%black 45 elseif strcmp(colcode.ColorCode,'white') 46 colorlist(1,:)=[1 1 1];%white 47 else 48 check_multicolors=1; 49 end 36 50 end 37 51 38 %default input parameters 39 if ~isstruct(colcode),colcode=[];end; 40 if ~isfield(colcode,'ListColorCode') || isempty(colcode.ListColorCode) 41 colorlist=[0 0 1]; %blue 42 col_vec=ones(size(vec_C)); 43 return 52 if check_multicolors 53 if (isfield(colcode,'CheckFixVecColor') && isequal(colcode.CheckFixVecColor,1)) 54 minC=colcode.MinVec; 55 maxC=colcode.MaxVec; 56 else 57 minC=min(vec_C); 58 maxC=max(vec_C); 59 end 60 colcode_out.MinC=minC; 61 colcode_out.MaxC=maxC; 62 if strcmp(colcode.ColorCode,'rgb')|| strcmp(colcode.ColorCode,'bgr')% 3 color representation 63 if isfield(colcode,'ColCode1') 64 colcode_out.ColCode1=colcode.ColCode1; 65 else 66 colcode_out.ColCode1=minC+(maxC-minC)/3;%default 67 end 68 if isfield(colcode,'ColCode2') 69 colcode_out.ColCode2=colcode.ColCode2; 70 else 71 colcode_out.ColCode2=minC+2*(maxC-minC)/3;%default 72 end 73 colorlist(2,:)=[0 1 0];%green 74 col_vec(vec_C < colcode_out.ColCode1)=1;% vectors with vec_C smaller than ColCode1 set to the first color (r or b) 75 col_vec((vec_C >= colcode_out.ColCode1) & (vec_C < colcode_out.ColCode2))=2;% select green vectors 76 col_vec(vec_C >= colcode_out.ColCode2)=3; 77 if strcmp(colcode.ColorCode,'rgb') 78 colorlist(1,:)=[1 0 0];%red 79 colorlist(3,:)=[0 0 1];%blue 80 else 81 colorlist(1,:)=[0 0 1];%blue 82 colorlist(3,:)=[1 0 0];%red 83 end 84 else 85 colorjet=jet;% ususal colormap from blue to red 86 sizlist=size(colorjet); 87 indsel=ceil((sizlist(1)/64)*(1:64)); 88 colorlist(:,1)=colorjet(indsel,1); 89 colorlist(:,2)=colorjet(indsel,2); 90 colorlist(:,3)=colorjet(indsel,3); 91 sizlist=size(colorlist); 92 nblevel=sizlist(1); 93 col2_1=maxC-minC; 94 col_vec=1+floor(nblevel*(vec_C-minC)/col2_1); 95 col_vec=col_vec.*(col_vec<= nblevel)+nblevel*(col_vec >nblevel);% take color #nblevel at saturation 96 col_vec=col_vec.*(col_vec>= 1)+ (col_vec <1);% take color #1 for values below 1 97 end 44 98 end 45 if isfield(colcode,'ColCode1')46 ColCode1=minC+colcode.ColCode1*(maxC-minC);47 else48 ColCode1=minC+(maxC-minC)/3;%default49 end50 if isfield(colcode,'ColCode2')51 ColCode2=minC+colcode.ColCode2*(maxC-minC);52 else53 ColCode2=minC+2*(maxC-minC)/3;%default54 end55 colcode_out.MinC=minC;56 colcode_out.MaxC=maxC;57 if strcmp(colcode.ListColorCode,'black')58 colorlist(1,:)=[0 0 0];%black59 col_vec=ones(size(vec_C));%all vectors at color#160 elseif strcmp(colcode.ListColorCode,'white')61 colorlist(1,:)=[1 1 1];%white62 col_vec=ones(size(vec_C));%all vectors at color#163 elseif strcmp(colcode.ListColorCode,'rgb')|| strcmp(colcode.ListColorCode,'bgr')% 3 color representation64 % ind1=find(vec_C < ColCode1); % =1 for red vectors65 ind_green=find((vec_C >= ColCode1) & (vec_C < ColCode2));% =1 for green vectors66 % ind3=find(vec_C >= ColCode2);% =1 for blue vectors67 colorlist(2,:)=[0 1 0];%green68 col_vec(vec_C < ColCode1)=1;69 col_vec(ind_green)=2;70 col_vec(vec_C >= ColCode2)=3;71 if strcmp(colcode.ListColorCode,'rgb')72 colorlist(1,:)=[1 0 0];%red73 colorlist(3,:)=[0 0 1];%blue74 else75 colorlist(1,:)=[0 0 1];%blue76 colorlist(3,:)=[1 0 0];%red77 end78 else79 colorjet=jet;% ususal colormap from blue to red80 sizlist=size(colorjet);81 indsel=ceil((sizlist(1)/64)*(1:64));82 colorlist(:,1)=colorjet(indsel,1);83 colorlist(:,2)=colorjet(indsel,2);84 colorlist(:,3)=colorjet(indsel,3);85 sizlist=size(colorlist);86 nblevel=sizlist(1);87 col2_1=maxC-minC;88 col_vec=1+floor(nblevel*(vec_C-minC)/col2_1);89 col_vec=col_vec.*(col_vec<= nblevel)+nblevel*(col_vec >nblevel);% take color #nblevel at saturation90 col_vec=col_vec.*(col_vec>= 1)+ (col_vec <1);% take color #1 for values below 191 end
Note: See TracChangeset
for help on using the changeset viewer.