程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python CV2 accumulate function family

編輯:Python

accumulate Family of functions

  • 1. accumulate
  • 2. accumulateProduct
  • 3. accumulateSquare
  • 4. accumulateWeighted

accumulate Function family is a function that accumulates pictures . Include accumulate,accumulateProduct,accumulateSquare and accumulateWeighted.

1. accumulate

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.]]

2. accumulateProduct

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.]]

3. accumulateSquare

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.]]

4. accumulateWeighted

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]]

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved