accumulate Function family is a function that accumulates pictures . Include accumulate,accumulateProduct,accumulateSquare and accumulateWeighted.
The function is declared as :accumulate(src, dst, mask=None). among src by float Type of numpy Array ,dst It's the same thing . If not float An array of type will produce an error .
mask Must be np.uint8 Type and src Same array .0 Indicates that the value corresponding to the position does not participate in the accumulation . Other values indicate accumulation .
Examples are as follows :
#coding:utf8
import cv2
import numpy as np
a = np.array([[1],[2],[13]],np.float32)
b = np.zeros((3,1),np.float32)
mask = np.ones((3,1),np.uint8)
mask[1]=0
c = cv2.accumulate(a,b,mask)
print(c)
c = cv2.accumulate(c,b,mask)
print(c)
The output value is :
[[ 1.]
[ 0.]
[13.]]
[[ 2.]
[ 0.]
[26.]]
The function is declared as :accumulateProduct(src1, src2, dst, mask=None).src1,src2 and dst For the same type of float32 Array .
The function src1 and src2 After multiplying , Put it in dst in .
#coding:utf8
import cv2
import numpy as np
a = np.array([[1],[2],[13]],np.float32)
b = np.array([[3],[5],[6]],np.float32)
c = np.zeros((3,1),np.float32)
d = cv2.accumulateProduct(a,b,c)
print(c)
[[ 3.]
[10.]
[78.]]
The function is declared as :accumulateSquare(src, dst, mask=None).
The function src Put the square of dst in .
#coding:utf8
import cv2
import numpy as np
a = np.array([[1],[2],[13]],np.float32)
c = np.zeros((3,1),np.float32)
cv2.accumulateSquare(a,c)
print(c)
[[ 1.]
[ 4.]
[169.]]
The function is declared as :accumulateWeighted(src, dst, alpha, mask=None)
The function is press alpha Weight accumulation .
#coding:utf8
import cv2
import numpy as np
a = np.array([[1],[2],[13]],np.float32)
c = np.zeros((3,1),np.float32)
cv2.accumulateWeighted(a,c,0.1)
print(c)
[[0.1 ]
[0.2 ]
[1.3000001]]