How to read LSB of audio sample?

조회 수: 5 (최근 30일)
manisha sharma
manisha sharma 2015년 3월 27일
댓글: manisha sharma 2015년 3월 29일
Hello everyone... I am working on audio steganography project.And i need to read and manipulate LSB of the audio sample.Please tell me a way to do this. Thanks in advance.
  댓글 수: 2
manisha sharma
manisha sharma 2015년 3월 27일
The audio samples are in floating point representation.When i use dec2bin to convert the floating point number in binary, it only shows binary equivalent of digits before decimal point.But i want to reach LSB of the sample.
James Tursa
James Tursa 2015년 3월 27일
Do you simply want to overwrite the trailing least significant byte of the mantissa with a different bit pattern? I.e., change the floating point value slightly but have your desired pattern embedded in the trailing bits?

댓글을 달려면 로그인하십시오.

채택된 답변

James Tursa
James Tursa 2015년 3월 27일
Here is an example of overwriting the least significant byte of a double with other bit patterns, in this case the string 'hidden':
% Arbitraty 6 element double vector
>> x = rand(1,6)
x =
0.957166948242946 0.485375648722841 0.800280468888800 0.141886338627215 0.421761282626275 0.915735525189067
% Find the location of the least significant byte in the double for this machine
>> LSB = find(typecast(1,'uint8')~=typecast(1+eps,'uint8'))
LSB =
1
% Re-interpret the bytes of the double vector as a uint8 vector
>> u = typecast(x,'uint8')
u =
Columns 1 through 35
153 127 112 148 28 161 238 63 82 133 98 6 101 16 223 63 124 40 48 201 229 155 233 63 216 151 19 224 84 41 194 63 202 83 230
Columns 36 through 48
8 35 254 218 63 32 30 143 150 180 77 237 63
% Our replacement data
>> s = 'hidden'
s =
hidden
% Construct the indexes for the replacement bytes
>> lower_bound = LSB
lower_bound =
1
>> upper_bound = LSB + 8*(numel(s)-1)
upper_bound =
41
% Replace the floating data with our new data
>> u(lower_bound:8:upper_bound) = s
u =
Columns 1 through 35
104 127 112 148 28 161 238 63 105 133 98 6 101 16 223 63 100 40 48 201 229 155 233 63 100 151 19 224 84 41 194 63 101 83 230
Columns 36 through 48
8 35 254 218 63 110 30 143 150 180 77 237 63
% Turn result back into double vector (note result is close to original x)
>> y = typecast(u,'double')
y =
0.957166948242940 0.485375648722843 0.800280468888797 0.141886338627212 0.421761282626269 0.915735525189076
% Now do the reverse to recover our hidden data
% Re-interpret the bytes of the double vector as a uint8 vector
>> w = typecast(y,'uint8')
w =
Columns 1 through 35
104 127 112 148 28 161 238 63 105 133 98 6 101 16 223 63 100 40 48 201 229 155 233 63 100 151 19 224 84 41 194 63 101 83 230
Columns 36 through 48
8 35 254 218 63 110 30 143 150 180 77 237 63
% Pick off our hidden bytes and re-interpret as a string
>> char(w(lower_bound:8:upper_bound))
ans =
hidden
  댓글 수: 3
manisha sharma
manisha sharma 2015년 3월 28일
I have no knowledge about uint8.So can you please tell me about the use of uint8 (in the above example you have given).
Also it seems that for decoding we need to know the length of message 's'.Is it so?
Because while calculating Upper_bound we need length of 's' ie. our text message. But on the decoding time we have our encoded audio only.So i think, i need to embed the value of Upper_bound in audio itself.
This is what i think.Please can you clear my doubts?
Thanks...
manisha sharma
manisha sharma 2015년 3월 29일
This method is not working for audio samples.May be because audio samples have large digits after decimal, example 3.0518e-004
What should i do?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio Plugin Creation and Hosting에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by