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