-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAveragingAttack.m
75 lines (74 loc) · 1.94 KB
/
AveragingAttack.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
clc;
close all;
clear all;
p=10;
chtimg=zeros(256,256);
notr=input('Enter no of traitors');
for i=1:notr
traitor(i)=input('Enter Traitor');
end
ti=0
for m=1:p
str = int2str(m);
str = strcat('E:\M Tech\Semester 4\Project Work\watermarked images\',str,'.bmp');
a = imread(str);
b=size(a);
c=size(find(traitor-m));
sizc=c(2);
if (notr~=sizc)
chtimg=chtimg+double(a/notr);
ti=ti+1
end
b=size(a);
for i=1:(b(1)*b(2))
db(i,m)=a(i);
end
end
A=db';
% %e=0.1;
% % beta=0;
d=size(A,2);
meanvector=mean(db,2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Calculating mean centered images
for l=1:p;
meancenter(1:b(1)*b(2),l)=double(db(1:b(1)*b(2),l))-meanvector(1:b(1)*b(2));
end
mc=meancenter';
test=chtimg;
for i=1:b(1)*b(2)
testvector(i,1)=test(i);
end
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%Finding the mean centered test image
meancenttest=double(testvector)-meanvector;
mct=meancenttest';
% % %k=achlioptasreduceddimension(n,e,beta);
for t=1:10
k=1500;
R=achlioptasRandomMatrix(d,k);
r=(1/sqrt(k))*R;
%load AveragingAttack r
projectedImages = [];
for i = 1 : p
temp = mc(i,:)*r; % projection of centered images into facespace
projectedImages = [projectedImages; temp];
end
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % %%projecting the test image as span of eigen faces
projectedTestImage = mct*r; % Test image feature vector
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % %%Finding the eucledian distance between test image and data base images
for i=1:p
euc(i,t)=(norm(projectedImages(i,:)-projectedTestImage))^2;
end
end
eu=mean(euc,2);
(eu./max(eu))'
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % %% Image with the minimum eucledian distance is the recognised image
%[mindis arg_min]=min(euc);
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%
% arg_min
% mindis
%no=euc./max(euc)