Implementation of solution to image stacking and statistical blending.
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import imageio
import numpy as np
import scipy.stats as stats
import glob
from _utils import *
sample = imageio.imread('../_data/SEQ01-32bits/sample.0001.exr')
print('sample 0001')
summary(sample)
sample 0001 R G B min: 0.0294 0.0204 0.0148 1st Quar: 0.1513 0.1422 0.1306 median: 0.2340 0.2164 0.1900 mean: 0.3025 0.2680 0.2191 3rd Quar: 0.3858 0.3417 0.2785 max: 71.7715 47.6547 24.3402 sigma: 0.3659 0.2595 0.1554
histogram(sample, interval=[0, 1])
Transform from linear to sRGB usign gamma correction $\large \gamma = 2.2$.
sample_sRGB = sample**(1/2.2)
histogram(sample_sRGB, interval=[0, 1])
def stackRead(pathname):
'''
pathname defined by "glob" pattern.
i.e.: "directory/sequence_folder/image_*.jpg"
'''
# List of image in pathname folder
SEQ_IMG = glob.glob(pathname)
n = len(SEQ_IMG)
# sample for stack definition
sample = imageio.imread(SEQ_IMG[0])
# x and y are the dimensions
# c is the number of channels
y, x, c = sample.shape
# define stack
stack = np.zeros((n, y, x, c), dtype=sample.dtype)
# image stacking
for FILE in SEQ_IMG:
index = SEQ_IMG.index(FILE)
stack[index] = imageio.imread(FILE)
# output
return stack
stack = stackRead('../_data/SEQ01-32bits/sample.*.exr')
panel(stack**(1/2.2), (3, 1),
interval=[0, 1],
dims=(1200, 400),
texts=['{:04}'.format(i + 1) for i in range(10)])