This repository was archived by the owner on Mar 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest2.m
92 lines (87 loc) · 2.36 KB
/
test2.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
% % x = imread("origin-th.png","png");
% % y = imread("thumbnail.png","png");
% % [M,N] = size(x);
% % dif = double(0);
% % for i = 1:M
% % for j = 1:N
% % p = double(x(i,j));
% % q = double(y(i,j));
% % s = double(abs(p-q));
% % dif = dif + s/double(x(i,j));
% % end
% % end
% % dif = dif/double((M*N))
%
% %file: main.m
% %%the main function of the project
% whole = imread("apple.png","png");
% [M,N,C] = size(whole);
% blocksize = 32;
% MSB = 2;
% count = 20000;
% key = 1;
% m = M/blocksize;
% n = N/blocksize;
% values = zeros(m,n);%store the original average pixel of every block
% sub1 = zeros(blocksize);
% sub2 = zeros(blocksize);
% for chanal = 1 : C
% origin = whole(:,:,chanal);
% for i = 1 : m
% for j = 1 : n
% x = (i-1)*blocksize+1;
% y = (j-1)*blocksize+1;
% sub1(1:blocksize,1:blocksize) = origin(x:x+blocksize-1,y:y+blocksize-1);
% values(i,j) = mean2(sub1);
% end
% end
%
% embed_image = SaveSpace( origin , blocksize , MSB , count);
% EnImage = Encipher( embed_image , key); %encipher
% [AjImage,s] = Adjustment( EnImage , blocksize , values , MSB);
% whole(:,:,chanal) = AjImage(:,:);
% end
% imwrite(whole,"apple-res.png","png");
%
%
% Img=imread('dream\dream-.png');
% BW = Img;
% R=BW(:,:,1);
% [REDcounts,x] = imhist(R);
% G=BW(:,:,2);
% [Greencounts,y] = imhist(R);
% B=BW(:,:,3);
% [Bluecounts,z] = imhist(R);
% figure;
% subplot(131);imhist(R);title('Red');
% subplot(132);imhist(G);title('Green');
% subplot(133);imhist(B);title('Blue');
%file: main.m
%%the main function of the project
for pic = 1:20
whole = imread(strcat("temp\",num2str(pic),".jpeg"),"jpeg");
[M,N,C] = size(whole);
blocksize = 16;
MSB = 2;
count = 20000;
key = 1;
m = M/blocksize;
n = N/blocksize;
values = zeros(m,n);%store the original average pixel of every block
for chanal = 1 : C
origin = whole(:,:,chanal);
for i = 1 : m
for j = 1 : n
x = (i-1)*blocksize+1;
y = (j-1)*blocksize+1;
sub1(1:blocksize,1:blocksize) = origin(x:x+blocksize-1,y:y+blocksize-1);
values(i,j) = mean2(sub1);
end
end
embed_image = SaveSpace( origin , blocksize , MSB , count);
EnImage = Encipher( embed_image , key); %encipher
[AjImage,s] = Adjustment( EnImage , blocksize , values , MSB);
whole(:,:,chanal) = AjImage(:,:);
end
imwrite(whole,strcat("temp\res-",num2str(pic),".png"),"png");
end