% % phase2hue_cycle( flAnglesIn ) % % Map angle values (in radians) to a hue cycle color map with roughly % uniform luminance (using hl.m, but this could be replaced with % MATLAB's "hsv" or "jet" color maps). % % % USAGE: % clrOut = phase2hue_cycle( -pi : .1 : pi ) % % ARGUMENTS: % % flAnglesIn: Input array with angle values in radians. % % RETURN VALUES: % % clrOut: An array RGB triplets, one for each of the input values. % % HARDCODED: (none) % % CALLS: % % -> hl.m % -> hl_color_cycle.m % % % Mark Dow, May 11, 2008 % function clrOut = phase2hue_cycle( flAnglesIn ) clrOut = NaN ( [ size(flAnglesIn) 3 ] ); % Normalize angles to [0,255] for use as indices into color cycle map: % Shift/wrap range to [0,2*pi]. nAnglesI = mod( flAnglesIn, 2*pi ); % Shift range to [0,255]. nAnglesI = floor( 256*nAnglesI/(2*pi) ); nAnglesI( find(nAnglesI == 256) ) = 255; clr_map = hl; % Could also use MATLAB's hsv or jet here. for i = 1 : size( nAnglesI, 1 ) for j = 1 : size( nAnglesI, 2 ) if ~isnan( nAnglesI( i, j ) ) clr = 256*clr_map( nAnglesI( i, j ) + 1, 1:3 ); clr( find( clr == 256 ) ) = 255; clrOut( i, j, 1:3 ) = clr; end end end