function [R,n]=pspace(points)
vid=evalin('base', 'vid');
I=getsnapshot(vid);
Aspace=[points(1,1) points(1,2)];
Bspace=[points(2,1) points(2,2)];
Cspace=[points(3,1) points(3,2)];
Dspace=[points(4,1) points(4,2)];
Espace=[points(5,1) points(5,2)];
Fspace=[points(6,1) points(6,2)];

IspaceA=imcrop(I,[Aspace,6,6]);
IfilterA=(IspaceA>100);
pA=(sum(sum(IfilterA)))/49;
if pA<=0.3
    R(1,1)=0;
else 
    R(1,1)=1;
end
IspaceB=imcrop(I,[Bspace,6,6]);
IfilterB=(IspaceB>100);
pB=(sum(sum(IfilterB)))/49;
if pB<=0.3
    R(2,1)=0;
else 
    R(2,1)=1;
end
IspaceC=imcrop(I,[Cspace,6,6]);
IfilterC=(IspaceC>100);
pC=(sum(sum(IfilterC)))/49;
if pC<=.3
    R(3,1)=0;
else 
    R(3,1)=1;
end
IspaceD=imcrop(I,[Dspace,6,6]);
IfilterD=(IspaceD>100);
pD=(sum(sum(IfilterD)))/49;
if pD<=0.3
    R(4,1)=0;
else 
    R(4,1)=1;
end
IspaceE=imcrop(I,[Espace,6,6]);
IfilterE=(IspaceE>100);
pE=(sum(sum(IfilterE)))/49;
if pE<=0.3
    R(5,1)=0;
else 
    R(5,1)=1;
end
IspaceF=imcrop(I,[Fspace,6,6]);
IfilterF=(IspaceF>100);
pF=(sum(sum(IfilterF)))/49;
if pF<=0.3
    R(6,1)=0;
else 
    R(6,1)=1;
end
nind=find(R==0);%find index of R with 0 element
n=min(nind);
