I am working on a eye blink detection project in Matlab. By this moment I have been successfully extracted the images of pupil of eye from the real time video captured via a web cam.

But I am stuck at the process to differentiate the open eye pupil to the closed eye lid state.

  1. Open eye pupil

Open eye pupil

2.closed eye lid

closed eye lid

Could you please suggest me any image processing function or algorithm to differentiate between the two states.

(Attached images are the original/actual images extracted from the program on which image processing is to be done.)

  • $\begingroup$ What methods have you tried? By simply looking at your samples, I think image difference should work assuming you can correctly segment "eye" area. $\endgroup$ Mar 24, 2014 at 19:46
  • $\begingroup$ till now i have used mean intensity method to calculate values for a image, but it is not coming accurate under different set of environments, as lighting conditions for the image changes. and also it is a realtime program so storing images and then calculating the image difference would certainly increase its response time which is undesirable. $\endgroup$
    – Vikas
    Mar 26, 2014 at 7:34
  • $\begingroup$ and i have been able to correctly segment the eye area using my program and the above attached images have been segmented using the code itself. could you suggest me any matlab image processing function/algorithm that i should try on the above set of images. $\endgroup$
    – Vikas
    Mar 26, 2014 at 7:41
  • $\begingroup$ meanIntensity=mean2(pic); if meanIntensityValue>60 disp('Eye Closed') else disp('Eye Open') end using this algorithm but results get inaccurate during differnt light surroundings. $\endgroup$
    – Vikas
    Mar 26, 2014 at 7:52
  • 2
    $\begingroup$ A blink is a rapid change in intensity for a short period. Rather than absolute thresholds, how about looking for small spikes in intensity. $\endgroup$ May 5, 2014 at 21:35

1 Answer 1


You probably should take the Deep Learning approach in this case as it makes things almost trivial.

See PyImageSearch - Eye blink detection with OpenCV, Python, and dlib.

To have this integrated into MATLAB you may use Yuval Nirkin's find Face Landmarks project.
What you need is to replicate the Python calculation:

enter image description here

Which is implemented using the Eyes Landmarks:

enter image description here

  • $\begingroup$ That was 2014, you can understand from MATLAB reference in the question. Now we have multiple options to do this. :) $\endgroup$
    – Vikas
    Jul 6, 2023 at 7:15
  • $\begingroup$ @Vikas, Hence you either should accept the answer or post your own solution and mark it as the solution. For the community :-). $\endgroup$
    – Royi
    Jul 6, 2023 at 7:24
  • $\begingroup$ As this doesn't answer the question as it is in MATLAB. thanks for the efforts. $\endgroup$
    – Vikas
    Jul 6, 2023 at 7:45
  • $\begingroup$ @Vikas, All the tools there are available on MATLAB: mathworks.com/matlabcentral/answers/415029. Just replace the Python Code with MATLAB or just run the Python from MATLAB (It is supported). $\endgroup$
    – Royi
    Jul 6, 2023 at 8:22
  • $\begingroup$ If you want simpler integration, you may use: github.com/YuvalNirkin/find_face_landmarks. $\endgroup$
    – Royi
    Jul 6, 2023 at 8:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.