# How can i get mean and standard deviation of V component of HSV histogram?

22 views (last 30 days)
Fahad Mairaj on 27 Mar 2018
Commented: Walter Roberson on 3 Apr 2018
I have given a task to extract the value of the mean and standard deviation of V or I component from HSV or HSI histogram.
Can anyone help me out?
this is what I am going to do.
convert RGB image into HSV take histogram of that hsv image. then take out value of mean and standard deviation from that hsv histogram.
PLEASE GUIDE IF THESE STEPS ARE GOING TO WORK. THANKS

Fahad Mairaj on 3 Apr 2018
Thanks alot sir. Tht was helpful.
I need a another help that
I have to get the mean and standard deviation values of H S V of 30 images at least. I was getting those values individually which gets me keep writing n storing values in variable.
What i am doing is:
1. Convert image to hsv
2. Get H S V values.
3. Then get mean values of H S V components.
Like
meanV=mean2(V)
meanH=mean2(H)
And go on...
I have 30 images to get these value. Should I go for it just as i am doing?
Or Is there any easier way?
Walter Roberson on 3 Apr 2018

Abhishek Ballaney on 28 Mar 2018
https://in.mathworks.com/help/matlab/ref/mean.html
https://in.mathworks.com/help/matlab/ref/std.html

Walter Roberson on 28 Mar 2018
means and standard deviations of hsv histograms are not typically all that meaningful. What question would such a measurement be trying to answer??
Suppose you take
data = rand(1000,1000,3);
rgb = hsv2rgb(data);
subplot(1,3,1)
histogram(reshape(rgb(:,:,1),[],1),25)
subplot(1,3,2)
histogram(reshape(rgb(:,:,1),[],2),25)
subplot(1,3,3)
histogram(reshape(rgb(:,:,1),[],3),25)
That is, we generate uniform data in hsv space, such as would be needed for it to be reasonable that a histogram of the v component would be more or less equally distributed randomly. We convert the uniform data into hsv space, and then look at the red, green, and blue histograms of the rgb data. We can see that most of the data is towards the left edge for all three components.
Thus, in order to expect uniform v component you need to be starting with rgb that tends towards the darker.
If you take that same data and do
hsv = rgb2hsv(data);
and plot the third component, you can see that it is biased towards high value, so rgb that is uniformly random is mostly towards the high value. (Uniform random rgb data is bell curve in brightness, by the way.)
I ran through all of the color demonstration images provided with the image processing toolbox. The one with the smallest standard deviation was onion.png -- which has a small deviation mostly because it is one of the smallest of the images. eSFRTestImage.jpg has the largest standard deviation -- mostly because it is one of the largest images.