【发布时间】:2020-11-12 13:53:15
【问题描述】:
我正在使用MATLAB 2013a来实现本文的算法An improved method for high hiding capacity based on LSB and PVD
论文中的图 3.1 描述了嵌入过程,当到达右分支的第 5 步时,MATLAB 计算出变量 v1 和 v2 的错误值。这是我的代码:
counter =1;
for i=1:size(stego,1)
for j=1:3:size(stego,2)
%% Step 1: Let the three pixels of a block be Pi, Pi+1, and Pi+2.
p0 = stego(i,j);
p1 = stego(i,j+1);
p2 = stego(i,j+2);
%% Step 2: Suppose Pi <= Pi+1 and Pi <= Pi+2.
if (p0 <= p1 && p0 <=p2)
% some code is here.....
else
% Otherwise, the reference pixel is Pi+1, and apply the steps 8 to 12
% to produce the stego-pixels.
bits = sm(1, counter:counter+k-1); %sm is a binary string 0011101101011.....
counter = counter+k;
g1 = dec2bin(p1,8);
k_old = bin2dec(g1(1,end-k+1:end));
g1(1,end-k+1:end) = bits;
k_new = bin2dec(bits);
g1 = bin2dec(g1);
% Compute the difference value kdif = kold ?knew.
k_diff = k_old - k_new;
% Now, compute P'i+1 using Eq. (3.22).
if (k_diff > 2^(k-1) && (g1+2^k>=0 && g1+2^k<=255))
p_1 = g1 + 2^k;
elseif (k_diff < -2^(k-1) && (g1 - 2^k >=0 && g1 - 2^k <= 255))
p_1 = g1 - 2^k;
else
p_1 = g1;
end
v11 = abs(p0 - p_1); %ERROR HAPPENS HERE
v22 = abs(p2 - p_1); %ERROR HAPPENS HERE
% REST OF THE CODE ....
(我已经删除了左分支的代码,因为它没有问题)
在调试我的代码时,matlab 正确显示了 p0 等于 64 和 p_1 等于 66 的值,所以等式 v11 = abs(p0 - p_1); 必须产生 2。但它给出 v11 = 0。
那么,这是 Matlab 的错误吗?还是我的代码有问题?
【问题讨论】:
标签: matlab security debugging image-processing steganography