Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
 
 
主题工具 显示模式
旧 2008-05-27, 21:16   #2
qxb0111
初级会员
 
注册日期: 2008-05-15
年龄: 38
帖子: 2
声望力: 0
qxb0111 正向着好的方向发展
默认

function hsi=rgb2hsi(rgb)
%RGB2HSI Converts an RGB image to HSI
% HSI=RGB2HSI(rgb) converts an RGB image to HSI. The input image is
% assumed to be of size M-by-N-by-3, where the third dimension accounts
% for three image planes:red, green, and blue, in that order. If all RGB
% component images are equal, the HSI conversion is undefined. Ths input
% image can be of class double (with values in the rang[0,1]), uint8, or
% uint16.
% The output image, HSI, is of class double, where:
% hsi(:,:,1)= hue image normalized values to the range [0,1] by
% dividing all angle values by 2*pi.
% hsi(:,:,2)=saturation image, in the range [0,1].
% hsi(:,:,3)=intensity image, in the range [0,1].
%Extract the individual component images.
rgb=im2double(rgb);
r=rgb(:,:,1);
g=rgb(:,:,2);
b=rgb(:,:,3);
%Implement the conversion equations.
num=0.5*((r-g)+(r-b));
den=sqrt((r-g).^2+(r-b).*(g-b));
theta=acos(num./(den+eps));
H=theta;
H(b>g)=2*pi-H(b>g);
H=H/(2*pi);

num=min(min(r,g),b);
den=r+g+b;
den(den==0)=eps;
S=1-3.*num./den;
H(S==0)=0;
I=(r+g+b)/3;
%Combine all three results into an hsi image.
hsi=cat(3,H,S,I);
qxb0111 当前离线   回复时引用此帖
 

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码


相似的主题
主题 主题作者 版面 回复 最后发表
新手请教如何缩短时间 mtseasky MATLAB论坛 1 2008-07-26 01:36
求助:向量分段求乘积 fifa2002qwe MATLAB论坛 2 2008-06-01 22:02
matlab 中反函数运算。 zhanggongrui MATLAB论坛 0 2008-04-29 00:03
BMP图像转换成时间序列 zlnhappy MATLAB论坛 0 2008-04-28 17:53
求救-----基于小波域的数字水印 tcgqb111 MATLAB论坛 0 2007-05-24 07:27


所有时间均为北京时间。现在的时间是 05:37


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.