图像颜色饱和度 [英] Image color saturation

查看:266
本文介绍了图像颜色饱和度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一个饱和的功能形式,但没有找到任何东西。它不是那么难,但我所有的猜测都看起来不太正确(朝向去饱和的方向似乎更容易)。

I was trying to find a functional form for saturation but didn't find anything. It can't be that hard but all my guesses don't look quite right (the direction towards desaturation seems easier).

我有RGB格式的图像像素数据。最终图像也应采用RGB格式。那么,这些函数是如何定义的:

I have the pixel data of the image in RGB format. The final image should also be in RGB format. So, how are these functions defined:

r_n = saturation_r(r,g,b,sat);
g_n = saturation_g(r,g,b,sat);
b_n = saturation_b(r,g,b,sat); 


推荐答案

将RGB像素转换为HLS,按比例缩放S你的 sat 输入,然后转换回RGB。假码,假设所有颜色分量都在0.0到1.0范围内:

Convert the RGB pixel to HLS, scale the S by your sat input, then convert back to RGB. Pseudo-code, assuming all color components are in the range 0.0 to 1.0:

rgb_to_hls(r, g, b, h, l, s);
s = s * sat
hls_to_rgb(h, l, s, r, g, b);
return r, g, b

如果您需要RGB / HLS转换功能,这里是

If you need RGB/HLS conversion functions, here they are.

这篇关于图像颜色饱和度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆