Python: PS 图像调整--亮度调整
本文用 Python 实现 PS 图像调整中的亮度调整,具体的算法原理和效果可以参考之前的博客:
http://blog.csdn.net/matrix_space/article/details/22991683
import matplotlib.pyplot as plt
from skimage import io
file_name='D:/Image Processing/PS Algorithm/4.jpg';
img=io.imread(file_name)
Increment = -10.0
img = img * 1.0
I = (img[:, :, 0] + img[:, :, 1] + img[:, :, 2])/3.0 + 0.001
mask_1 = I > 128.0
r = img [:, :, 0]
g = img [:, :, 1]
b = img [:, :, 2]
rhs = (r*128.0 - (I - 128.0) * 256.0) / (256.0 - I)
ghs = (g*128.0 - (I - 128.0) * 256.0) / (256.0 - I)
bhs = (b*128.0 - (I - 128.0) * 256.0) / (256.0 - I)
rhs = rhs * mask_1 + (r * 128.0 / I) * (1 - mask_1)
ghs = ghs * mask_1 + (g * 128.0 / I) * (1 - mask_1)
bhs = bhs * mask_1 + (b * 128.0 / I) * (1 - mask_1)
I_new = I + Increment - 128.0
mask_2 = I_new > 0.0
R_new = rhs + (256.0-rhs) * I_new / 128.0
G_new = ghs + (256.0-ghs) * I_new / 128.0
B_new = bhs + (256.0-bhs) * I_new / 128.0
R_new = R_new * mask_2 + (rhs + rhs * I_new/128.0) * (1-mask_2)
G_new = G_new * mask_2 + (ghs + ghs * I_new/128.0) * (1-mask_2)
B_new = B_new * mask_2 + (bhs + bhs * I_new/128.0) * (1-mask_2)
Img_out = img * 1.0
Img_out[:, :, 0] = R_new
Img_out[:, :, 1] = G_new
Img_out[:, :, 2] = B_new
Img_out = Img_out/255.0
# 饱和处理
mask_1 = Img_out < 0
mask_2 = Img_out > 1
Img_out = Img_out * (1-mask_1)
Img_out = Img_out * (1-mask_2) + mask_2
plt.figure()
plt.imshow(img/255.0)
plt.axis('off')
plt.figure(2)
plt.imshow(Img_out)
plt.axis('off')
plt.figure(3)
plt.imshow(I/255.0, plt.cm.gray)
plt.axis('off')
plt.show()
Python: PS 图像调整--亮度调整的更多相关文章
- Python: PS 图像调整--明度调整
本文用 Python 实现 PS 图像调整中的明度调整: 我们知道,一般的非线性RGB亮度调整只是在原有R.G.B值基础上增加和减少一定量来实现的,而PS的明度调整原理还得从前面那个公式上去找.我们将 ...
- Python: PS 图像调整--饱和度调整
本文用 Python 实现 PS 图像调整中的饱和度调整算法,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/detail ...
- Python: PS 图像调整--黑白
本文用Python 实现 PS 里的图像调整–黑白,PS 里的黑白并不是简单粗暴的将图像转为灰度图,而是做了非常精细的处理,具体的算法原理和效果图可以参考以前的博客: http://blog.csdn ...
- Python: PS 图像调整--对比度调整
本文用 Python 实现 PS 里的图像调整–对比度调整.具体的算法原理如下: (1).nRGB = RGB + (RGB - Threshold) * Contrast / 255 公式中,nRG ...
- Python: PS 图像调整--颜色梯度
本文用 Python 实现 PS 中的色彩图,可以看到颜色的各种渐变,具体的效果可以参考以前的博客: http://blog.csdn.net/matrix_space/article/details ...
- PS 图像调整算法——亮度调整
这个算法是参考自 阿发伯 的博客,在此对 阿发伯 表示感谢, http://blog.csdn.net/maozefa 亮度调整 非线性亮度调整: 对于R,G,B三个通道,每个通道增加相同的增量. 线 ...
- PS 图像调整算法——自动对比度 (Auto Contrast)
PS 给出的定义: Enhance Monochromatic Contrast: Clips all channels identically. This preserves the overall ...
- PS 图像调整算法——自动色阶 (Auto Levels)
PS 给出的定义: Enhance Per Channel Contrast:Maximizes the tonal range in each channel to produce a more d ...
- PS 图像调整算法——黑白
这个算法是参考自 阿发伯 的博客: http://blog.csdn.net/maozefa 黑白调整 Photoshop CS的图像黑白调整功能,是通过对红.黄.绿.青.蓝和洋红等6种颜色的比例调节 ...
随机推荐
- P3258 松鼠的新家
松鼠的新家 洛谷链接 尽管标签是省选/NOI-,但提交的通过率已经高到三分之一了. 但它仍旧是一个省选/NOI-的题. 大致题意就是按输入的顺序走一棵树,看每个节点经过多少次.问题就相当于把一条链上的 ...
- CF651B-Beautiful Paintings
B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standa ...
- percona-toolkit工具安装
1.yum安装 yum install perl-TermReadKey.x86_64 yum install perl-IO-Socket-SSL yum install perl-DBI.x86_ ...
- 【POJ1149&BZOJ1280】PIGS(最大流)
题意:Emmy在一个养猪场工作.这个养猪场有M个锁着的猪圈,但Emmy并没有钥匙. 顾客会到养猪场来买猪,一个接着一个.每一位顾客都会有一些猪圈的钥匙,他们会将这些猪圈打开并买走固定数目的猪. 所有顾 ...
- 51nod1040 最大公约数之和
求$\sum_{i=1}^{n}(i,n)$.n<=1e9. $\sum_{i=1}^{n}(i,n)=\sum_{d|n}d\sum_{i=1}^{n}[(i,n)=d]=\sum_{d|n} ...
- THUWC2018 暴力+爆炸记
Day 0 没有Day0. Day 1 签到然后去宿舍,环境还行,比某偏远山区要强多了,不过这热水有点难拿??看RP有遇到煮好水的饮水机就拿,没有就苟矿泉水. 中午,那个餐还是挺好吃的,不过餐费40就 ...
- 大话数据结构——KMP算法(还存在问题)
http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm.html /*#include& ...
- hdu 4923 Room and Moor [ 找规律 + 单调栈 ]
传送门 Room and Moor Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Oth ...
- 深信服:Weblogic集群负载均衡技术解决方案
深信服应用交付产品替换集群中的Master节点,以双机模式部署接入,为Cluster 内的服务器提供应用交换服务,结合健康检查和业务特点,提供十几种负载均衡算法组合,满足多种生产环境下的业务需求. ...
- 【Nginx】Hello world程序
模块如何在运行中生效 配置文件中的location块决定了匹配某种URL的请求将会由相应的HTTP模块处理,因此,运行时HTTP框架会在接收完毕HTTP请求的头部后,将请求的URL与配置文件中的所有l ...