灰度图像的显示"/>
python的meshgrid的用法及灰度图像的显示
背景:
meshgrid可以代替数组的双重遍历,下面展示meshgrid进行画图,主要是将三维平面z=sin((x^2-y^2)^2+x*y)投影到xy平面,用z值作为各点的值。软件:
python3.5代码:
import numpy as np import matplotlib.pyplot as pltpoint = np.arange(-5,5,.1) x,y = np.meshgrid(point,point)z = np.sin((x**2-y**2)**2 + x*y)plt.imshow(z,cmap = plt.cm.gray) #灰度显示,越小越黑 plt.title("Image plot of $\sin((x^2 - y^2)^2 + x*y)$ for a grid of values") plt.show()
结果:
更多推荐
python的meshgrid的用法及灰度图像的显示
发布评论