By investigating the implemented code of an accepted paper, I encounter with following relation to estimate the variance of noise in an image:

$$ \sigma = \frac{median (|\nabla^hx-median(\nabla^hx)|)}{2*.6745},\tag{1}$$ where $\nabla^h$ compute horizontal derivative of $x$.

I know the variance of some samples can be estimated by $\frac{1}{n}\Sigma_{i=1}^n (x_i-\mu)^2$, but I cannot understand $(1)$ as well as the magic number $.6745$.

Any help will be appreciated.

  • 1
    $\begingroup$ I suspect the magic number is to make the Median Absolute Devian (MAD) the same as the std dev in the case of independent Gaussian noise. For other types of noise the two measurements won't be equal. $\endgroup$
    – David
    Aug 19, 2015 at 10:19

2 Answers 2


This method is called median absolute deviation (MAD). Unlike the version with mean, it is a robust estimator of the variance. For a univariate set $X$, MAD is defined as:

$MAD = median_{i} (| X_i-median_j(X_j) |)$.

This is typically thought as the median of the absolute values of the deviations from the median of the data. The variance is then robustly estimated as:

$\sigma= \kappa MAD(X)$, where $\kappa=1.4826$ is a scale factor. Note that your $0.6745=\frac{1}{1.4826}$ corresponds to such factor.

In your example, MAD of the gradients are utilized to estimate variance of the noise. It is a pretty standard procedure. For more on the topic, please refer here.

In MATLAB, you could simply compute this via the function mad.

  • $\begingroup$ What is the need for the scale factor? $\endgroup$ Jan 12, 2017 at 10:45

The reason why this method is used is well explained here:


See the derivation based on definition of median, and the inequality arising from it. The reason why that scale factor is present is due to the fact that you are estimating under the assumption that the noise contamination is Normally Distributed.

$ {\frac {1}{2}}=P(|X-\mu |\leq \operatorname {MAD} )=P\left(\left|{\frac {X-\mu }{\sigma }}\right|\leq {\frac {\operatorname {MAD} }{\sigma }}\right)=P\left(|Z|\leq {\frac {\operatorname {MAD} }{\sigma }}\right).$

Therefore, we must have that (using CDF definition) :

${\displaystyle \Phi \left(\operatorname {MAD} /\sigma \right)-\Phi \left(-\operatorname {MAD} /\sigma \right)=1/2}$

We have that, by property of Normal distribution,

$\Phi \left(-\operatorname {MAD} /\sigma \right)=1-\Phi \left(\operatorname {MAD} /\sigma \right)$

and hence, using the above equation, ${\displaystyle \operatorname {MAD} /\sigma =\Phi ^{-1}\left(3/4\right)=0.67449}$

With a different distribution, the scale factor changes accordingly, because the underlying Cumulative Distribution Function will yield a different value.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.