Estimating the Variance of Noise Using Median Function Applies on the Gradient of the Image
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.