Noisy tint in OpenCV

this question is about opencv with c ++ in VS2008 expression.

I make it very simple. Trying to get skin values ​​from camera image.

As you can see in the screenshot, the camera image looks good. I convert it to HSV and separate the Hue channel from this in order to later generate the skin value. But the Hue channel seems too noisy and grainy. Also, the HSV image window shows information degradation. Why is this happening? and how to solve it. If we can’t remove the noise with some kind of smoothing? The code is as follows:

#include <opencv2/opencv.hpp> int main(){ cv::VideoCapture cap(0); // open the default camera cv::Mat hsv, bgr, skin;//make image & skin container cap >> bgr; //cvNamedWindow("Image"); //cvNamedWindow("Skin"); //cvNamedWindow("Hue"); cv::cvtColor(bgr, hsv, CV_BGR2HSV); std::vector<cv::Mat> channels; cv::split(hsv, channels); cv::Mat hue; hue = channels[0]; cv::imshow("Image", bgr);cvMoveWindow("Image",0,0); cv::imshow("HSV", hsv);cvMoveWindow("HSV",660,0); cv::imshow("Hue", hue);cvMoveWindow("Hue",0,460); cvWaitKey(0);//wait for key press return 0; } 

enter image description here

+4
source share
2 answers

The Hue channel seems too noisy and grainy. Why is this happening?

In real colors, we see that part of the information represented by the “shade” is changing. The color red is fully described by the hue. Black color has no color information.

However, when the color is presented in HSV, as you did, the hue always accounts for one third of the color information .

Since the colors are suitable for any shade of gray, the shade component will be artificially high. This is the grain that you see. The closer to gray, the more the hue should be enhanced, including the error in the captured hue.

The HSV image window also shows degradation of information. Why is this happening?

There will be rounding errors in the conversion, but this is probably not as many as you think. Try converting the HSV image back to BGR to see how much degradation has occurred.

& how to solve it.

Actually, you have two options.

Use a higher quality camera or do not use the HSV format.

+6
source

If you look at the formulas in the OpenCV documentation for the cvtColor function with the CV_BGR2HSV parameter, you will have

enter image description here

enter image description here

enter image description here

Now that you have a shade of gray, i.e. when R is B and R is G, the fraction in the formula H is always undefined, since it is zero divided by zero. It seems to me that the documentation does not describe what happens in this case.

0
source

All Articles