left_eye=imread('e-1.jpg');
gray_left_eye=rgb2gray(left_eye);%左眼灰度图像
left_eye_edge=edge(gray_left_eye,'sobel');%用sobel算子提取左眼边界
imshow(left_eye_edge);
[y0,x0]=find(left_eye_edge==1);
A=length(x0);
x_c=sum(x0)/A;
y_c=sum(y0)/A;
mu_xx=(x0-x_c)'*(x0-x_c)/A;
mu_yy=(y0-y_c)'*(y0-y_c)/A;
mu_xy=(x0-x_c)'*(y0-y_c)/A;
a=sqrt(2)*sqrt(mu_xx+mu_yy+sqrt((mu_xx-mu_yy)^2+4*mu_xy^2));
b=sqrt(2)*sqrt(mu_xx+mu_yy-sqrt((mu_xx-mu_yy)^2+4*mu_xy^2));
left=b/a;
if(left<0.32)
text(width/2,height/2,'close', 'Color', 'r', 'FontWeight', 'bold');
else
text(width/2,height/2,'open', 'Color', 'r', 'FontWeight', 'bold');
end