forked from yongleex/SBCC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.py
35 lines (26 loc) · 840 Bytes
/
background.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import cv2
import numpy as np
def context_min(images):
return [np.min(images, axis=0)]
def context_mean(images):
return [np.mean(images, axis=0)]
def context_blurU(images, kx=21, ky=21):
results = [cv2.blur(img, (kx,ky)) for img in images]
return results
def context_blurG(images, kx=21, ky=21):
results = [cv2.GaussianBlur(img, (kx,ky), 3.0) for img in images]
return results
def test():
import matplotlib.pyplot as plt
img1 = cv2.imread('./data/3a.tif',0)
img2 = cv2.imread('./data/3b.tif',0)
images = [img1, img2]
for func in [context_min, context_mean, context_blurU, context_blurG]:
bgs = func(images)
for bg in bgs:
plt.figure()
plt.imshow(bg)
plt.title(func.__name__)
plt.show()
if __name__ == "__main__":
test()