仅在RGB或HSV图像(Matlab)中增加黄色饱和度 [英] Increase Yellow Saturation only in RGB or HSV Image (Matlab)

查看:3179
本文介绍了仅在RGB或HSV图像(Matlab)中增加黄色饱和度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图片。我想选择性地增加图像中的黄色的饱和度到最大。在RGB或HSV图像空间中如何做到这一点?谢谢。

解决方案

这需要在HSV(色相饱和度值)颜色空间中完成。



如果你有HSV的图像,这是很容易(否则将其转换为HSV)。 H是提供颜色信息的唯一变量,如果您检查



黄色像素





饱和



a href =https://i.stack.imgur.com/p6qck.jpg =nofollow noreferrer>


I have an image. I want to selectively increase the saturation of yellow in the image to max. How is this done in the RGB or HSV image space? Thanks.

解决方案

This needs to be done in HSV (Hue Saturation Value) color space.

If you have the image in HSV, it is very easy (else convert it to HSV). The H is the only variable that gives color information, and if you check the wikipedia page of Shades of Yellow, you'll notice they are all are between 45 to 60 deg. So take you HSV image, select the H in that range and increase the S (saturation) of those values.

In Matlab:

%Read image
imghsv=imread('http://7-themes.com/data_images/out/34/6884934-yellow-flowers.jpg');
imghsv=rgb2hsv(im2double(imghsv));

%pick yellow
yellowIndex=repmat((imghsv(:,:,1)>45/360)&(imghsv(:,:,1)<60/360),[1 1 3]);   
yellow=imghsv.*yellowIndex;

%Saturate it
moreSaturation=2;
yellowsaturated=yellow(:,:,2)*moreSaturation;
yellow(:,:,2)=yellowsaturated;

%put it back
newHsv=imghsv; 
newHsv(yellowIndex)=yellow(yellowIndex);

result:

Original

Yellow pixels

Saturated

这篇关于仅在RGB或HSV图像(Matlab)中增加黄色饱和度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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