I'm trying to imitate in a simple way (=> without any I.A.) the old trichromy process to colorize B&W photographs.
Here's the start picture :
I copied this picture in a red, green and blue version by using Pillow :
Each filtered picture has a reduced opacity (I used a putalpha(round(255/3)) for this case), and these are valid PNG files.
Then, I tried to merge this three samples, but there are no colors at the end. The results is the same by using paste or alpha_composite after a for loop :
Was I too optimistic or did I miss something to achieve this ?
EDIT
Here's the filter color function. It's certainly heavy because it compared each red, green and blue level of apixel in a picture with the red, green and blue level of the filter's color. But, still :
def color_photo(file:str,color:tuple,def_file_name:str):
"""
This function colorizes a picture based on a RGB color.
Example : put a red filter on a B&W photo.
"""
try:
format_file = file.split(".")[-1]
img = Image.open(file).convert("RGB")
pixels = img.load()
res = img.info["dpi"]
w, h = img.size
for px in range(w):
for py in range(h):
l_col = [int(new_level) if int(new_level)<int(old_level) else int(old_level) for new_level,old_level in zip(color,img.getpixel((px,py)))]
pixels[px,py] = tuple(l_col)
img.save(def_file_name+"."+format_file,dpi = res, subsampling = 0, quality = 100, optimize = True)
except:
print("You must do a mistake handling file names and/or the tuples of RGB's color instead of something like (234,125,89)")