-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgray.m
31 lines (31 loc) · 1.03 KB
/
gray.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
for no = 1 : 18
name = strcat("gray\",num2str(no),".png")
origin = imread(name,"png");
[M,N] = size(origin);
blocksize = 16;
MSB = 2;
count = 3000000;
key = 1;
m = M/blocksize;
n = N/blocksize;
values = zeros(m,n);%store the original average pixel of every block
sub = zeros(blocksize);
for i = 1 : m
for j = 1 : n
x = (i-1)*blocksize+1;
y = (j-1)*blocksize+1;
sub(1:blocksize,1:blocksize) = origin(x:x+blocksize-1,y:y+blocksize-1);
values(i,j) = mean2(sub);
end
end
embed_image = SaveSpace( origin , blocksize , MSB , count);
EnImage = Encipher( embed_image , key ); %encipher
[AjImage,s] = Adjustment( EnImage , blocksize , values , MSB);
% origin = imresize(origin,[768,1024]);
% if (size(size(origin))== [1,3])
% origin = rgb2gray(origin);
% size(origin)
% end
% imwrite(origin,strcat("gray\",num2str(no),".png"),"png");
imwrite(AjImage,strcat("gray-res\",num2str(no),".png"),"png");
end