Compare commits
2 Commits
d8c7b8b0ef
...
514413e1dd
Author | SHA1 | Date | |
---|---|---|---|
|
514413e1dd | ||
|
01d18a4943 |
@ -4,9 +4,8 @@ import numpy as np
|
||||
import os
|
||||
from tqdm import tqdm
|
||||
import csv
|
||||
from utils import Color, denoise, iterativeMean, isARawImage, escapeFilePath, getColorChannel, saveNpArray, rescaleRawImageForDenoiser, updateExtremes
|
||||
from utils import Color, denoise, iterativeMean, isARawImage, escapeFilePath, getColorChannel, saveNpArray, rescaleRawImageForDenoiser, updateExtremes, getColorMeans
|
||||
import matplotlib.pyplot as plt
|
||||
from scipy.ndimage import gaussian_filter
|
||||
|
||||
imagesFolderPath = 'rafael/arw'
|
||||
imagesFolderPathFileName = escapeFilePath(imagesFolderPath)
|
||||
@ -75,7 +74,7 @@ def treatImage(imageFileName, computeExtremes = False, color = None):
|
||||
if denoiser != 'mean':
|
||||
imageDenoisedNpArray = denoise(imageNpArray, denoiser)
|
||||
else:
|
||||
imageDenoisedNpArray = means[color]
|
||||
imageDenoisedNpArray = colorMeans[color]
|
||||
imageNoiseNpArray = imageNpArray - imageDenoisedNpArray
|
||||
estimatedPrnuIterativeMean.add(imageNoiseNpArray)
|
||||
|
||||
@ -91,17 +90,12 @@ if (minColor is None or maxColor is None) and denoiser != 'mean':
|
||||
print(f'{maxColor=}')
|
||||
|
||||
if denoiser == 'mean':
|
||||
means = {}
|
||||
for color in colors:
|
||||
colorIterativeMean = iterativeMean()
|
||||
for imageFileName in tqdm(imagesFileNames, f'Computing mean of {color} colored images'):
|
||||
imageNpArray = getImageNpArray(imageFileName, False, color)
|
||||
imageNpArray = gaussian_filter(imageNpArray, sigma = 5)
|
||||
colorIterativeMean.add(imageNpArray)
|
||||
means[color] = colorIterativeMean.mean
|
||||
colorMeans = getColorMeans(imagesFileNames, colors)
|
||||
for color in Color:
|
||||
colorMeans[color] = colorMeans[color]
|
||||
fileName = f'mean_{imagesFolderPathFileName}_{color}'
|
||||
# Then use `merge_single_color_channel_images_according_to_bayer_filter.py` to consider all color channels, instead of saving this single color channel as an image.
|
||||
saveNpArray(fileName, colorIterativeMean.mean)
|
||||
saveNpArray(fileName, colorMeans[color])
|
||||
|
||||
for color in colors:
|
||||
estimatedPrnuIterativeMean = iterativeMean()
|
||||
|
@ -7,6 +7,7 @@ from PIL import Image
|
||||
from skimage import img_as_float
|
||||
from datetime import datetime
|
||||
import builtins as __builtin__
|
||||
from scipy.ndimage import gaussian_filter
|
||||
|
||||
class Color(Enum):
|
||||
RED = auto()
|
||||
@ -130,3 +131,14 @@ def updateExtremes(imageNpArray, minColor, maxColor):
|
||||
|
||||
def print(*toPrint):
|
||||
__builtin__.print(datetime.now(), *toPrint)
|
||||
|
||||
def getColorMeans(imagesFileNames, colors = Color):
|
||||
colorMeans = {}
|
||||
for color in colors:
|
||||
colorIterativeMean = iterativeMean()
|
||||
for imageFileName in tqdm(imagesFileNames, f'Computing mean of {color} colored images'):
|
||||
imageNpArray = getImageNpArray(imageFileName, False, color)
|
||||
imageNpArray = gaussian_filter(imageNpArray, sigma = 5)
|
||||
colorIterativeMean.add(imageNpArray)
|
||||
colorMeans[color] = colorIterativeMean.mean
|
||||
return colorMeans
|
||||
|
Loading…
Reference in New Issue
Block a user