PS 给出的定义:

Enhance Monochromatic Contrast: Clips all channels identically. This preserves the overall color relationship while making highlights
appear lighter and shadows appear darker. The Auto Contrast command uses this algorithm.

和自动色阶不一样的地方在于,自动对比度不是三个通道分别调整,而是三个通道同时调整,可以先获取图像的亮度信息,然后根据 clipping percentage 对亮度进行动态范围的拉伸,根据拉伸前后亮度的比率,可以同比例调整R,G,B 三个通道,这样调整的图像不会出现色偏的问题。

先拉伸亮度的动态范围,可以借用自动色阶里的函数。

function I_out=F_color(I, percent)

%%% the tonal range of the input image is 0-1.

[row, col]=size(I);

I_sort=sort(I(:));

I_out=I;

%%% based on the clipping percentage, 

%%% compute the upper and lower boundaries 

if (percent==0)

    I_min=min(I_sort)

    I_max=max(I_sort)

else

    I_min=I_sort(floor(row*col*percent))

    I_max=I_sort(floor(row*col*(1-percent)))

end



for i=1:row

    for j=1:col

            if(I(i,j)<I_min)

                I_out(i,j)=I_min;

            elseif(I(i,j)>I_max)

                I_out(i,j)=1;

            else

                I_out(i,j)=(I(i,j)-I_min)*(1-I_min)/(I_max-I_min)+I_min;

            end

    end 

end

利用拉伸前后亮度的比率,同比例调整R,G,B三个通道。

clc;

clear all;

Image=imread('8.jpg');

Image=double(Image)/255;

imshow(Image);

R=Image(:,:,1);

G=Image(:,:,2);

B=Image(:,:,3);

I=R*0.2989+G*0.5871+0.1140*B;

I=I/(max(I(:)));

percent=0.001;

I_out=F_color(I, percent);

delta=0.0001;

K=(I_out+delta)./(I+delta);

Image_out(:,:,1)=R.*K;

Image_out(:,:,2)=G.*K;

Image_out(:,:,3)=B.*K;

figure, imshow(Image_out);

原图:

调整后的图:

最新文章

  1. SCons - 简单而强大的项目编译脚本
  2. python 中偏函数 partial 的使用
  3. bzoj 1877: [SDOI2009]晨跑
  4. SqlServer 事务和异常处理示例
  5. 题解西电OJ (Problem 1003 -最喜欢的数字)--动态规划
  6. Web前端性能优化的14条规则
  7. Redis intset
  8. Git双机同步
  9. Webpack多入口文件、热更新等体验
  10. ROS多机通信计算机网络配置
  11. JavaScript中Object的总结
  12. Struts2上传文件出错
  13. BZOJ 1500/Luogu 2042 - 维修数列 - [NOI2005][Splay]
  14. 常量,变量,a++,++a,+=等
  15. selenium 模拟手机
  16. 20155306 白皎 0day漏洞——漏洞利用原理之DEP
  17. javascript 浮点数加减乘除计算会有问题, 整理了以下代码来规避这个问题
  18. ZOJ 2969 Easy Task
  19. Python 装饰器Decorator(二)
  20. idea中tomcat乱码问题解决

热门文章

  1. 1CCTableView的使用,TableView响应和小格子tableView实现
  2. EJB开发第一个无状态会话bean、开发EJB客户端
  3. Android必知必会-使用okhttp的PUT方式上传文件
  4. EBS系统克隆
  5. 【java线程系列】java线程系列之线程间的交互wait()/notify()/notifyAll()及生产者与消费者模型
  6. JPA(三)之实体关系一对多(多对一)
  7. Java-IO之BufferedInputStream(缓冲输入流)
  8. eclipse代码恢复(开发程序代码恢复)
  9. [Redmine] Centos5上安装Redmine3.0+nginx+thin部署
  10. Linux IPC实践(7) --Posix消息队列