(5)彩色图像去饱和
2015-07-02 14:21
696 查看
去饱和是指在RGB图像中以连续的方式统一消减颜色量。通过将每一个RGB像素替换为一个去饱和的颜色(Rd, Gd, Bd)来实现,其中(Rd, Gd, Bd)是在RGB空间通过在像素的原始颜色和相应的灰度点(Y, Y, Y)之间进行线性插值求得。即:
(Rd, Gd, Bd) = (Y, Y, Y)+ (R - Y, G - Y, B - Y)* s
系数s的取值区间为[0, 1],s取0时,为灰度图像,s取1时,为原图。
代码实现如下:
参数mParameter取100和50的饱和度图如下:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202012/15/c1b575e4a8406379d89f1cad81bcf3ff)
(Rd, Gd, Bd) = (Y, Y, Y)+ (R - Y, G - Y, B - Y)* s
系数s的取值区间为[0, 1],s取0时,为灰度图像,s取1时,为原图。
代码实现如下:
public int getNewColor(int color){ int r = (color >> 16) & 0xFF; int g = (color >> 8) & 0xFF; int b = color & 0xFF; int gray = (int)((r*0.3)+(b*0.59)+(g*0.11)); int newR = saturation(r, gray); int newG = saturation(g, gray); int newB = saturation(b, gray); return (255 << 24) + (newR << 16) + (newG << 8) + newB; } private int saturation(int rgb, int gray){ return gray + (rgb - gray) * (mParameter) / 100; }
参数mParameter取100和50的饱和度图如下:
相关文章推荐
- 流式大数据处理的三种框架:Storm,Spark和Samza
- UVa - 100 - The 3n + 1 problem
- 字符串查找算法:bm算法
- UVa - 100 - The 3n + 1 problem
- Sample Code地址
- 斜坡光照阴影算法
- Linux下新手如何将VIM配置成C++编程环境(可以STL自动补全)
- [Leetcode]-Merge Two Sorted Lists
- Web开发之环境搭建
- Unity里面三角面数
- if条件综合shell一键安装LAMP
- 判断一个点是否在view上
- php 加密 解密 方法
- ContentObserver 介绍
- Cloudfoundry之Service
- JPush推送 之 RegistrationID 精确对点推送
- 【Android基础篇】TabWidget设置背景和字体
- 配置Odroid ubunutu 静态IP 并让PC 使用Ccproxy 做代理上网
- SecureCRT快捷键
- 实时操作系统与非实时操作系统到底有什么区别?