# How to calculate StdDev for RGB image? [closed]

Hello,

I'm trying to get the mean and standard deviation on a RGB image. I have used the example code and I have this:

cv::Mat image = cv::imread("C:/stddev.jpg");

cv::Scalar mean, stddev; //0:1st channel, 1:2nd channel and 2:3rd channel

meanStdDev(image, mean, stddev, cv::Mat());
std::cout << "Standard deviation channel B,G,R: " << stddev << std::endl;
std::cout << "Mean B,G,R: " << mean << std::endl;


I have used this picture: And this is my output:

Standard deviation channel B,G,R: [0,0,0,0] Mean B,G,R: [1, 103, 168, 0]

In Adobe Photoshop it gives me the same values for each seperate channel but when I select RGB (So for all channels I suppose) it gives me a standard deviation of 69.17 and a mean of 90.33:

So how do I get those numbers instead of each channel in OpenCV?

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Andriezel close date 2017-11-09 06:08:38.059354

I don't know photoshop but opencv give you a good result.

( 2017-11-09 03:11:00 -0500 )edit

@LBerger That's the whole thing. I want to get the same results in my OpenCV program..

( 2017-11-09 03:36:53 -0500 )edit

Again your question is about photoshop (off topic) and not opencv. We must guess what is in your photoshop window. I see histogram may be 90.33 is the mean value of image luminance

( 2017-11-09 04:00:06 -0500 )edit

I think you misunderstood my question. I already found the answer so I close this one.

( 2017-11-09 06:08:10 -0500 )edit