如何使用opencv设置某个像素的色调值 [英] how to set hue value of some pixel with opencv
本文介绍了如何使用opencv设置某个像素的色调值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要更改图像某些像素的色调,但我不知道如何设置它们!
I need to change the hue of some pixels of my image, but i don't know how to set them!
我用 CV_BGR2HSV
转换了 HSV 中的图像,现在我用 for by rows 和 cols 循环......
I converted the image in HSV with CV_BGR2HSV
and now i'm cycling with a for by rows and cols...
如何访问每个像素的色调?
how can I access each pixel's hue?
用于设置 RGB 我正在使用此代码...
for setting RGB i'm using this code...
CvScalar s;
s=cvGet2D(imgRGB,i,j); // get the (i,j) pixel value
printf("B=%f, G=%f, R=%f\n",s.val[0],s.val[1],s.val[2]);
s.val[0]=240;
s.val[1]=100;
s.val[2]=100;
cvSet2D(imgRGB,i,j,s); // set the (i,j) pixel value
推荐答案
您已经将图像转换为 HSV,因此图像的 3 层现在对应于色相、饱和度和值:
You already converted your image to HSV, so the 3 layers of the image now correspond to Hue, Saturation and Value:
s.val[0]
是色调.s.val[1]
是饱和度.s.val[2]
是值.
s.val[0]
is the hue.s.val[1]
is the saturation.s.val[2]
is the value.
所以继续使用与 RGB 图像完全相同的方法来获取和设置像素值.
So go ahead and use exactly the same method as for your RGB images to get and set the pixel values.
这篇关于如何使用opencv设置某个像素的色调值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文