Python Binding AverageImage
Anders Kaestner edited this page Jul 17, 2019
·
6 revisions
Return to Python bindings manual
import numpy as np
import matplotlib.pyplot as plt
import skimage.io as io
from imagalg import AverageImage
img=io.imread('../../UnitTests/data/frame0000_100x100x100.tif').astype('float32')
# Create an instance of the Average image class
avg=AverageImage()
# Average combination
a = avg.process(img,AverageImage.ImageAverage,[])
# Min combiantion
b =avg.process(img,AverageImage.ImageMin,[])
# Max combination
c=avg.process(img,AverageImage.ImageMax,[])
# Median combination
d =avg.process(img,AverageImage.ImageMedian,[])
# Weighted average
e=avg.process(img,AverageImage.ImageWeightedAverage,[])
plt.figure(figsize=[11,6])
plt.subplot(2,3,1)
plt.imshow(a)
plt.title('Average')
plt.subplot(2,3,2)
plt.imshow(b)
plt.title('Min')
plt.subplot(2,3,3)
plt.imshow(c)
plt.title('Max')
plt.subplot(2,3,4)
plt.imshow(d)
plt.title('Median')
plt.subplot(2,3,5)
plt.imshow(e)
plt.title('Weighted Average')
plt.tight_layout()
plt.savefig('avgresults.png')
Runing the example script should produce a plot like