opencv中的blockproc相当于什么?
http://www.mathworks.com/help/images/ref/blockproc.html?refresh=true
我想在3X3的块中打破图像并在每个块上应用平均值。
答案 0 :(得分:3)
答案 1 :(得分:0)
使用python绑定时,我们可以执行以下操作
import cv2
import numpy as np
mat = cv2.imread('x.jpg')
rows, cols, x = mat.shape
rows, cols = 3*(rows/3), 3*(cols/3)
reshaped = mat[:rows,:cols].reshape(rows//3, 3, cols//3, 3,3)
mat1 = reshaped.sum(axis=(1, 3)) / 9
cv2.imwrite('y.jpg', mat1.astype(np.uint8))