资源简介
该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路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
评论
共有 条评论