First try to merge multiple single color channel images

This commit is contained in:
Benjamin Loison 2024-04-18 01:00:41 +02:00
parent 6aca1126a1
commit 0b52e781e3
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -1,31 +1,34 @@
from PIL import Image
from utils import Color
from tqdm import tqdm
def getImageByColor(color):
return Image.open(f'mean_flat-field_nef_wavelet_{color}.png')
return Image.open(f'means/mean_flat-field_nef_wavelet_{color}.png')
color = Color.BLUE
image = getImageByColor(color)
height, width = image.size
width, height= image.size
multipleColorsImage = Image.new('RGB', [dimension * 2 for dimension in image.size])
for color in Color:
for color in tqdm(Color, 'Color'):
colorImage = getImageByColor(color)
for y in range(height):
for y in tqdm(range(height), 'Height'):
for x in range(width):
pixel = colorImage.getpixel(x, y)
pixel = colorImage.getpixel((x, y))
'''
RG
GB
'''
newX, newY = {
Color.RED: 2 * x, 2 * y,
Color.GREEN_RIGHT: 2 * (x - 1), 2 * y,
Color.GREEN_BOTTOM: 2 * x, 2 * (y - 1),
Color.BLUE: 2 * (x - 1), 2 * (y - 1),
Color.RED: (x, y),
Color.GREEN_RIGHT: (x - 1, y),
Color.GREEN_BOTTOM: (x, y - 1),
Color.BLUE: (x - 1, y - 1),
}[color]
newX *= 2
newY *= 2
multipleColorsImage.putpixel((x, y), pixel)
multipleColorsImage.putpixel((newX, newY), pixel)
multipleColorsImage.save('multipleColors.png')