TypeError: an integer is required (got type tuple)

Another possible reason for this misleading error message is if the img is a view into np.ndarray, not contiguous memory data. So e.g. if your code worked with img, it will fail if you do something like img=np.flipud(img).

The solution is to make deep copy, like img=np.flipud(img).copy().


In my experience the error statement was misleading. In my case, the coordinates (x, y) were in float instead of int and fixing that fixed this issue.