-1

Is there any edge detection filter in OpenCV like canny but I want the background to be white and the edges in black color

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • 4
    Make a copy of your image, invert it, and use the common edge detection. – HansHirse Nov 25 '19 at 11:22
  • @HansHirse: this doesn't make sense, edge detection is contrast-independent. I guess that the OP wants contrast reversal *after* edge filtering. –  Dec 09 '19 at 10:36

1 Answers1

1

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()
santamo
  • 34
  • 2