36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from utils import Color, getColorChannel
|
|
from tqdm import tqdm
|
|
|
|
IMAGE_INDEX_RANGE = range(3294, 3553)
|
|
Y_RANGE = 5
|
|
X_RANGE = 25
|
|
ORIGINAL_INTERESTING_POSITION = [5752, 1695][::-1]
|
|
INTERESTING_POSITION = np.array(ORIGINAL_INTERESTING_POSITION) // 2
|
|
COLOR = Color.RED
|
|
|
|
def getImageFilePath(imageIndex):
|
|
return f'../rafael/240424/photos/DSC0{imageIndex}.ARW'
|
|
|
|
def getImageColorChannel(imageIndex, color):
|
|
imageFilePath = getImageFilePath(imageIndex)
|
|
colorChannel = getColorChannel(imageFilePath, color)
|
|
return colorChannel
|
|
|
|
def crop(image, interestingPosition, yRange, xRange):
|
|
return image[interestingPosition[0] - yRange: interestingPosition[0] + yRange, interestingPosition[1] - xRange: interestingPosition[1] + xRange]
|
|
|
|
# Could leverage crop already here.
|
|
colorChannels = [crop(getImageColorChannel(imageIndex, COLOR), INTERESTING_POSITION, Y_RANGE, X_RANGE).astype(np.int32) 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)
|
|
|
|
#colorChannel = crop(multipleColorsImage, ORIGINAL_INTERESTING_POSITION, Y_RANGE, X_RANGE)
|
|
colorChannelToDisplay = estimatedPrnu
|
|
#colorChannelToDisplay = crop(colorChannelToDisplay, INTERESTING_POSITION, Y_RANGE, X_RANGE)
|
|
print(colorChannelToDisplay.shape)
|
|
plt.imshow(colorChannelToDisplay)
|
|
plt.show() |