您的位置:首页 > 其它

图像的HSV拉伸增强对比度

2014-10-21 20:50 621 查看
图像的HSV拉伸增强对比度

HSV 和RGB颜色空间的相互转换

http://blog.csdn.net/cinmyheart/article/details/40348831

HSV的拉伸对比度增强就是对S V 两个域进行归一化,H保持不变即可

左侧是原图,右侧是经过处理的图片



转换代码:

%% *********************************************************
% code writer : EOF
% code file : HSV_enhance_filter.m
% code date : 2014.10.21
% e-mail : jasonleaster@gmail.com
%
% Code description :
% we translate RGB into HSV and normolize the
% S V channel and then translate HSV back to RGB.
%
% *********************************************************

function Output = HSV_enhance_filter(Image)

if size(Image,3) ~= 3
fprintf('ERROR Imput-Image must be three channel image\n');
return;
end

[H,S,V] = RGB2SHV(Image);

V_max = max(max(V));
V_min = min(min(V));

S_max = max(max(S));
S_min = min(min(S));

Height_Image = size(Image,1);
Width_Image = size(Image,2);

for row = 1:Height_Image
for col = 1:Width_Image

S(row,col) = (S(row,col) - S_min)/(S_max - S_min);
V(row,col) = (V(row,col) - V_min)/(V_max - V_min);
end
end

Output = HSV2RGB_Color(H,S,V);

end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: