I'm trying to target both the iris and pupil border using opencv's Canny Edge, but all of the parameters I've used do not meet the criteria of well delimiting the two edges. The only way I found of segmenting at least the edge of the iris was binarizing it and then applying the Canny Edge and actually gave a good return.
- Is there any way to improve the result? Or is it trial and error?
- How to segment the pupil?
Attempt to segment only the pupil binarizing in the dark range:
#'guarda' o pixel se ele estiver no intervalo que é preto
for x in range(0,suavizada.shape[0]):
for y in range(0,suavizada.shape[1]):
if img[x][y] >=0 and suavizada[x][y] <65:
escala[x][y] = 255
Code to target iris:
img = cv2.imread('path',0)
suavizada = cv2.medianBlur(img,7)
_,limites = cv2.threshold(suavizada,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
bordas = cv2.Canny(limites,0,0)
cv2.imshow('bordas',bordas)
cv2.waitKey(0)
cv2.destroyAllWindows()
Imagem original:
Imagem depois de binarizar e passar pelo Canny:
Estou utilizando Python 3.x com a biblioteca instalada via PyPi