Calculates the variance of an image
variance_matrix = imvariance(image)
This function computes a matrix containing the variance of each point of an image.
The variance is the sum of the absolute value of the differences between the central pixel and its neighbours:
variance=sum(|x(neighbour)-x(central)|)
A low variance value means a pixel is not very different from its neigbours (in all directions).
This property can be used to unwrap phased images. In case of a "path-following algorithm", the variance can be a "merit function" used to determine which pixels should be connected first. This "merit function" is much more noise immune than a "merit function" based on a laplace kernel.
This algorithm calculates the variance everywhere even on the edges. In some cases, consider multiplying by a mask like this
so that edge values are really significative.
http://siptoolbox.sourceforge.net