[iasobel] [Up] [iaotsu] | Image Filtering |
Computes the variance on the neighborhood of the pixel. The neighborhood is given by the set marked by the kernel elements.
def iavarfilter(f, h): from Numeric import asarray, Float64, sum, ravel, sqrt f = asarray(f).astype(Float64) f = f + 1e-320*(f == 0) # change zero by a very small number (prevent 'math range error') n = sum(ravel(h)) fm = iapconv(f, h) / n f2m = iapconv(f*f, h) / n g = sqrt(f2m - (fm*fm)) / fm return g
[iasobel] [Up] [iaotsu] | |