资源简介
该matlab程序实现各个颜色空间模型的相互转化,说明及使用示例程序中都有说明。与君共享。
代码片段和文件信息
function varargout = colorspace(Conversionvarargin)
%COLORSPACE Convert a color image between color representations.
% B = COLORSPACE(SA) converts the color representation of image A
% where S is a string specifying the conversion. S tells the
% source and destination color spaces S = ‘dest<-src‘ or
% alternatively S = ‘src->dest‘. Supported color spaces are
%
% ‘RGB‘ R‘G‘B‘ Red Green Blue (ITU-R BT.709 gamma-corrected)
% ‘YPbPr‘ Luma (ITU-R BT.601) + Chroma
% ‘YCbCr‘/‘YCC‘ Luma + Chroma (“digitized“ version of Y‘PbPr)
% ‘YUV‘ NTSC PAL Y‘UV Luma + Chroma
% ‘YIQ‘ NTSC Y‘IQ Luma + Chroma
% ‘YDbDr‘ SECAM Y‘DbDr Luma + Chroma
% ‘JPEGYCbCr‘ JPEG-Y‘CbCr Luma + Chroma
% ‘HSV‘/‘HSB‘ Hue Saturation Value/Brightness
% ‘HSL‘/‘HLS‘/‘HSI‘ Hue Saturation Luminance/Intensity
% ‘XYZ‘ CIE XYZ
% ‘Lab‘ CIE L*a*b* (CIELAB)
% ‘Luv‘ CIE L*u*v* (CIELUV)
% ‘Lch‘ CIE L*ch (CIELCH)
%
% All conversions assume 2 degree observer and D65 illuminant. Color
% space names are case insensitive. When R‘G‘B‘ is the source or
% destination it can be omitted. For example ‘yuv<-‘ is short for
% ‘yuv<-rgb‘.
%
% MATLAB uses two standard data formats for R‘G‘B‘: double data with
% intensities in the range 0 to 1 and uint8 data with integer-valued
% intensities from 0 to 255. As MATLAB‘s native datatype double data is
% the natural choice and the R‘G‘B‘ format used by colorspace. However
% for memory and computational performance some functions also operate
% with uint8 R‘G‘B‘. Given uint8 R‘G‘B‘ color data colorspace will
% first cast it to double R‘G‘B‘ before processing.
%
% If A is an Mx3 array like a colormap B will also have size Mx3.
%
% [B1B2B3] = COLORSPACE(SA) specifies separate output channels.
% COLORSPACE(SA1A2A3) specifies separate input channels.
% Pascal Getreuer 2005-2006
%%% Input parsing %%%
if nargin < 2 error(‘Not enough input arguments.‘); end
[SrcSpaceDestSpace] = parse(Conversion);
if nargin == 2
Image = varargin{1};
elseif nargin >= 3
Image = cat(3varargin{:});
else
error(‘Invalid number of input arguments.‘);
end
FlipDims = (size(Image3) == 1);
if FlipDims Image = permute(Image[132]); end
if ~isa(Image‘double‘) Image = double(Image)/255; end
if size(Image3) ~= 3 error(‘Invalid input size.‘); end
SrcT = gettransform(SrcSpace);
DestT = gettransform(DestSpace);
if ~ischar(SrcT) & ~ischar(DestT)
% Both source and destination transforms are affine so they
% can be composed into one affine operation
T = [DestT(:1:3)*SrcT(:1:3)DestT(:1:3)*SrcT(:4)+DestT(:4)];
Temp = zeros(size(Image));
Temp(::1) = T(1)*Image(::1) + T(4)*Image(::2) + T(7)*Image(::3) + T(10);
Temp(::2) = T(2)*Image(::1) + T(5)*Image(::
相关资源
- MATLAB实现HOG特征提取
- 神经网络matlab实现几种hop(Hopfield)算
- matlab 散点图实验数据
- 数字图像处理(第三版)matlab代码 冈
- TLS_ESPRIT的间谐波检测算法matlab程序
- LT码的MATLAB实现
- 广义霍夫变换 GHT matlab代码
- LEACH仿真 簇头 节点存活 系统能耗
- 傅里叶梅林图像拼接MATLAB
- 基于matlab的灰色预测模型GM1,1预测标
- 基于帧差法的运动目标检测的matlab代
- matlab产生正弦光栅条纹
- 雷英杰《MATLAB遗传算法工具箱与应用
- 小波锐化matlab
- matlab AR模型参数谱估计
- 基于MATLAB的运动物体检测与识别
- prim算法在matlab中的代码
-
直接转矩控制的matlab/Simuli
nk模型 - 循环平稳信号的MATLAB的仿真
- 肤色检测matlab
- matlab产生正弦波及.mif文件的程序
- matlab实现十进制到二进制定点有符号
- 各类杂波模拟及Matlab实现.zip
- 异步电机矢量控制MATLAB 仿真
- 生成pwm波形的matlab编程
- matlab边缘化处理代码
- 业界良心版BP神经网络分类MATLAB代码
- huff编解码matlab算法
- 朴素贝叶斯算法matlab代码实现
- FDBPM算法matlab程序
评论
共有 条评论