function loca = wm_type_0(loca,w,step,g)

%输入: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:100
step if a11-a21<=g %如果满足条件,a11增,a12减 a11 = a11 + s; a21 = a21 - s; else break; %不满足条件,跳出此循环 end end %-----如果a12和a22不满足条件,则也要调整------------ if a12-a22>g for s = step:step:100*step if a12-a22>=g %如果满足条件,a12减,a22增 a12 = a12 - s; a22 = a22 + s; else break; %不满足条件,跳出此循环 end end end

    end
    if 1 == w(index)            
        for s = step:step:100*step
            if a11-a21>=-g   %如果满足条件,a11减,a21增
                a11 = a11 - s;
                a21 = a21 + s;
            else
                break;     %不满足条件,跳出此循环
            end
        end
         %-----如果a12和a22不满足条件,则也要调整------------
        if a12-a22<-g
            for s = step:step:100*step
                if a12-a22<=-g   %如果满足条件,a12增,a22减
                    a12 = a12 + s;
                    a22 = a22 - 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

注意,在LH子带中,需要额外调整a12和a22的值,因为这两个值的差值也需要满足一定的条件

已知此函数用于在HL子带嵌入水印function loca = wm_type_0locawstepg输入:loca为要嵌入水印的子带输出:loca为嵌入水印后的子带m2n2 = sizeloca;index = 1;取出22的块for k = 12m2-1 for kk = 12n2-1 tem = locakk+1kkkk+1; a11 = tem11;

原文地址: https://www.cveoy.top/t/topic/fF5H 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录