图像的均值、标准差、方差和偏度
means, std deviation, variance and skewness of image
此代码将图像拆分为较小的块,并查找这些块的平均值并将这些值写入文件。我还想计算方差和偏度。请帮助
for (int r = 0; r < img.rows; r += m)
for (int c = 0; c < img.cols; c += n)
{
Mat tile = img(Range(r, min(r + m, img.rows)),
Range(c, min(c + n, img.cols)));
Scalar MScalar,StdScalar;
meanStdDev(tile,MScalar,StdScalar);
cout<<"n Blue Channel Avg is "<<MScalar.val[0];
cout<<"n Green Channel Avg is "<<MScalar. val[1];
cout<<"n Red Channel Avg is "<<MScalar. val[2];
cout<<"nBlue channel std dev is "<<StdScalar.val[0];
cout<<"nGreen Channel std dev is "<<StdScalar. val[1];
cout<<"nRed Channel std dev is "<<StdScalar. val[2]<<"n";
int m[6] = { MScalar.val[0], MScalar.val[1], MScalar.val[2], StdScalar.val[0], StdScalar.val[1], StdScalar.val[2] };
Mat M = Mat(1, 6, CV_32S, m);
outdata<< M << "n";
cout<<M<<endl;
}
outdata<<endl;
}
}
waitKey();
return 0;
}
引用自:http://en.wikipedia.org/wiki/Standard_deviation
"换句话说标准差σ (sigma)是X方差的平方根"
意思是,如果你有标准偏差,你所需要做的就是std*std来得到方差。
偏度:http://en.wikipedia.org/wiki/Skewness
你可以从公式中看到,你需要做的是值减去平均值的和,然后除以std,所有这些的3次方。
色调通道的一个例子是:
float skewness;
for (int x = 0; x<channelHue.rows; x++) {
for (int y = 0; y<channelHue.cols; y++) {
skewness += pow(((channelHue.at<int>(x, y) - mean)/std), 3);
}
}
相关文章:
- 为什么是谷神星协方差.计算()似乎永远运行而不返回?
- 为什么需要返回指针来利用协方差?
- 标准库容器最简单、性能差的哈希类是什么?
- Eigen对修复非正定义的协方差矩阵有解吗
- 回调参数中的协方差C++
- 获取长双精度向量的方差
- 我在计算 4 个值的方差时的错误在哪里
- C++容器、协方差和模板
- 如何使用向量查找平均值和标准差
- "shared_ptr"如何实现协方差?
- C++协方差返回类型的缺点是什么
- 我遇到了一个关于多线程的小问题.需要多线程来计算 Pi 和方差
- 如何在犰狳中使用变量/方差函数
- 用c++计算平均值和方差
- 计算运行标准差
- c++中的加权方差和加权标准差
- 如何在C++或Java中计算方差、中值和标准差
- 在c++中使用Boost计算样本向量的均值和标准差
- C++使用std::accumulate计算不正确的标准差
- 图像的均值、标准差、方差和偏度