filters.py 488 B

12345678910111213141516171819202122
  1. import cv2, pywt
  2. import numpy as np
  3. from scipy.signal import medfilt2d, wiener, cwt
  4. def w2d(arr, mode='haar', level=1):
  5. #convert to float
  6. imArray = arr
  7. imArray /= 255
  8. # compute coefficients
  9. coeffs=pywt.wavedec2(imArray, mode, level=level)
  10. #Process Coefficients
  11. coeffs_H=list(coeffs)
  12. coeffs_H[0] *= 0
  13. # reconstruction
  14. imArray_H = pywt.waverec2(coeffs_H, mode);
  15. imArray_H *= 255
  16. imArray_H = np.uint8(imArray_H)
  17. return imArray_H