Move getImageNpArray
to utils.py
This commit is contained in:
parent
790c0d6da4
commit
4bea5e3a97
@ -4,7 +4,7 @@ import numpy as np
|
||||
import os
|
||||
from tqdm import tqdm
|
||||
import csv
|
||||
from utils import Color, denoise, iterativeMean, isARawImage, escapeFilePath, getColorChannel, saveNpArray, rescaleRawImageForDenoiser, updateExtremes, getColorMeans
|
||||
from utils import Color, denoise, iterativeMean, escapeFilePath, saveNpArray, getColorMeans, getImageNpArray
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
imagesFolderPath = 'rafael/arw'
|
||||
@ -54,25 +54,11 @@ def getImageFilePath(imageFileName):
|
||||
imageFilePath = f'{imagesFolderPath}/{imageFileName}'
|
||||
return imageFilePath
|
||||
|
||||
def getImageNpArray(imageFileName, computeExtremes, color):
|
||||
global minColor, maxColor
|
||||
imageFilePath = getImageFilePath(imageFileName)
|
||||
imageNpArray = getColorChannel(imageFilePath, color)
|
||||
|
||||
if computeExtremes:
|
||||
minColor, maxColor = updateExtremes(imageNpArray, minColor, maxColor)
|
||||
return
|
||||
|
||||
if isARawImage(imageFileName) and denoiser != 'mean':
|
||||
imageNpArray = rescaleRawImageForDenoiser(imageNpArray, minColor, maxColor)
|
||||
# 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
|
||||
|
||||
# `color` is the actual color to estimate PRNU with.
|
||||
def treatImage(imageFileName, computeExtremes = False, color = None):
|
||||
global estimatedPrnuIterativeMean
|
||||
imageNpArray = getImageNpArray(imageFileName, computeExtremes, color)
|
||||
imageFilePath = getImageFilePath(imageFileName)
|
||||
imageNpArray = getImageNpArray(imageFilePath, computeExtremes, color)
|
||||
if imageNpArray is None:
|
||||
return
|
||||
if denoiser != 'mean':
|
||||
|
@ -142,3 +142,17 @@ def getColorMeans(imagesFileNames, colors = Color):
|
||||
colorIterativeMean.add(imageNpArray)
|
||||
colorMeans[color] = colorIterativeMean.mean
|
||||
return colorMeans
|
||||
|
||||
def getImageNpArray(imageFilePath, computeExtremes, color):
|
||||
global minColor, maxColor
|
||||
imageNpArray = getColorChannel(imageFilePath, color)
|
||||
|
||||
if computeExtremes:
|
||||
minColor, maxColor = updateExtremes(imageNpArray, minColor, maxColor)
|
||||
return
|
||||
|
||||
if isARawImage(imageFilePath) and denoiser != 'mean':
|
||||
imageNpArray = rescaleRawImageForDenoiser(imageNpArray, minColor, maxColor)
|
||||
# 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user