一种基于RGB空间的对照度增强的filter


今天看前辈博客的时候看到一种新的基于RGB颜色空间的image contrast enhance filter

流浪的鱼link:

http://blog.csdn.net/jia20003/article/details/7385160#comments


算法的实现还是非常easy的。

左边的均是原图。右边的是增强后的图片,只是感觉RGB空间的算法都还是又色相转移的问题...这样的算法的效果没有HSV的效果好~说死点。这样的做法就是不正确的....


一下參数均使用

对照度1.5

亮度 1

即对照度增强1.5。亮度不变.

一种基于RGB空间的对照度增强的filter


一种基于RGB空间的对照度增强的filter



%*********************************************************
% code writer   : EOF
% code file     : ehc_filter_color_img.m
% code date     : 2014.10.27
% e-mail        : jasonleaster@gmail.com
%
% Code Description:
%       A image enchance filter in RGB color space.
%*********************************************************

function Output = ehc_filter_color_img(Image,contrast_coefficient,brightness_coefficient)

    Image_Channel = size(Image,3);
    
    if Image_Channel ~=3 
        fprintf('Image channel error!
');
    end
    
    Height_Image = size(Image,1);
    Width_Image  = size(Image,2);
    
    for row = 1 : Height_Image
        for col = 1 : Width_Image
             mean_value = (Image(row,col,1) + Image(row,col,2) + Image(row,col,3) )/3;
             
              Image(row,col,1) =  Image(row,col,1) - mean_value;
              Image(row,col,2) =  Image(row,col,2) - mean_value;
              Image(row,col,3) =  Image(row,col,3) - mean_value;
              
              Image(row,col,1) =  Image(row,col,1)*contrast_coefficient;
              Image(row,col,2) =  Image(row,col,2)*contrast_coefficient;
              Image(row,col,3) =  Image(row,col,3)*contrast_coefficient;
              
              Image(row,col,1) =  Image(row,col,1) + mean_value*brightness_coefficient;
              Image(row,col,2) =  Image(row,col,2) + mean_value*brightness_coefficient;
              Image(row,col,3) =  Image(row,col,3) + mean_value*brightness_coefficient;
        end
    end

    Output = Image;
end