how to count bit error
1 次查看(过去 30 天)
显示 更早的评论
clc
x=wavread('one.wav');
a=wavread('stego_message.wav');
y=((2^(nbits-1)*x(:,1)));
for i=1:length(y)
if y(i)<0
y(i)=-1*y(i);
end
end
tx=dec2bin(y);
p=((2^(nbits-1)*a(:,1)));
for j=1:length(p)
if p(j)<0
p(j)=-1*p(j);
end
end
rx=dec2bin(p);
off=0;
err= tx-rx(off+1:length(tx)+off);
I want to count error bit please some on help me
2 个评论
Geoff Hayes
2014-6-13
Muhammad - your above code is incomplete and won't run. What is nbits? What is tx? What is off?
What is your definition of the error bit? I know from a previous posting how your stego_message.wav file was generated, but you need to provide some context surrounding what you are trying to find with the above code.
Note that the two for loops can be removed and simply replaced with
y = abs(y);
p = abs(p);
since the purpose behind these two or loops is to just make all elements in y and p positive.
回答(1 个)
Geoff Hayes
2014-6-14
If you are trying to count the number of samples that have changed in the audio file before and after steganography, then why not just compare the two arrays and count the differences? Both integer sample arrays are of the same size and you have modified at most one bit in each based on your question at http://www.mathworks.com/matlabcentral/answers/133711-quantization-erorr-in-audio-steganography
sampleDiffCount = 0;
for i=1:length(y)
if y(i)~=p(i)
sampleDiffCount = sampleDiffCount + 1;
end
end
Now you have number of samples that are different between the original and modified wav file (and so the number of bits that have changed). You could easily add this functionality to your original code and not have to read in both files to do the comparison.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!