Skip to content

Instantly share code, notes, and snippets.

@suhaskv
Created December 23, 2020 11:43
Show Gist options
  • Save suhaskv/ff1888d5d929841a305ac022acf95623 to your computer and use it in GitHub Desktop.
Save suhaskv/ff1888d5d929841a305ac022acf95623 to your computer and use it in GitHub Desktop.
VSB Power Line Blog - Perform hard-thresholding on the 1st level detail coefficients
# Calculate the sigma value
sigma = (1/0.6745) * np.mean(np.absolute(wavlt_coeffs[-1] - np.mean(wavlt_coeffs[-1],None)), None)
# Calculate the universal threshold using Stein Unbiased Risk Estimate (SURE)
Td = sigma * np.sqrt(2*np.log(len(x)))
# Perform hard-thresholding on the 1st level detail coefficient values
wavlt_coeffs[1:] = (pywt.threshold(i, value=Td, mode='hard') for i in wavlt_coeffs[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment