How to calculate StdDev for RGB image? [closed]

asked 2017-11-09 02:32:55 -0600

Andriezel gravatar image

updated 2017-11-09 03:35:23 -0600


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: image description 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: image description

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

edit retag flag offensive 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.

LBerger gravatar imageLBerger ( 2017-11-09 03:11:00 -0600 )edit

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

Andriezel gravatar imageAndriezel ( 2017-11-09 03:36:53 -0600 )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

LBerger gravatar imageLBerger ( 2017-11-09 04:00:06 -0600 )edit

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

Andriezel gravatar imageAndriezel ( 2017-11-09 06:08:10 -0600 )edit