Detect bridge Arch and its center using OpenCV

Viewed 55

I want to detect the bridge arch and its center using python.

input image

and I want to like this

output image

I tried different techniques like contours, canny and other algorithms but did not find my solution. kindly help me to solve this.

here is my code

image = .imread(path)
# convert to RGB
image = .cvtColor(image, .COLOR_BGR2RGB)
# convert to grayscale
gray = .cvtColor(image, .COLOR_RGB2GRAY)
# create a binary thresholded image
_, binary = .threshold(gray, 225, 255, .THRESH_BINARY_INV)
# show it
plt.imshow(binary, cmap="gray")
plt.show()
# find the contours from the thresholded image
contours, hierarchy = .findContours(binary, .RETR_TREE, .CHAIN_APPROX_SIMPLE)
# draw all contours
image = .drawContours(image, contours, -1, (0, 255, 0), 2)
# show the image with the drawn contours
_imshow(image)
0 Answers
Related