利用直方图实现的可逆数据的隐藏算法简单,几乎不造成数据的丢失。当然,由于算法简单,要破解或者提取也是比较简单。可以作为其他数据隐藏的算法参考。
算法如下:
用matlab实现:
clear all;
close all;
im=imread('bar_embedded.bmp');
I=im;
[m,n]=size(I);
subplot(211);
imhist(I);
hold on
plot(gray_value1,p1,'r+');
hold off
seq=zeros(m,n);%获取信息初始化
for f1=1:n
for f2=1:m
if I(f1,f2)==(gray_value1+1)
seq(f1,f2)=1;%提取
I(f1,f2)=I(f1,f2)-1;
end
end
end %seq为提取信息
ind=I>=gray_value1+1;
I(ind)=I(ind)-1;
%恢复最小值对应点
ind1=seq0>0;
I(ind1)=seq0(ind1);
subplot(212);
imhist(I);
hold on
plot(gray_value1,p1,'r+');
hold off