TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'
<p>I try to use Moravec detection. When I try to run this code I get some error:</p>

<pre><code>     diff = diff - image.getpixel((x, y))
TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'
</code></pre>

<p>How can I fix it? Any help will be appreciated. The code is:</p>

<pre><code>def moravec(image, threshold = 100):
    """Moravec's corner detection for each pixel of the image."""

    corners = []
    xy_shifts = [(1, 0), (1, 1), (0, 1), (-1, 1)]

    for y in range(1, image.size[1]-1):
        for x in range(1, image.size[0]-1):
            # Look for local maxima in min(E) above threshold:
            E = 100000
            for shift in xy_shifts:
                diff = image.getpixel((x + shift[0], y + shift[1]))
                diff = diff - image.getpixel((x, y))
                diff = diff * diff
                if diff &lt; E:
                    E = diff
            if E &gt; threshold:
                corners.append((x, y))

    return corners

if __name__ == "__main__":
        threshold = 100

        image = Image.open('all.jpg')
        corners = moravec(image, threshold)
        draw_corners(image, corners)
        image.save('low2.png')
</code></pre>