In [1]:
import canont3i
r_cfa = canont3i.read_CR2_as_CFA('data/red.CR2')
g_cfa = canont3i.read_CR2_as_CFA('data/green.CR2')
b_cfa = canont3i.read_CR2_as_CFA('data/blue.CR2')
In [2]:
import numpy as np
y, x = np.mgrid[0:r_cfa.shape[0], 0:r_cfa.shape[1]]
pix00 = (np.mod(y, 2) == 0) & (np.mod(x, 2) == 0)
pix10 = (np.mod(y, 2) == 1) & (np.mod(x, 2) == 0)
pix01 = (np.mod(y, 2) == 0) & (np.mod(x, 2) == 1)
pix11 = (np.mod(y, 2) == 1) & (np.mod(x, 2) == 1)
In [3]:
rstats = [float(r_cfa[pix].sum())/r_cfa.sum() for pix in (pix00, pix10, pix01, pix11)]
gstats = [float(g_cfa[pix].sum())/g_cfa.sum() for pix in (pix00, pix10, pix01, pix11)]
bstats = [float(b_cfa[pix].sum())/b_cfa.sum() for pix in (pix00, pix10, pix01, pix11)]
In [4]:
rstats
Out[4]:
In [5]:
gstats
Out[5]:
In [6]:
bstats
Out[6]:
In [7]:
import matplotlib.pyplot as plt
%pylab inline
figure()
h00 = plt.hist(r_cfa[pix00], 50, normed=1, histtype='step', color='red', label='00')
h10 = plt.hist(r_cfa[pix10], 50, normed=1, histtype='step', color='green', label='10')
h01 = plt.hist(r_cfa[pix01], 50, normed=1, histtype='step', color='green', label='01')
h11 = plt.hist(r_cfa[pix11], 50, normed=1, histtype='step', color='blue', label='11')
plt.legend()
plt.title('red image')
Out[7]:
In [8]:
figure()
h00 = plt.hist(g_cfa[pix00], 50, normed=1, histtype='step', color='red', label='00')
h10 = plt.hist(g_cfa[pix10], 50, normed=1, histtype='step', color='green', label='10')
h01 = plt.hist(g_cfa[pix01], 50, normed=1, histtype='step', color='green', label='01')
h11 = plt.hist(g_cfa[pix11], 50, normed=1, histtype='step', color='blue', label='11')
plt.legend()
plt.title('green image')
Out[8]:
In [9]:
figure()
h00 = plt.hist(b_cfa[pix00], 50, normed=1, histtype='step', color='red', label='00')
h10 = plt.hist(b_cfa[pix10], 50, normed=1, histtype='step', color='green', label='10')
h01 = plt.hist(b_cfa[pix01], 50, normed=1, histtype='step', color='green', label='01')
h11 = plt.hist(b_cfa[pix11], 50, normed=1, histtype='step', color='blue', label='11')
plt.legend()
plt.title('blue image')
Out[9]: