Before optimizing extract_4_color_channel_images_from_raw.py

This commit is contained in:
Benjamin Loison 2024-05-23 16:55:11 +02:00
parent 2144babd8f
commit a5cf1083bd
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -1,8 +1,9 @@
import numpy as np
import matplotlib.pyplot as plt
from utils import Color, getColorChannel
from tqdm import tqdm
IMAGE_INDEX = 3294
IMAGE_INDEX_RANGE = range(3294, 3553)
Y_RANGE = 5
X_RANGE = 25
ORIGINAL_INTERESTING_POSITION = [5752, 1695][::-1]
@ -16,16 +17,18 @@ def getImageColorChannel(imageIndex, color):
imageFilePath = getImageFilePath(imageIndex)
return getColorChannel(imageFilePath, color).astype(np.int32)
firstColorChannel = getImageColorChannel(IMAGE_INDEX, COLOR)
secondColorChannel = getImageColorChannel(IMAGE_INDEX + 1, COLOR)
differenceColorChannel = firstColorChannel - secondColorChannel
print(differenceColorChannel.shape)
# Could leverage crop already here.
colorChannels = [getImageColorChannel(imageIndex, COLOR) for imageIndex in tqdm(IMAGE_INDEX_RANGE)]
meanColorChannels = np.mean(colorChannels, axis = 0)
estimatedPrnus = [colorChannel - meanColorChannels for colorChannel in tqdm(colorChannels)]
estimatedPrnu = np.mean(estimatedPrnus, axis = 0)
print(estimatedPrnu.shape)
def crop(image, interestingPosition, yRange, xRange):
return image[interestingPosition[0] - yRange: interestingPosition[0] + yRange, interestingPosition[1] - xRange: interestingPosition[1] + xRange]
#colorChannel = crop(multipleColorsImage, ORIGINAL_INTERESTING_POSITION, Y_RANGE, X_RANGE)
colorChannelToDisplay = differenceColorChannel
colorChannelToDisplay = estimatedPrnu
colorChannelToDisplay = crop(colorChannelToDisplay, INTERESTING_POSITION, Y_RANGE, X_RANGE)
print(colorChannelToDisplay.shape)
plt.imshow(colorChannelToDisplay)