Changeset 313 for trunk/src/set_col_vec.m
- Timestamp:
- Dec 1, 2011, 12:44:42 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/set_col_vec.m
r102 r313 1 1 %'set_col_vec': sets the color code for vectors depending on a scalar vec_C and parameters given by the struct colcode 2 %function [colorlist,col_vec,minC, colcode1,colcode2,maxC]=colvec(colcode,vec_C)2 %function [colorlist,col_vec,minC,ColCode1,ColCode2,maxC]=colvec(colcode,vec_C) 3 3 %OUTPUT 4 4 %colorlist(nb,3); %list of nb colors 5 5 %col_vec, size=[length(vec_C),3)];%list of color indices corresponding to vec_C 6 6 %minC, maxC: min and max of vec_C 7 % colcode1, colcode2: absolute threshold in vec_C corresponding to colcode.colcode1 and colcode.colcode27 %ColCode1, ColCode2: absolute threshold in vec_C corresponding to colcode.ColCode1 and colcode.ColCode2 8 8 %INPUT 9 9 % colcode: struture setting the colorcode for vectors 10 10 % colcode.CName: 'ima_cor','black','white',... 11 % colcode. ColorCode ='black', 'white', 'rgb','brg', '64 colors'11 % colcode.ListColorCode ='black', 'white', 'rgb','brg', '64 colors' 12 12 % colcode.FixedCbounds =0; thresholds scaling relative to min and max, =1 fixed thresholds 13 13 % colcode.MinC; min 14 14 % colcode.MaxC; max 15 % colcode. colcode1: first threshold for rgb, relative to min (0) and max (1)16 % colcode. colcode2: second threshold for rgb, relative to min (0) and max (1),17 % rmq: we need min <= colcode1 <= colcode2 <= max, otherwise18 % colcode1 and colcode2 are adjusted to the bounds15 % colcode.ColCode1: first threshold for rgb, relative to min (0) and max (1) 16 % colcode.ColCode2: second threshold for rgb, relative to min (0) and max (1), 17 % rmq: we need min <= ColCode1 <= ColCode2 <= max, otherwise 18 % ColCode1 and ColCode2 are adjusted to the bounds 19 19 % vec_C: matlab vector representing the scalar setting the color 20 20 function [colorlist,col_vec,colcode_out]=set_col_vec(colcode,vec_C) … … 27 27 return 28 28 end 29 if (isfield(colcode,' FixedCbounds') && isequal(colcode.FixedCbounds,1))30 minC=colcode.Min C;31 maxC=colcode.Max C;29 if (isfield(colcode,'CheckFixVecColor') && isequal(colcode.CheckFixVecColor,1)) 30 minC=colcode.MinVec; 31 maxC=colcode.MaxVec; 32 32 else 33 33 minC=min(vec_C); … … 37 37 %default input parameters 38 38 if ~isstruct(colcode),colcode=[];end; 39 if ~isfield(colcode,' ColorCode') || isempty(colcode.ColorCode)39 if ~isfield(colcode,'ListColorCode') || isempty(colcode.ListColorCode) 40 40 colorlist=[0 0 1]; %blue 41 41 col_vec=ones(size(vec_C)); 42 42 return 43 43 end 44 if isfield(colcode,' colcode1')45 colcode1=minC+colcode.colcode1*(maxC-minC);44 if isfield(colcode,'ColCode1') 45 ColCode1=minC+colcode.ColCode1*(maxC-minC); 46 46 else 47 colcode1=minC+(maxC-minC)/3;%default47 ColCode1=minC+(maxC-minC)/3;%default 48 48 end 49 if isfield(colcode,' colcode2')50 colcode2=minC+colcode.colcode2*(maxC-minC);49 if isfield(colcode,'ColCode2') 50 ColCode2=minC+colcode.ColCode2*(maxC-minC); 51 51 else 52 colcode2=minC+2*(maxC-minC)/3;%default52 ColCode2=minC+2*(maxC-minC)/3;%default 53 53 end 54 54 colcode_out.MinC=minC; 55 55 colcode_out.MaxC=maxC; 56 if strcmp(colcode. ColorCode,'black')56 if strcmp(colcode.ListColorCode,'black') 57 57 colorlist(1,:)=[0 0 0];%black 58 58 col_vec=ones(size(vec_C));%all vectors at color#1 59 elseif strcmp(colcode. ColorCode,'white')59 elseif strcmp(colcode.ListColorCode,'white') 60 60 colorlist(1,:)=[1 1 1];%white 61 61 col_vec=ones(size(vec_C));%all vectors at color#1 62 elseif strcmp(colcode. ColorCode,'rgb')|| strcmp(colcode.ColorCode,'bgr')% 3 color representation63 ind1=find(vec_C < colcode1); % =1 for red vectors64 ind_green=find((vec_C >= colcode1) & (vec_C < colcode2));% =1 for green vectors65 ind3=find(vec_C >= colcode2);% =1 for blue vectors62 elseif strcmp(colcode.ListColorCode,'rgb')|| strcmp(colcode.ListColorCode,'bgr')% 3 color representation 63 ind1=find(vec_C < ColCode1); % =1 for red vectors 64 ind_green=find((vec_C >= ColCode1) & (vec_C < ColCode2));% =1 for green vectors 65 ind3=find(vec_C >= ColCode2);% =1 for blue vectors 66 66 colorlist(2,:)=[0 1 0];%green 67 67 col_vec(ind1)=1; 68 68 col_vec(ind_green)=2; 69 69 col_vec(ind3)=3; 70 if strcmp(colcode. ColorCode,'rgb')70 if strcmp(colcode.ListColorCode,'rgb') 71 71 colorlist(1,:)=[1 0 0];%red 72 72 colorlist(3,:)=[0 0 1];%blue
Note: See TracChangeset
for help on using the changeset viewer.