【发布时间】:2020-03-01 00:55:11
【问题描述】:
我使用库FyeldGenerator 生成两个高斯随机场。如果它们被绘制出来,是这样的:
from FyeldGenerator import generate_field
import matplotlib.pyplot as plt
import numpy as np
# Helper that generates power-law power spectrum
def Pkgen(n):
def Pk(k):
return np.power(k, -n)
return Pk
# Draw samples from a normal distribution
def distrib(shape):
a = np.random.normal(loc=0, scale=1, size=shape)
b = np.random.normal(loc=0, scale=1, size=shape)
return a + 1j * b
shape = (512, 512)
field_x = generate_field(distrib, Pkgen(3), shape)
field_y = generate_field(distrib, Pkgen(3), shape)
plt.imshow(field_x, cmap='seismic')
plt.show()
plt.imshow(field_y, cmap='seismic')
然后我用 matplotlib 和quiver 绘制向量场。
现在我想将随机场大小相同的图像应用于矢量场。我希望点 (i,j) 中的像素沿方向(二维)移动,这在 quiver 函数中显示。有什么办法吗?
这是在 matlab 上完成的这个问题的一个例子,但在 3D 中:
stackoverflow 的链接:Applying a vector field to image in matlab
【问题讨论】:
标签: python matlab opencv matplotlib computer-vision