Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在我的代码中遇到错误,但我无法确定原因。(getpixel()接受2个位置参数,但给出了3个)_Python_Typeerror_Pillow - Fatal编程技术网

Python 在我的代码中遇到错误,但我无法确定原因。(getpixel()接受2个位置参数,但给出了3个)

Python 在我的代码中遇到错误,但我无法确定原因。(getpixel()接受2个位置参数,但给出了3个),python,typeerror,pillow,Python,Typeerror,Pillow,我正在为一个项目编程,这样我就可以很容易地确定我要为网站填充多少像素的图像。但是,我遇到了这个错误:getpixel()接受2个位置参数,但给出了3个。 我的代码如下: from PIL import Image import PIL.ImageOps background = Image.open("background.png") target = input("Please enter the name of your image (including file type)") tar

我正在为一个项目编程,这样我就可以很容易地确定我要为网站填充多少像素的图像。但是,我遇到了这个错误:getpixel()接受2个位置参数,但给出了3个。 我的代码如下:

from PIL import Image
import PIL.ImageOps


background = Image.open("background.png")
target = input("Please enter the name of your image (including file type)")
targetImage = Image.open(target)
area = targetImage.size
targetColouredCoords = []


newArea = (area[0] + 1, area[1] + 1)
borderedTarget = PIL.ImageOps.expand(targetImage, border=10, fill="black")
targetValues = list(borderedTarget.getdata())


def analyser():
    pixelOne = 1
    pixelTwo = 1
    completedSearch = 0
    currentPixel = borderedTarget.getpixel(pixelOne, pixelTwo)

    def colourChecker():
        if currentPixel != (0, 0, 0):
            targetColouredCoords.append((pixelOne, pixelTwo))

    while completedSearch != len(targetValues):
        while pixelOne != newArea[0]:
            while pixelTwo != newArea[1]:
                colourChecker()
                pixelTwo += 1
                completedSearch += 1
            pixelTwo = 1
            pixelOne += 1


analyser()

我在整个代码中提供3个参数的唯一一行是18,但我不理解这行代码是如何不正确的,或者突出显示为问题的代码(第26行)是如何不正确的。在删除错误之前,我无法继续编写代码,因此非常感谢您的帮助

再次查看,输入必须是一个元组:

getpixel((像素一、像素二))