简体   繁体   English

将图像转换为灰度 python

[英]Converting image to grayscale python

Can anyone help with the code to go after for loop to convert to grayscale either by average method or weighted method任何人都可以在for循环之后通过平均方法或加权方法将代码转换为go

import matplotlib.pyplot
import numpy


myImage = matplotlib.pyplot.imread('flower.png')

height=myImage.shape[0]
width=myImage.shape[1]

for x in range(0, height-1):
    for y in range(0,width-1):

      INSET CODE HERE


imgplot = matplotlib.pyplot.imshow(myImage)
matplotlib.pyplot.show()

There's already been a post about this - you can either use PIL easily or create it yourself with Numpy and Matplotlib.已经有一篇关于此的帖子- 您可以轻松使用 PIL,也可以使用 Numpy 和 Matplotlib 自己创建它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM