Ejemplo n.º 1
0
def filter(image, rgb):
    filtered_image = Image.new("RGB", (image.width, image.height))
    for y in range(image.height):
        for x in range(image.width):
            pixel = colourx.rgb_to_hcl(image.getpixel((x,y)))
            new_hue = colourx.rgb_to_hcl(rgb)[0]
            new_color = (new_hue, pixel[1], pixel[2])
            filtered_image.putpixel((x,y), colourx.hcl_to_rgb(new_color))
    return filtered_image
Ejemplo n.º 2
0
def dynamic_filter(image, rgb, colour_clamp=False):
    filtered_image = Image.new("RGB", (image.width, image.height))
    for y in range(image.height):
        for x in range(image.width):
            opixel = image.getpixel((x,y))
            pixel = colourx.rgb_to_hcl(image.getpixel((x,y)))
            new_hue = colourx.rgb_to_hcl(rgb)[0]
            new_color = colourx.hcl_to_rgb((new_hue, pixel[1], pixel[2]))

            opacity = math.sqrt(255**2-opixel[1]**2)/255.0
            new_color = colourx.blend_colour( opixel, new_color, opacity)
            filtered_image.putpixel((x,y), new_color)

    return filtered_image
Ejemplo n.º 3
0
def image_hcl(Image):
    r = g = b = 0.0
    numpix = Image.width * Image.height

    for y in range(Image.height):
        for x in range(Image.width):
            pixel = Image.getpixel((x,y))
            r += pixel[0]
            g += pixel[1]
            b += pixel[2]
    avg_rgb = (r/numpix, g/numpix, b/numpix)
    return colourx.rgb_to_hcl(avg_rgb)