如何编辑单个像素?

时间:2019-10-11 21:18:20

标签: python

我决定只使用matplotlib.pyplot.imread方法给我的数组制作图像编辑程序,但是当我尝试将一个像素的内容分配给另一个像素时,它告诉我:{{1 }}。

can't assign to function call

2 个答案:

答案 0 :(得分:0)

f(xCount2, y1) = f(xSet, y1)
f(xCount2, y1) = f(xSet, y1)
f(xCount2, y1) = f(xSet, y1)
f(xCount2, y1) = f(xSet, y1)

要在f中设置字段,请使用f[xCount2, y1]。括号用于调用函数,方括号用于索引。

答案 1 :(得分:0)

将括号()更改为方括号[],方括号用于索引。这样的事情应该起作用:

for xCount in range(xCountStart, x1):
    xCount2 = (x1 + xCount) / 2
    xSet = xCount2
    for y1 in range(350, 360):
        for xCount2 in range(xSet, xCount):
            f[xCount2, y1] = f[xSet, y1]
            f[xCount2, y1] = f[xSet, y1]
            f[xCount2, y1] = f[xSet, y1]
            f[xCount2, y1] = f[xSet, y1]
        xCount2 = xSet
    y1 = 350 
    ...