基于HL子带的数字水印嵌入算法 - Matlab实现
function loca = wm_type_1(loca,w,step,g)
% 此函数用于在HL子带嵌入水印
% 输入:loca为要嵌入水印的子带
% 输出:loca为嵌入水印后的子带
[m2,n2] = size(loca);
index = 1;
%取出2*2的块
for k = 1:2:m2-1
for kk = 1:2:n2-1
tem = loca(k:k+1,kk:kk+1);
a11 = tem(1,1);
a12 = tem(1,2);
a21 = tem(2,1);
a22 = tem(2,2);
if 0 == w(index)
for s = step:step:100*step
if a12-a22<=g %如果满足条件,a22增,a12减
a12 = a12 - s;
a22 = a22 + s;
else
break; %不满足条件,跳出此循环
end
end
%-----如果a11和a21不满足条件,则也要调整------------
if a11-a21<=-g
for s = step:step:100*step
if a12-a22>=g
a12 = a12 - s;
a22 = a22 + s;
a11 = a11 + s;
a21 = a21 - s;
else
break;
end
end
end
if a11-a21>=g
for s = step:step:100*step
if a12-a22<=-g
a12 = a12 + s;
a22 = a22 - s;
a11 = a11 - s;
a21 = a21 + s;
else
break;
end
end
end
%-----------------------------------------------------
end
if 1 == w(index)
for s = step:step:100*step
if a12-a22>=-g %如果满足条件,a22增,a12减
a12 = a12 + s;
a22 = a22 - s;
else
break; %不满足条件,跳出此循环
end
end
%-----如果a11和a21不满足条件,则也要调整------------
if a11-a21<=-g
for s = step:step:100*step
if a12-a22>=g
a12 = a12 - s;
a22 = a22 + s;
a11 = a11 + s;
a21 = a21 - s;
else
break;
end
end
end
if a11-a21>=g
for s = step:step:100*step
if a12-a22<=-g
a12 = a12 + s;
a22 = a22 - s;
a11 = a11 - s;
a21 = a21 + s;
else
break;
end
end
end
%-----------------------------------------------------
end
index = index + 1;
tem(1,1) = a11;
tem(1,2) = a12;
tem(2,1) = a21;
tem(2,2) = a22;
loca(k:k+1,kk:kk+1) = tem;
end
end
end
原文地址: https://www.cveoy.top/t/topic/jpQN 著作权归作者所有。请勿转载和采集!