1 Star 0 Fork 0

愚乐于世/BM3D_cpp2py

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ht_filtering_hadamard.py 802 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ryan 提交于 2019-10-18 16:19 . add dct waiting for test
import numpy as np
from scipy.linalg import hadamard
import math
def ht_filtering_hadamard(group_3D, sigma, lambdaHard3D, doWeight): # group_3D shape=(n*n, nSx_r)
nSx_r = group_3D.shape[-1]
coef_norm = math.sqrt(nSx_r)
coef = 1.0 / nSx_r
group_3D_h = hadamard_transform(group_3D)
T = lambdaHard3D * sigma * coef_norm
T_3D = np.where(np.abs(group_3D_h) > T, 1, 0)
weight = np.sum(T_3D)
group_3D_h = np.where(np.abs(group_3D_h) > T, group_3D_h, 0.)
group_3D = hadamard_transform(group_3D_h)
group_3D *= coef
if doWeight:
weight = 1. / (sigma * sigma * weight) if weight > 0. else 1.
return group_3D, weight
def hadamard_transform(vec):
n = vec.shape[-1]
h_mat = hadamard(n).astype(np.float64)
v_h = vec @ h_mat
return v_h
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ylyslzx/BM3D_cpp2py.git
git@gitee.com:ylyslzx/BM3D_cpp2py.git
ylyslzx
BM3D_cpp2py
BM3D_cpp2py
master

搜索帮助