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

来源:互联网 发布:统赢编程教程 编辑:程序博客网 时间:2024/05/21 05:56


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

流浪的鱼link:

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


算法的实现还是很简单的。

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


一下参数均使用

对比度1.5

亮度 1

即对比度增强1.5,亮度不变.






%*********************************************************% 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!\n');    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


0 0