from PIL import Image

#This is the pixel function:
def pix_manipulate(pic):
    (r,g,b) = pic
    if r != 0 and g != 0 and b == 0:
        r = 0
        g = 0
    return r,g,b

def y_block(pic,pix_func):
    c = pic.copy()
    w,h = c.size
    for width in range(w):
        for height in range(h):
            pix = c.getpixel((width, height))
            np = pix_func(pix)
            c.putpixel((width, height), np)
    return c



def y_pix(pix):
    (r,g,b) = pix
    if not (r != 0 and g != 0 and b == 0):
        r = 0
        g = 0
        b = 0
    return (r,g,b)

def y_pass(picture,pixelfunc):
    cp = picture.copy()
    w,h = cp.size
    for width in range(w):
        for height in range(h):
            pix = cp.getpixel((width,height))
            np = pixelfunc(pix)
            cp.putpixel((width,height),np)
    return cp

p = Image.open("yellow.jpg")
newim = y_block(p,pix_manipulate)
newim.show()
newim.save("Yellow block.jpg")

yellowpass = y_pass(p,y_pix)
yellowpass.show()
yellowpass.save("Yellow pass.jpg")


            
                
