Add and use getImageCrop
This commit is contained in:
parent
fd6a9868fe
commit
0c429aa4d6
@ -3,7 +3,7 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from tqdm import tqdm
|
||||
from utils import denoise, iterativeMean, getColorChannel, escapeFilePath, Color, mergeSingleColorChannelImagesAccordingToBayerFilter, rescaleRawImageForDenoiser, updateExtremes, saveNpArray, getColorMeans
|
||||
from utils import denoise, iterativeMean, getColorChannel, escapeFilePath, Color, mergeSingleColorChannelImagesAccordingToBayerFilter, rescaleRawImageForDenoiser, updateExtremes, saveNpArray, getColorMeans, getImageCrop
|
||||
import sys
|
||||
import os
|
||||
import random
|
||||
@ -60,7 +60,7 @@ def getImageFilePath(camera, cameraImageIndex):
|
||||
|
||||
def getSingleColorChannelImages(camera, cameraImageIndex):
|
||||
imageFilePath = getImageFilePath(camera, cameraImageIndex)
|
||||
singleColorChannelImages = {color: rescaleIfNeeded(getColorChannel(imageFilePath, color)[:minimalColorChannelCameraResolution[0],:minimalColorChannelCameraResolution[1]], minColor, maxColor) for color in Color}
|
||||
singleColorChannelImages = {color: rescaleIfNeeded(getImageCrop(getColorChannel(imageFilePath, color), minimalColorChannelCameraResolution), minColor, maxColor) for color in Color}
|
||||
return singleColorChannelImages
|
||||
|
||||
def getMultipleColorsImage(singleColorChannelImages):
|
||||
@ -74,8 +74,7 @@ def getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, c
|
||||
return imagePrnuEstimateNpArray
|
||||
|
||||
imagesCamerasFilePaths = {camera: [f'{IMAGES_CAMERAS_FOLDER[camera]}/{imagesCamerasFileName}' for imagesCamerasFileName in imagesCamerasFileNames[camera]] for camera in imagesCamerasFileNames}
|
||||
#print(imagesCamerasFilePaths)
|
||||
cameraColorMeans = {camera: getColorMeans(imagesCamerasFilePaths[camera], Color, DENOISER) for camera in imagesCamerasFilePaths}
|
||||
cameraColorMeans = {camera: getColorMeans(imagesCamerasFilePaths[camera], Color, DENOISER, minimalColorChannelCameraResolution) for camera in imagesCamerasFilePaths}
|
||||
|
||||
from utils import silentTqdm
|
||||
#tqdm = silentTqdm
|
||||
|
@ -132,12 +132,14 @@ def updateExtremes(imageNpArray, minColor, maxColor):
|
||||
def print(*toPrint):
|
||||
__builtin__.print(datetime.now(), *toPrint)
|
||||
|
||||
def getColorMeans(imagesFileNames, colors, denoiser):
|
||||
def getColorMeans(imagesFileNames, colors, denoiser, singleColorChannelCropResolution = None):
|
||||
colorMeans = {}
|
||||
for color in colors:
|
||||
colorIterativeMean = iterativeMean()
|
||||
for imageFileName in tqdm(imagesFileNames, f'Computing mean of {color} colored images'):
|
||||
imageNpArray = getImageNpArray(imageFileName, False, color, denoiser)
|
||||
if singleColorChannelCropResolution is not None:
|
||||
imageNpArray = getImageCrop(imageNpArray, singleColorChannelCropResolution)
|
||||
imageNpArray = gaussian_filter(imageNpArray, sigma = 5)
|
||||
colorIterativeMean.add(imageNpArray)
|
||||
colorMeans[color] = colorIterativeMean.mean
|
||||
@ -156,3 +158,7 @@ def getImageNpArray(imageFilePath, computeExtremes, color, denoiser):
|
||||
# Pay attention to range of values expected by the denoiser.
|
||||
# Indeed if provide the thousands valued raw image, then the denoiser only returns values between 0 and 1 and making the difference between both look pointless.
|
||||
return imageNpArray
|
||||
|
||||
def getImageCrop(image, cropResolution):
|
||||
imageCrop = image[:cropResolution[0], :cropResolution[1]]
|
||||
return imageCrop
|
||||
|
Loading…
x
Reference in New Issue
Block a user