def local_var(img, size=3):
 structure_element = np.ones((size, size), dtype=img.dtype)
 l_var = signal.correlate((img ** 2), structure_element, mode='same')
 l_var /= (size ** 2)
 l_var -= (local_mean(img, size=size) ** 2)
 return l_var

def local_var ( img , size = 3 ) : structure_element = np . ones ( ( size , size ) , dtype = img . dtype ) l_var = signal . correlate ( ( img ** 2 ) , structure_element , mode = 'same' ) l_var /= ( size ** 2 ) l_var -= ( local_mean ( img , size = size ) ** 2 ) return l_var
compute a image of the local variance .