加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wiener_filtering_hadamard.py 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
Shuai_Yan 提交于 2020-04-16 17:41 . Added some notes
import numpy as np
from scipy.linalg import hadamard
def wiener_filtering_hadamard(group_3D_img, group_3D_est, sigma, doWeight):
"""
:wiener_filtering after hadamard transform
:param group_3D_img:
:param group_3D_est:
:param sigma:
:param doWeight:
:return:
"""
assert group_3D_img.shape == group_3D_est.shape
nSx_r = group_3D_img.shape[-1]
coef = 1.0 / nSx_r
group_3D_img_h = hadamard_transform(group_3D_img) # along nSx_r axis
group_3D_est_h = hadamard_transform(group_3D_est)
# wiener filtering in this block
value = np.power(group_3D_est_h, 2) * coef
value /= (value + sigma * sigma)
group_3D_est_h = group_3D_img_h * value * coef
weight = np.sum(value)
group_3D_est = hadamard_transform(group_3D_est_h)
if doWeight:
weight = 1. / (sigma * sigma * weight) if weight > 0. else 1.
return group_3D_est, weight
def hadamard_transform(vec):
n = vec.shape[-1]
h_mat = hadamard(n).astype(np.float64)
v_h = vec @ h_mat
return v_h
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化