猫史档案馆


【Python作品分享】新的作品-60【作品秀】

用户:三体_梦Cheney三体_梦Cheney查看:0 回复:0 评论:0 创建时间:2021-12-05T13:24:29


【作品展示】

center_image

 

【作品介绍】

 

【作品源代码】

from PIL import Image
import matplotlib.pyplot as plt

img = Image.open("bcm.jpg")
width,height = img.size

# 获取像素
pixel = img.getpixel((100,100))
print(pixel)

# 修改像素值
for i in range (width):
    img.putpixel((i,100),(0,0,255))

# 转灰度图
img_gray = img.convert('L')

# 显示图片
plt.rcParams["image.cmap"] = "gray"
plt.imshow(img_gray)
# 显示网格
plt.grid()
plt.show()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页