Code
Code
R = (255-Cr).^2;
G = Cb./Cr;
CrCb = Cr./Cb;
EyeC=(Q+R+G)/3;
CRS = Cr.^2;
ssCRS = sum(sum(CRS));
ssCrCb=sum(sum(CrCb));
eta = 0.95 * ssCRS/ssCrCb;
x= CRS - eta * Cr./Cb;
MM = CRS.*x.*x;
SE=strel('disk',10) ;
UP=imdilate(y,SE);
Down=imerode(y,SE);
EyeY= UP./(Down+1);
EyeMap=EyeY.*EyeC;
img = mat2gray(EyeMap);
if img<0.85
sas=0;
else
sas=img;
end
% lll=graythresh(img);
bimg=im2bw(sas);
% figure;imshow(img);
cform = makecform('srgb2lab');
J = applycform(I,cform);
K=J(:,:,2);
L=graythresh(J(:,:,2));
BW1=im2bw(J(:,:,2),L);
M=graythresh(J(:,:,3));
BW2=im2bw(J(:,:,3),M);
O=BW1.*BW2;
l1=strel('disk',8);
% Ob1=imerode(O,l1);
% O=~(Ob1);
% figure;imshow(I);
% hold on;
% plot(a1,a2,'r*');
% hold off;
[m1 n1] = size(img);
for i=1:m1
for j=1:n1
if img(i,j)<0.7
sas(i,j)=0;
else
sas(i,j)=img(i,j);
end
end
end
if img<0.8
sas=0;
else
sas=img;
end
sasb=im2bw(sas);
ll=strel('disk',15);
sasbb=imdilate(sasb,ll);
ss=regionprops(sasbb,'centroid');
cc=cat(1,ss.Centroid);
a11=cc(:,1);
a12=cc(:,2);
%
% P=bwlabel(O,8);
% BB=regionprops(P,'Boundingbox');
% BB1=struct2cell(BB);
% BB2=cell2mat(BB1);
%
% [s1 s2]=size(BB2);
% mx=0;
% for k=3:4:s2-1
%
p=BB2(1,k)*BB2(1,k+1);
%
if p>mx && (BB2(1,k)/BB2(1,k+1))<1.8
%
mx=p;
%
j=k;
%
end
% end
figure;imshow(I);
hold on;
plot(a11,a12,'r*');
% rectangle('Position',[BB2(1,j-2),BB2(1,j-1),BB2(1,j),BB2(1,j+1)],'EdgeColor','
r' )
hold off;
%
%
%
%
%
%
%
%
%
%
segment(x,y)=0;
end
end
end
im(:,:,1)=I(:,:,1).*segment;
im(:,:,2)=I(:,:,2).*segment;
im(:,:,3)=I(:,:,3).*segment;
imshow(uint8(im));
end
clear all;
close all;
clc;
tic;
a1 = imread('image201112190001.jpg');
a2 = imread('image201112190001.jpg');
[s1 s2 s3] = size(a1);
[t1 t2 t3] = size(a2);
if s1~=t1 && s2~=t2 && s3~=t3
disp('Error Image Size does not match');
else
ag1 = rgb2gray(a1);
ag2 = rgb2gray(a2);
y = imabsdiff(ag1,ag2);
sad1 = sum(y);
sad2 = sum(sad1);
if sad2==0
disp('Both Images are equal');
else
disp('Unequal Images');
end
end
toc;
%
%
%
%
%
%
%
%
%
Q = Cb.^2;
R = (255-Cr).^2;
G = Cb./Cr;
CrCb = Cr./Cb;
EyeC=(Q+R+G)/3;
CRS = Cr.^2;
ssCRS = sum(sum(CRS));
ssCrCb=sum(sum(CrCb));
eta = 0.95 * ssCRS/ssCrCb;
x= CRS - eta * Cr./Cb;
MM = CRS.*x.*x;
SE=strel('disk',4) ;
UP=imdilate(y,SE);
Down=imerode(y,SE);
EyeY= UP./(Down+1);
EyeMap=EyeY.*EyeC;
subplot(1,4,1), imagesc(I);title ('Face');axis off;
subplot(1,4,2), imagesc(Q);title ('Cb^2');axis off;
subplot(1,4,3), imagesc(R);title ('(Cr-complement)^2');axis off;
subplot(1,4,4), imagesc(EyeC);title ('Eye-Map-C'); axis off;
colormap(gray);
subplot(1,4,1), imagesc(UP);title ('Dilation'); axis off;
subplot(1,4,2), imagesc(Down);title ('Erotion'); axis off;
subplot(1,4,3), imagesc(EyeY);title ('EyeY'); axis off;
subplot(1,4,4),
imagesc(EyeMap);
colormap(gray);
end
Mouse Movement
Right Click
clc
% clear
S.ja=java.awt.Robot;
S.ja.mousePress(java.awt.event.InputEvent.BUTTON1_MASK);
S.ja.mouseRelease(java.awt.event.InputEvent.BUTTON1_MASK);
pause(0.001)
S.ja.mousePress(java.awt.event.InputEvent.BUTTON1_MASK);
S.ja.mouseRelease(java.awt.event.InputEvent.BUTTON1_MASK);
Left Click
clc
% clear all
S.ja=java.awt.Robot;
S.ja.mousePress(java.awt.event.InputEvent.BUTTON1_MASK);
S.ja.mouseRelease(java.awt.event.InputEvent.BUTTON1_MASK);
Left
function[]=left()
pos=get(0,'PointerLocation')
[m n]=size(pos)
set(0,'PointerLocation',[m+100 n])
Right
clc
[pos]=get(0,'PointerLocation')
m=pos(1);
n=pos(2);
set(0,'PointerLocation',[m+10 n])
Up
clc
[pos]=get(0,'PointerLocation')
m=pos(1);
n=pos(2);
set(0,'PointerLocation',[m n+10])
Down
clc
[pos]=get(0,'PointerLocation')
m=pos(1);
n=pos(2);
set(0,'PointerLocation',[m n-10])