我有一张图片:
我必须检测两者之间的空白并基本上将其划分为这样的两部分-
这是我到目前为止所编码的......但它确实只检测到黑线而不是中间的白色区域。
import numpy as np
import cv2
img = cv2.imread('12.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray,50,150,apertureSize = 3)
median = cv2.medianBlur(gray,5)
minLineLength = 250
maxLineGap = 100
lines = cv2.HoughLinesP(edges,0.3,np.pi/180,250,minLineLength,maxLineGap)
for line in lines:
x1,y1,x2,y2 =line[0]
cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
cv2.imwrite('newwhite.png',img)