from PIL import Image, ImageChops 

PATH = "/home/cugur/Downloads/matf/dozs/2024/week2/data/yugo.jpg"

with Image.open(PATH) as img:

    print("Ulazna slika: ")
    print(img)
    print("Rezolucija ulazne slike je: {}".format(img.size))
    img.show()

    r, g, b = img.split()
    print("'Red' komponenta slike: ")
    print(r)
    r.show()

    # Za analizu
    # g.show()
    # b.show()

    # Definisanje black kanala:
    black = ImageChops.constant(r, 0)
    black.show()
    
    # Kombinacije slika
    imgr = Image.merge("RGB", (r, black, black))
    imgr.show()

    imgg = Image.merge("RGB", (black, g, black))
    imgg.show()

    imgb = Image.merge("RGB", (black, black, b))
    imgb.show()

    # Zadatak: sta se dogodi kada most intensive filter RED postavimo na npr. zeleni kanal?
    imgrg = Image.merge("RGB", (black, r, black))
    imgrg.show()

    # Zelena + crvena = zuta
    imgrg = Image.merge("RGB", (r, r, black))
    imgrg.show()