积分图像的构建
实现前后图对比:
实现代码:
import cv2 import numpy as np img = cv2.imread('./4.jpg', 0) h, w = img.shape s = 0 #积分图 ii = np.zeros((h, w)) for i in range(h): for j in range(w): s += img[i, j] ii[i, j] = int(s) if i==0 else int(s+ii[i-1, j]) s = 0 ii = 255 * ii/ii[h-1, w-1] cv2.imshow('picture', ii) cv2.imwrite('6.jpg', ii) cv2.waitKey() cv2.destroyAllWindows()