I used the findcontours method but it does not work as expected. What I want is the sketched version of the letter “v” from the original image.
This is the original image of letter “v”
After using findcontours, codes attached below, it gave me an image that is not exactly what I want. I am a new user so can only upload one image. Pls see replies below.
gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
ret, binary = cv.threshold(gray, 0, 255, cv.THRESH_BINARY_INV | cv.THRESH_OTSU)
thinned = cv.ximgproc.thinning(binary)
contours, hireachy = cv.findContours(thinned, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
contours = extractContours(contours)
def extractContours(contours):
contours = contours[0].tolist()
x = []
y = []
newContours = []
for i in contours:
newContours.append(i[0])
for i in newContours:
x.append(i[0])
y.append(i[1])
return np.asfortranarray([x, y])