首页 > 代码库 > 图像的HSV拉伸增强对比度

图像的HSV拉伸增强对比度

图像的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



















图像的HSV拉伸增强对比度