1、 Canny边缘检测
2、OpenCV中的Canny边界检测
import cv2 import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread("./image/test3.jpg", 0) edges = cv2.Canny(img, 100,
200)
plt.subplot(121),plt.imshow(img, cmap='gray') plt.title("Original")
plt.subplot(122),plt.imshow(edges, cmap='gray') plt.title("Edge")
plt.show()
2、 图像金字塔
import cv2
import numpy as np
A = cv2.imread('./image/apple.jpg')
B = cv2.imread('./image/orange.jpg')
G = A.copy()
gpA = [G]
for i in range(6):
G = cv2.pyrDown(G)
gpA.append(G)
G = B.copy()
gpB = [G]
for i in range(6):
G = cv2.pyrDown(G)
gpB.append(G)
lpA = [gpA[5]]
for i in range(5, 0, -1):
GE = cv2.pyrUp(gpA[i])
L = cv2.subtract(gpA[i-1], GE)
lpA.append(L)
lpB = [gpB[5]]
for i in range(5, 0, -1):
GE = cv2.pyrUp(gpB[i])
L = cv2.subtract(gpB[i-1], GE)
lpB.append(L)
LS = []
for la, lb in zip(lpA, lpB):
rows, cols, dpt = la.shape
ls = np.hstack((la[:, 0:cols/2], lb[:, cols/2:]))
LS.append(ls)
ls_ = LS[0]
for i in range(1, 6):
ls_ = cv2.pyrUp(ls_)
ls_ = cv2.add(ls_, LS[i])
real = np.hstack((A[:,:cols/2],B[:,cols/2:]))
cv2.imwrite('Pyramid_blending2.jpg', ls_)
cv2.imwrite('Direct_blending.jpg', real)
本节较为简单,理论知识居多,程序也简单,就没有做出具体的工具使用;在之前的章节所有的工具使用的都是python3.6+PyQt5+matplotlib+openCV3中的知识,如果有什么疑问请留言,如需要源码请联系邮箱:[email protected]