简体   繁体   中英

Is there any edge detection in opencv(python) with white background?

OpenCV中是否有像canny这样的边缘检测滤镜,但我希望背景为白色,边缘为黑色

I don't think there is such concept but you can achieve this way

import cv2
import numpy as np
img = cv2.imread("arch.jpg")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

edges = cv2.Canny(gray,100,200)
ret,th2 = cv2.threshold(edges,100,255,cv2.THRESH_BINARY_INV)


cv2.imshow("img",th2)
cv2.waitKey(0)
cv2.destroyAllWindows()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM