Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. def dwt(img):
  2.     maskL = [0.02674875741080976, -0.01686411844287795, -0.07822326652898785, 0.2668641184428723, 0.6029490182363579, 0.2668641184428723, -0.07822326652898785, -0.01686411844287795, 0.02674875741080976]
  3.     maskH = [0.09127176311424948, -0.05754352622849957, -0.5912717631142470, 1.115087052456994, -0.5912717631142470, -0.05754352622849957, 0.09127176311424948]
  4.     height = img.shape[0]
  5.     width = img.shape[1]
  6.     bandL = zeros([height,width/2])
  7.     bandH = zeros(bandL.shape)
  8.     for r in range(0, height): #1D-DWT dla wierszy
  9.         bandL[r,:] = convolve(img[r,:], maskL, mode='same')[::2]
  10.         bandH[r,:] = convolve(img[r,:], maskH, mode='same')[::2]
  11.     bandLL = zeros([height/2,width/2])
  12.     bandLH = zeros(bandLL.shape)
  13.     bandHL = zeros(bandLL.shape)
  14.     bandHH = zeros(bandLL.shape)
  15.     for c in range(0, width/2): #1D-DWT dla kolumn
  16.         bandLL[:,c] = convolve(bandL[:,c], maskL, mode='same')[::2]
  17.         bandLH[:,c] = convolve(bandL[:,c], maskH, mode='same')[::2]
  18.         bandHL[:,c] = convolve(bandH[:,c], maskL, mode='same')[::2]
  19.         bandHH[:,c] = convolve(bandH[:,c], maskH, mode='same')[::2]
  20.     return clip(bandLL, 0.0, 1.0), bandLH, bandHL, bandHH
  21.  
  22. bLL, bLH, bHL, bHH = dwt(testimg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement