Hi, I am writing a script which will measure a length of antler from an image. So far, I have written an script which detect antler edges but with gaps in it. By gaps, I mean there are missing pieces in boundry of antler.
I have written a script which resizes the image, applies Gaussian filter, eroson, canny filter, and dilation.
This is the result image,
Script and original image is attached in this post. What I want to do is to detect edg of antler and draw its boundry line so I can calculate its length.
Original script
import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
import imutils
img = cv.imread("images/BFA Elk/IMG_0176.jpeg")
img = imutils.resize(img, width=400)
cv.imshow("Original image", img)
copy_img = np.copy(img)
copy_img = cv.cvtColor(copy_img, cv.COLOR_BGR2RGB)
gray = cv.cvtColor(copy_img, cv.COLOR_RGB2GRAY)
gray_blur = cv.GaussianBlur(gray,(11,11),0)
cv.imshow('Gaussian Blur', gray_blur)
# cv.waitKey()
kernel = np.ones((5,5), np.uint8)
img_erosion = cv.erode(gray_blur, kernel, iterations=1)
cv.imshow('After erode', img_erosion)
lower = 60
upper = 120
adges = cv.Canny(img_erosion, lower,upper)
cv.imshow('Canny edge', adges)
# plt.imshow(adges, cmap='gray')
kernel2 = np.ones((5,5), np.uint8)
img_dilation = cv.dilate(adges, kernel2, iterations=1)
cv.imshow('Dilated image', img_dilation)
kernel = np.ones((5,5), np.uint8)
img_erosion = cv.erode(gray_blur, kernel, iterations=1)
cv.imshow('After erode', img_erosion)
cv.waitKey()