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!