Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dwt(img):
- maskL = [0.02674875741080976, -0.01686411844287795, -0.07822326652898785, 0.2668641184428723, 0.6029490182363579, 0.2668641184428723, -0.07822326652898785, -0.01686411844287795, 0.02674875741080976]
- maskH = [0.09127176311424948, -0.05754352622849957, -0.5912717631142470, 1.115087052456994, -0.5912717631142470, -0.05754352622849957, 0.09127176311424948]
- height = img.shape[0]
- width = img.shape[1]
- bandL = zeros([height,width/2])
- bandH = zeros(bandL.shape)
- for r in range(0, height): #1D-DWT dla wierszy
- bandL[r,:] = convolve(img[r,:], maskL, mode='same')[::2]
- bandH[r,:] = convolve(img[r,:], maskH, mode='same')[::2]
- bandLL = zeros([height/2,width/2])
- bandLH = zeros(bandLL.shape)
- bandHL = zeros(bandLL.shape)
- bandHH = zeros(bandLL.shape)
- for c in range(0, width/2): #1D-DWT dla kolumn
- bandLL[:,c] = convolve(bandL[:,c], maskL, mode='same')[::2]
- bandLH[:,c] = convolve(bandL[:,c], maskH, mode='same')[::2]
- bandHL[:,c] = convolve(bandH[:,c], maskL, mode='same')[::2]
- bandHH[:,c] = convolve(bandH[:,c], maskH, mode='same')[::2]
- return clip(bandLL, 0.0, 1.0), bandLH, bandHL, bandHH
- bLL, bLH, bHL, bHH = dwt(testimg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement