def estimate_sigma(im, average_sigmas=False, multichannel=False):
 if multichannel:
  nchannels = im.shape[(-1)]
  sigmas = [estimate_sigma(im[..., c], multichannel=False) for c in range(nchannels)]
  if average_sigmas:
   sigmas = np.mean(sigmas)
  return sigmas
 elif (im.shape[(-1)] <= 4):
  msg = 'image is size {0} on the last axis, but multichannel is False.  If this is a color image, please set multichannel to True for proper noise estimation.'
  warn(msg.format(im.shape[(-1)]))
 coeffs = pywt.dwtn(im, wavelet='db2')
 detail_coeffs = coeffs[('d' * im.ndim)]
 return _sigma_est_dwt(detail_coeffs, distribution='Gaussian')

def estimate_sigma ( im , average_sigmas = False , multichannel = False ) : if multichannel : nchannels = im . shape [ ( - 1 ) ] sigmas = [ estimate_sigma ( im [ ... , c ] , multichannel = False ) for c in range ( nchannels ) ] if average_sigmas : sigmas = np . mean ( sigmas ) return sigmas elif ( im . shape [ ( - 1 ) ] <= 4 ) : msg = 'image is size {0} on the last axis, but multichannel is False.  If this is a color image, please set multichannel to True for proper noise estimation.' warn ( msg . format ( im . shape [ ( - 1 ) ] ) ) coeffs = pywt . dwtn ( im , wavelet = 'db2' ) detail_coeffs = coeffs [ ( 'd' * im . ndim ) ] return _sigma_est_dwt ( detail_coeffs , distribution = 'Gaussian' )
robust wavelet-based estimator of the noise standard deviation .