Premise: the background is black, the value is 0, the object is white, the value is 1
cv2.getStructuringElement
rectKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (9, 4))
gradX = cv2.morphologyEx(gradX, cv2.MORPH_CLOSE, rectKernel)
thresh = cv2.threshold(gradX, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
cv2.imshow("thresh", thresh)