# -*- coding: utf-8 -*-
"""
Created on Tue Aug 3 22:35:14 2021
@author: Wenqing Zhou (zhou.wenqing@qq.com)
@github: https://github.com/ouening
"""
import numpy as np
from numpy import cos,sin,exp,abs,ceil
import matplotlib.pyplot as plt
randn = np.random.randn
uniform = np.random.uniform
Img = np.random.randn(100,100)
# 参数设置
M = 2000
Lmax = 60
ps = 0.004
I = uniform(0,0.7)
pb = uniform(0,0.2)
pg = 10*uniform(0,1.0)
# 初始化角度
phi = uniform(0, np.pi)
v0 = cos(phi)+1j*sin(phi)
print(v0)
v = v0*Lmax/(M-1)
print(v)
# 初始化轨迹向量
x = np.array([complex(real=0, imag=0)] * M)
nextDir = None
canvas = 64
for t in range(M-1):
# 每次迭代
if np.random.uniform() < ps*pb:
nextDir = 2*v*exp(1j*(np.pi+(np.random.uniform()-0.5)))
# print('满足条件:',nextDir)
else:
nextDir = 0
dv = nextDir + ps * ( pg * (randn() + 1j*randn()) - I*x[t]) * (Lmax/(M-1))
# print(dv)
v = v+dv
v = (v/abs(v))*(Lmax/(M-1))
# print(v)
x[t+1] = x[t] + v
x += complex(real=-np.min(x.real), imag=-np.min(x.imag))
x = x - complex(real=x[0].real % 1., imag=x[0].imag % 1.) + complex(1, 1)
x += complex(real=ceil((canvas - max(x.real)) / 2), imag=ceil((canvas - max(x.imag)) / 2))
plt.plot(x.real, x.imag)
plt.show()
DeblurGANv1运动模糊核生成代码
最新推荐文章于 2025-03-03 10:09:58 发布