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)")
The trichromy process starts with three different images, or inputs. One is the light relected by the object passed through a green filter, the next through an orange filter and the third through a green filter.
You don't have that. You only have a single input image, and though it may be expressed in RGB terms, the red, green and blue channels are all identical.
There is simply no colour information available to you from which to construct, construe or create a likeness of the original. Anything you do is pure guesswork. Imagine looking at each pixel in the image and saying "Mmmm, this pixel has a grey value of 146, now what were the three R, G and B values that gave rise to this?". How could you possibly know?