博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 图像处理,画一个正弦函数
阅读量:4357 次
发布时间:2019-06-07

本文共 533 字,大约阅读时间需要 1 分钟。

import numpy as npfrom PIL import Imageimport matplotlib.pyplot as pltimport mathsize = 300new_im = Image.new("RGBA",(size,size)) #创建一个空的图片a_img = np.array(new_im)  #获取空图片的数据m = (size-50)/2 #函数的摆幅for i in range(0,size):    x = 2 * math.pi * (  i / size )  #控制 根据 i / size 的比例,控制 x 的值为  0-2π    y = size/2 - m*math.sin(x)  #将正弦函数画在中间    y = int(y)    if y < size and y >= 0:        a_img[y][i] = (0,0,0,255)   plt.figure("beauty")plt.imshow(a_img)#plt.axis('off')plt.show()

  

效果为:

 

转载于:https://www.cnblogs.com/muamaker/p/10761913.html

你可能感兴趣的文章
HDU 2188------巴什博弈
查看>>
tp5任务队列使用supervisor常驻进程
查看>>
Xmind?
查看>>
spring+quartz 实现定时任务三
查看>>
day2-三级菜单
查看>>
linux下升级4.5.1版本gcc
查看>>
Beanutils
查看>>
FastJson
查看>>
excel4j
查看>>
Thread
查看>>
char * 与char []探究理解
查看>>
QT窗体显示在屏幕中间位置
查看>>
emmet使用技巧
查看>>
RPC-Thrift(二)
查看>>
MSSQL for Linux 安装指南
查看>>
【Golang 接口自动化08】使用标准库httptest完成HTTP请求的Mock测试
查看>>
洛谷 P1036 选数
查看>>
女性社区TOP10
查看>>
BP神经网络算法推导及代码实现笔记zz
查看>>
前端必读:浏览器内部工作原理
查看>>