shisoUSZ
shisoUSZ

Reputation: 1

openCV Canny edge detection improvement

I am trying to use openCV Canny edge detector in my python code. I want to have edge detection along the edge of the object, which is corresponding to the skin.

I did:

**im = img[0]
bw = im > thAir
eg1 = cv2.Canny(np.uint8(im),thAir,thBone)
eg2 = cv2.Canny(np.uint8(bw), 0,1)
fig,ax = plt.subplots(1,4)
ax[0].imshow(im)
ax[1].imshow(bw)
ax[2].imshow(eg1)
ax[3].imshow(eg2)
plt.show()**

where thBone is maximum value it can have, and thAir is the minimum value

However, apparently, the detection did not work... Any idea for the improvement?

imshow results

Upvotes: 0

Views: 1257

Answers (1)

ddaletski
ddaletski

Reputation: 86

What are the values of thAir and thBone? Canny edge detector accuracy highly depends on choice of these thresholds.

Consider also using morphology. You can detect edges for such kind of objects (connected, without holes inside) with morphological gradient, which won't depend on thresholds. Documentation for morphology transformations: https://docs.opencv.org/2.4.13.7/modules/imgproc/doc/filtering.html?highlight=morphologyex#cv2.morphologyEx

Upvotes: 0

Related Questions