I have an image converted to a ndarray with RGBA values. Suppose it's 50 x 50 x 4.
I want to replace all the pixels with values array([255, 255, 255, 255]) for array([0, 0, 0, 0]). So:
from numpy import * from PIL import Image def test(mask): mask = array(mask) find = array([255, 255, 255, 255]) replace = array([0, 0, 0, 0]) return putmask(mask, mask != find, replace) mask = Image.open('test.png') test(mask) What am I doing wrong? That gives me a ValueError: putmask: mask and data must be the same size. Yet if I change the arrays to numbers (find = 255, replace = 0) it works.