I'm trying to find the distance between two irregular edges in a Binary image at various intervals. I want to find the distance/ length of the red line (the distance between the black edge at the bottom to the black peak edge at the top) Not sure which method to use for this. I also did edge detection. But not sure how to find the distance between the edges (the green lines) It would be great if I can also trace the green lines and draw a line (not straight) on top of it. I'm trying to do this all with OpenCV and Scipy packages. Please let me know if I should approach this problem in any other way. ANd In my case, I can't manually detect coordinates because I have a huge data set to work on a daily basis.
topLeft = count(mask[0])
bottomLeft = count(mask[h])
# to shadow and hide the old left line
mask = line(mask, (topLeft, 0), (bottomLeft, h), (0, 0, 0), 80)
topRight = count(mask[0])
bottomRight = count(mask[h])
# to shadow and hide the old right line
mask = line(mask, (topRight, 0), (bottomRight, h), (0, 0, 0), 80)
mask = cv2.cvtColor(mask, cv2.COLOR_GRAY2BGR)
# to draw new clean left line
mask = line(mask, (topLeft, 0), (bottomLeft, h), (128, 0, 255), 25)
# to draw new clean right line
mask = line(mask, (topRight, 0), (bottomRight, h), (128, 0, 255), 25)
a = center(topLeft, 0, bottomLeft, h)
b = center(topRight, 0, bottomRight, h)
mask = line(mask, a, b, (128, 0, 255), 25)
cv2.imwrite("out2.jpg", mask)
Blockquote