(完整 word 版)(绝对可运行)加密图像中的可逆数据隐藏算法 matlab 代码(基于张新鹏教授的算法)
%This is the program of Reversible Data Hiding in Encrypted Domain
clc;
clear;
%===============Read image===========================
original_p=rgb2gray(imread('LENA。tif’));
[m,n]=size(original_p);
%==============Image encryption======================
random_bits=rand(m,n*8)〈=0.5; %伪随机序列
for i=1:m
for j=1:n
s=0;
for k=0:7
b(k+1)=mod(fix(double(original_p(i,j))/(2^k)),2);
eb(k+1)=xor(b(k+1),random_bits(i,8*j+k-7));
s=s+eb(k+1)*(2^k);
end
encrypted_image(i,j)=s;
end
end
figure(1);
subplot(1,2,1);
imshow(original_p);
hold on;
title(’Original image',’fontsize’,16);
subplot(1,2,2);
encrypted_image=uint8(encrypted_image);
imshow(encrypted_image);
title('Encrypted image','fontsize',16);
%================Data embedding======================
size=8; %分块大小
N=6;%置乱周期
number1=3;
number2=N—number1;
lim_row=fix(m/size); %图像的分块数
lim_col=fix(n/size); %图像的分块数
bitts=3;
watermessage=rand(lim_row,lim_col)<0.5; %水印信息
%======pseudo_randomly=======
for i=1:lim_row
for j=1:lim_col
block_image{i,j}=encrypted_image((size*i—size+1):size*i,(size*j-size+1):size*j);
评论0
最新资源