图像的方差和均值 [英] Variance and Mean of Image

查看:184
本文介绍了图像的方差和均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在计算原始图像和隐秘图像的均值和方差进行比较我正在使用灰度BMP图像作为同战犯

I am calculating mean and variance of my original and stego image to compare them I am using grayscale BMP image for comaprison

image=imread("image name")
M = mean(image(:))
V = var((image(:)))

这是在MATLAB中计算均值/变量的正确方法吗?我的差异越来越超出平均水平.

Is this is correct way fo calculating mean/var in MATLAB? My Variance is getting more than mean..

任何帮助表示赞赏.

推荐答案

这些确实是计算图像所有像素上的均值和方差的正确方法.

These are indeed the correct way to calculate the mean and variance over all the pixels of your image.

您的方差大于均值并非不可能,因为两者均按以下方式定义:

It is not impossible that your variance is larger than the mean as both are defined in the following way:

mean     = sum(x)/length(x)
variance = sum((x - mean(x)).^2)/(length(x) - 1);

例如,如果使用 randn(N,1)从标准正态分布生成噪声,则将获得 N 个样本,并计算均值和差异,您将获得大约 0 1 .因此,您的方差很可能大于均值.

For example, if you generate noise from a standard normal distribution with randn(N,1), you will get N samples, and if you calculate the mean and variance, you will get approximately 0 and 1. So there as well, your variance may well be larger than the mean.

两者的含义完全不同:均值使您可以知道像素的位置(即白色,黑色,50%灰色等).平均值将使您了解选择哪种像素颜色来汇总完整图像的颜色.方差可让您了解像素值如何扩展:例如如果您的平均像素值为50%灰度,那么其他大多数像素也都是50%灰度(较小方差)还是您有50个黑色像素和50个白色像素(较大方差)?因此,您也可以将其视为了解平均值的效果的一种方式(即方差为零,大多数信息均由平均值捕获).

Both have a totally different meaning: the mean gives you an idea where your pixels are (i.e. are they white, black, 50% gray, ...). The mean will give you an idea of what pixel color to choose to summarize the color of the complete image. The variance gives you an idea how the pixel values are spread: e.g. if your mean pixel value is 50% gray, are most of the other pixels also 50% gray (small variance) or do you have 50 black pixels and 50 white pixels (large variance)? So you could also view it as a way to get an idea how well the mean summarizes the image (i.e. with zero variance, most of the information is captured by the mean).

编辑:对于信号的RMS值(均方根),只需执行

edit: For the RMS value (Root Mean Square) of a signal, just do what the definition says. In most cases you want to remove the DC component (i.e. the mean) before calculating the RMS value.

我忘记提及的是:从物理角度比较方差的数值和均值也没有多大意义.平均值具有与数据相同的维度(以像素为单位,请考虑强度),而方差具有数据的平方(即强度^ 2).另一方面,标准差(在MATLAB中为 std )是方差的平方根,其维数与数据的维数相同,因此您可以进行一些比较(这是另一个问题,您是否应该做这样的比较.)

edit 2: What I forgot to mention was: it also makes little sense to compare the numerical value of the variance with the mean from a physical point of view. The mean has the same dimension as your data (in case of pixels, think of intensity), while the variance has the dimension of your data squared (so intensity^2). The standard deviation (std in MATLAB), which is the square root of the variance on the other hand has the same dimension as the data, so there you could make some comparisons (it is another question whether you should do such comparison).

这篇关于图像的方差和均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆