I'm new to matlab! I'm trying to detect pupils from a frame sequence... I need to use this approach to detect whether eyes are open or not.
imfindcircles is working when I don't use erode and dilate, but that steps of erode and dilate are bringing me a really cool image, it's a very clean black circle on white background, Hough will work like a charm, but it doesn't and I cannot really find a way out. It doesn't depend on radii range, because if I comment erode and dilate it works. Erode and dilate produce a perfect image as I just said.
Any tips?
rightEye = imcrop(videoFrame, rightEyeBox);
leftEye = imcrop(videoFrame, leftEyeBox);
% to grayscale
grayRightEye = rgb2gray(rightEye);
grayLeftEye = rgb2gray(leftEye);
% binarize
grayRightEye = im2bw(grayRightEye, 0.45);
% erode and dilate
finalRight = imdilate(grayRightEye, strel('disk', 7));
finalRight = imerode(finalRight, strel('disk', 11));
imshow(grayRightEye);
rightCircle = max(rightRows, rightCols);
[centers, radii] = imfindcircles(grayRightEye,[5 25])