In [ ]:
import sys
import numpy as np
import matplotlib.pyplot as plt
import imagalg
In [ ]:
N=10
a=np.linspace(0,N-1,N)
b=np.linspace(0,N,N+1)
c=np.linspace(0,N+1,N+2)
x,y,z=np.meshgrid(a,b,c)
#img=np.random.normal(size=[10,11,12])
img=x+y*N+z*N*N
#img=x+y+z
#img=np.linspace(0,999,1000)
#img=img.reshape([10,10,10])
#img=img.astype('float32')
img.dtype
In [ ]:
avg=imagalg.AverageImage()
In [ ]:
print(avg.windowSize())
In [ ]:
plt.figure(figsize=[15,5])
res=avg.process(img,imagalg.AverageImage.ImageAverage,[])
ximg=img.mean(axis=0)
if (N<10) :
print(ximg)
print(res)
else :
plt.subplot(1,3,1)
plt.imshow(ximg)
plt.subplot(1,3,2)
plt.imshow(res)
plt.subplot(1,3,3)
plt.imshow((res-ximg)/ximg)
plt.colorbar()
In [ ]:
plt.figure(figsize=[15,5])
res=avg.process(img,imagalg.AverageImage.ImageMin,[])
ximg=img.min(axis=0)
if (N<10) :
print(ximg)
print(res)
else :
plt.subplot(1,3,1)
plt.imshow(ximg)
plt.subplot(1,3,2)
plt.imshow(res)
plt.subplot(1,3,3)
plt.imshow(res-ximg)
plt.colorbar()
In [ ]:
plt.figure(figsize=[15,5])
res=avg.process(img,imagalg.AverageImage.ImageMax)
ximg=img.max(axis=0)
if (N<10) :
print(ximg)
print(res)
else :
plt.subplot(1,3,1)
plt.imshow(ximg)
plt.subplot(1,3,2)
plt.imshow(res)
plt.subplot(1,3,3)
plt.imshow(res-ximg)
plt.colorbar()
In [ ]:
plt.figure(figsize=[15,5])
res=avg.process(method=imagalg.AverageImage.ImageWeightedAverage,img=img)
ximg=img.mean(axis=0)
if (N<10) :
print(ximg)
print(res)
else :
plt.subplot(1,3,1)
plt.imshow(ximg)
plt.subplot(1,3,2)
plt.imshow(res)
plt.subplot(1,3,3)
plt.imshow((res-ximg)/ximg)
plt.colorbar()
In [ ]:
try:
res=avg.process(img,imagalg.AverageImage.ImageAverage,[2])
except imagalg.ImagingException as e :
print(e)
In [ ]:
help(imagalg.AverageImage)
In [ ]:
res.dtype
In [ ]:
pc=imagalg.PolynomialCorrection()
In [ ]:
pc.polynomialOrder()
In [ ]:
pc.coefficients()
In [ ]:
pc.setup([1,2,3,4])
print(pc.polynomialOrder(),pc.coefficients())
In [ ]:
pc.setup([1])
In [ ]:
pc.setup([0,1,2,3,4,5,6,7,8,9,10,11])
In [ ]:
c=pc.coefficients()
In [ ]:
arr=np.array([1,2,3,4,5,6])
print(pc.process(arr))
for v in arr :
print(c[0]+c[1]*v+c[2]*v**2+c[3]*v**3)
In [ ]:
a2=np.array([[1.0,2,3],[4,5,6]])
print(a2)
pc.processInplace(a2)
print(a2)
In [ ]:
a2.dtype
In [ ]:
a2.dtype
In [ ]:
help(imagalg)
In [ ]: