-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainDFT.m
executable file
·70 lines (53 loc) · 1.78 KB
/
mainDFT.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
%% init
dim = 256;
imgnum = 20;
wmlength = 1024;
dimblk = 32; % block dimension
wmnum = 1000;
load imgs.mat
% imgs = zeros(dim, dim, imgnum);
% for i = 1:imgnum
% imgFile = ['image',num2str(i),'.bmp'];
% % imgs(:,:,i) = imresize(imread(['images/',imgFile]), [dim dim]);
% imgs(:,:,i) = im2double(imresize(imread(['images/',imgFile]), [256 256]));
% end
load DCTblks.mat
% DCTblks = compDCTblks(imgs, imgnum);
load pnseqs.mat
% shift = round(rand() * wmnum);
% pnseqs = genPN(wmlength, shift);
% idx = randperm(4096);
% 1:2730, 2731:end (2/3 for parameter estimation, 1/3 for model testing)
%% main process
% 20 images, 1000 watermarks, 9 embed positions, 4 groups of data, 50 thresholds.
% At every execution we calculate the corresponding test statistics
% with and without the watermark.
D = dctmtx(8);
img2dct = @(block_struct) D * block_struct.data * D';
dct2img = @(block_struct) D' * block_struct.data * D;
embedScheme = 'DFT';
fftobj = vision.FFT;
ifftobj = vision.IFFT;
attackCategory = 'jpeg';
imgATT0 = attack(imgs, attackCategory);
coef0 = zeros(size(imgATT0));
for i = 1:imgnum
coef0(:,:,i) = abs(fftshift(step(fftobj, squeeze(imgATT0(:,:,i)))));
end
% params = getParams(ATTDCTblks0, lktbl);
% params: sitenum X imgnum X modelnum X 2
result = zeros(wmnum, imgnum, 2, 2);
masksize = wmlength;
[mask, mask_symmetry] = compMaskDFT(dim,dim,masksize);
for j = 1:wmnum
wm = pnseqs(1:wmlength, j);
disp([' watermark: ', num2str(j)]);
% tic;
embedDFT;
imgATT1 = attack(imgWM, attackCategory);
detectDFT;
% toc;
% return;
end
filename = ['result_', embedScheme, attackCategory, '2.mat'];
save(filename, 'result');