# HSV Histogram or just SV? [closed]

Hello I have an image as in the picture, which only I care on the whiteness-greyness-black. The other Hue I don't really don't care. OpenCV uses H: 0 - 180, S: 0 - 255, V: 0 - 255

I just want to get the average value for S and V in the picture. The example that I got from the internet is only HS. Or maybe I have wrongly search again. If there any advice that I can get?

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by sturkmen close date 2020-09-28 12:14:59.436172

1

if you're only interested in the average values, you don't even need a histogram calcutation.

just convert to HSV, and call meanStdDev() . mean[1] will be average S, mean[2] average V.

( 2015-11-04 03:38:22 -0500 )edit

@berak, this is what I got from the meanStdDev() code.

mean1[3.31882, 0.558971, 125.862, 0] stdev1[14.8365, 1.81434, 6.38802, 0]

Is it true that mean[1] = 0.558971 (average S) nearly to dark mean[2] = 125.862 (average V) halves of the value?

a bit confuse here

the purpose of this work (maybe I'm wrong) is because I want to filter white-bright component on the image and by using HSV I can use inRange, the problem is every images will have a different threshold value for the inRange of HSV which requires me to find the good thresholding values.

( 2015-11-04 05:35:04 -0500 )edit
2

If you have a grayscale image as the one you posted, why are you using HSV color space? You already have values between 0 and 255 describing "brightness". And if your input images are in color, it seems much easier to convert them to YUV color space and filter based on Y channel (luminance).

( 2015-11-04 06:51:21 -0500 )edit

@LorenaGdL@berak, after some learning by myself, I think I posted the wrong pic. So I updated the new pic which consist of nearly white and grey. This image is in RGB. I don't want to convert to Grayscale due to few information might be missing so I'm planning to threshold based on the white color. From the image about, by converting RGB to HSV, I can filter up by using this statement. cvtColor(frame, frame_gray, CV_BGR2HSV); inRange(frame_gray, Scalar(0, 0, 190), Scalar(179, 50, 255), frame_gray);

The question comes back to me again, how could I get the average values if let say I have around 1000 nearly the same pictures which having noise or illumination issue but yet still can see the difference of white and grey. Will the histogram work? is there any SV histogram? to get the value

( 2015-11-17 04:09:10 -0500 )edit
3

zms, this won't go anywhere, unless you point out , what you're trying to achieve.

( 2015-11-17 04:17:29 -0500 )edit

@berak, sorry for confusing anyone. This is for road lane tracking. I'm trying to thresholding the white area from the grey area. The image capture in RGB. Sometimes there are other colours on the image also, so if I change the RGB to GreyScale, it would be a problem while thresholding it since the value might be like the white color greyscale value. That's why my intention is to filter the white image in HSV.

So majority colour is grey and white. I'm converting to HSV and filter by using range inRange(frame_gray, Scalar(0, 0, 190), Scalar(179, 50, 255), frame_gray);

that value is trial and error. :( So I tried to have more images and find out the S and V average value so I can use for the inRange statement. That's why I'm thinking histogram. Maybe I'm wrong but not sure.

( 2015-11-17 21:43:35 -0500 )edit