From 3636335b63ad52ecab030fde1872aa101ddf01b7 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Thu, 18 Apr 2024 00:52:08 +0200 Subject: [PATCH] Add `match` statement --- ...hannel_images_according_to_bayer_filter.py | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/datasets/raise/merge_single_color_channel_images_according_to_bayer_filter.py b/datasets/raise/merge_single_color_channel_images_according_to_bayer_filter.py index b8b6694..2edf9ed 100644 --- a/datasets/raise/merge_single_color_channel_images_according_to_bayer_filter.py +++ b/datasets/raise/merge_single_color_channel_images_according_to_bayer_filter.py @@ -1,15 +1,36 @@ from PIL import Image from utils import Color -def getImageFileNameByColor(color): - return f'mean_flat-field_nef_wavelet_{color}.png' +def getImageByColor(color): + return Image.open(f'mean_flat-field_nef_wavelet_{color}.png') color = Color.BLUE -image = Image.open(getImageFileNameByColor(color)) -#print(image.size) +image = getImageByColor(color) +height, width = image.size -newImage = Image.new('RGB', [dimension * 2 for dimension in image.size]) -#print(newImage.size) +multipleColorsImage = Image.new('RGB', [dimension * 2 for dimension in image.size]) for color in Color: - getImageFileNameByColor(color) \ No newline at end of file + colorImage = getImageByColor(color) + for y in range(height): + for x in range(width): + pixel = colorImage.getpixel(x, y) + ''' + RG + GB + ''' + newX, newY = { + Color.RED: 2 * x, 2 * y, + Color.GREEN_RIGHT: 2 * x, 2 * y, + Color.GREEN_BOTTOM: 2 * x, 2 * y, + Color.BLUE: 2 * x, 2 * y, + }[color] + match color: + case Color.RED: + newX, newY = 2 * x, 2 * y + case Color.GREEN_RIGHT: + newX, newY = 2 * + + multipleColorsImage.putpixel((x, y), pixel) + +multipleColorsImage.save('multipleColors.png') \ No newline at end of file