how to count bit error
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Geoff Hayes
le 13 Juin 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.
Réponses (1)
Geoff Hayes
le 14 Juin 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Encryption / Cryptography dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!