📄 uint322colcode.m
字号:
function outarray = uint322colcode(inarray)
% uint322colcode - convert from uint32 to colcode array
%
% FORMAT: outarray = uint322colcode(inarray)
%
% Input fields:
%
% inarray Nx1 (or 1xN) input array of type uint32
%
% Output fields:
%
% outarray Nx4 double array
% (n, 1) = color index or NaN
% (n, 2) = red component (0...255)
% (n, 3) = green component (0...255)
% (n, 4) = blue component (0...255)
%
% See also colcode2uint32
% Version: v0.6f
% Build: 7061811
% Date: Jun-18 2007, 11:42 AM CET
% Author: Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools
% argument check
if nargin ~= 1 || ...
~isa(inarray, 'uint32')
error( ...
'BVQXtools:BadArgument', ...
'Bad/missing input argument supplied.' ...
);
end
% linearize array
inarray = double(inarray(:));
% produce output array
outarray = zeros(length(inarray), 4);
outarray(:, 1) = NaN;
% index color range and moduli
idxcolormin = 63 * 16777216;
idxcolormax = 64 * 16777216;
rmodulus = 16777216;
gmodulus = 65536;
bmodulus = 256;
% get colors with indices
idxcolor = find((inarray < idxcolormin) | (inarray >= idxcolormax));
rgbcolor = find((inarray >= idxcolormin) & (inarray < idxcolormax));
% set index
outarray(idxcolor, 1) = inarray(idxcolor);
% fill those correctly
outarray(rgbcolor, 2) = floor(mod(inarray(rgbcolor, 1), rmodulus) / 65536);
outarray(rgbcolor, 3) = floor(mod(inarray(rgbcolor, 1), gmodulus) / 256);
outarray(rgbcolor, 4) = mod(inarray(rgbcolor, 1), bmodulus);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -