#49: Remove intermediary bias by not working on images but numpy arrays instead

This commit is contained in:
Benjamin Loison 2024-04-19 17:21:54 +02:00
parent 675b01271a
commit 9365b58d1d
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -1,15 +1,18 @@
from PIL import Image
from utils import Color
from tqdm import tqdm
import matplotlib.pyplot as plt
def getImageByColor(color):
return Image.open(f'means/mean_flat-field_nef_wavelet_{color}.png')
filePath = f'means/mean_rafael_arw_bilateral_{color}.npy'
image = np.load(filePath)
return image
color = Color.BLUE
image = getImageByColor(color)
width, height = image.size
width, height = image.shape
multipleColorsImage = Image.new('RGB', [dimension * 2 for dimension in image.size])
multipleColorsImage = np.empty([dimension * 2 for dimension in image.shape], dtype = np.float64)
def getNewIndex(index, offset):
newIndex = (index - offset) * 2 + offset
@ -19,7 +22,7 @@ for color in tqdm(Color, 'Color'):
colorImage = getImageByColor(color)
for y in tqdm(range(height), 'Height'):
for x in range(width):
pixel = colorImage.getpixel((x, y))
pixel = colorImage[x, y]
'''
Assume Bayer Filter:
RG
@ -33,6 +36,6 @@ for color in tqdm(Color, 'Color'):
}[color]
newX, newY = [getNewIndex(index, offset) for index, offset in [(x, offsetX), (y, offsetY)]]
multipleColorsImage.putpixel((newX, newY), pixel)
multipleColorsImage[newX, newY] = pixel
multipleColorsImage.save('multipleColors.png')
plt.imsave('multiple_colors.png', multipleColorsImage)