how to count bit error

1 view (last 30 days)
Muhammad fayyaz
Muhammad fayyaz on 13 Jun 2014
Answered: Geoff Hayes on 14 Jun 2014
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 Comments
Geoff Hayes
Geoff Hayes on 13 Jun 2014
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.
Muhammad fayyaz
Muhammad fayyaz on 14 Jun 2014
Respected Sir,
I have two .wav files one before steganography and one after steganography i want to compare both the files and see that there is no difference or a little bit difference. I just need some parameters for audio(.wav) file. I have calculated SNR and MSE now i need 2 more . so if you have any idea please share it with me.

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 14 Jun 2014
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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!