I have a watermarked signal WATERMARKED SIGNAL

And the actual watermark WATERMARK

In Matlab, I need to find out the delay parameters $d_i$ which can be considered as the embedded information.such that $0\leq d_i \leq 100$. There are 5 of them. I am afraid I don't understand the task, and my professor is on leave and will not be back before the task deadline. Would anyone be kind enough to at least tell me something about it? Show me a piece of code or a source? I can't seem to find any information about the code online.


All instructions:enter image description here

enter image description here

EDIT: Thank you Mathew for the answer. Now I believe I know what to do mathematically but still can't achieve the answer I am required (This must come from the fact I am an amateur with Matlab). I tried to play with your code but I have no idea what I need to change in order for it to work. So I will show you the code I created and if you are still interested in helping me, could you tell me what else needs to be changed?

%Step 1. Upload sound files

[x,fs] = audioread('sample4_va18535.wav');
[m,fs] = audioread('assignment4_embedded_signal.wav');

%Step 2. Determine number of samples and create the window

N      = 132300;
w      = blackman(N);

%Step 3. Multiply both signals with the window to get x_w[n] and m_w[n]

xw     = x .* w;
mw     = m .* w;

%Step 4. Apply FFT to get X_w(k) and M_w(k)

XW     = fft(xw);
MW     = fft(mw);

%Step 5. Conjugate M_w(k) to get M_w*(k)

MWconj    = conj(MW);

%Step 6. Normalize XW * M_w*

Norm   = abs(XW .* MWconj);

%Step 7. Take IFFT

xwmw   = ifft((XW .* MWconj) ./ (Norm));

%Step 8. Plot everything (Using your method)

lags   = linspace(-N/2, N/2, N);

figure(1); hold off;
% find the 5 peaks, then plot them
[pks,locs] = findpeaks(fftshift(abs(xwmw)),'NPeaks',5,'MinPeakHeight',0.0075);
hold on;
xlabel('Correlation Lags'); ylabel('Scaled Correlation Magnitude (dB)')
grid on;
title('Watermark Cross-Correlation');

What I get is this : Surely it looks nothing like what you've got enter image description here

Thank you for being patient with me. And I will understand if you can't find time to help me more.

  • $\begingroup$ What is your background in signal processing? Do you know about or are you familiar cross-correlation? $\endgroup$ – matthewjpollard Jan 5 at 19:12
  • $\begingroup$ I come from maths, and I met signal processing for the first time in late October. I don't know what cross-correlation is. From what I gathered this task requires usage of IDFT, and nonlinear phase-correlation comes into play? I need all the help I can get... $\endgroup$ – Scavenger23 Jan 5 at 19:36
  • $\begingroup$ Yes, you can accomplish cross-correlation via usage of DFTs. Let me play with the signals you have linked to make sure there isn't anything funny going on behind the scenes, and then I'll provide an answer at a later time. $\endgroup$ – matthewjpollard Jan 5 at 20:01
  • $\begingroup$ If you do I will be eternally grateful. I looked at the mathworks page with cross-correlation function but it just provided more confusion. I found the lag difference between the samples to be 3295. But this number is meaningless to me. Thank you in advance! $\endgroup$ – Scavenger23 Jan 5 at 20:03
  • $\begingroup$ Well, it certainly looks encoded in some way, which means that it likely isn't as simple as a basic cross-correlation and find the peak. Were you given any other information? If so, could you provide it in your original post? $\endgroup$ – matthewjpollard Jan 5 at 20:39

Thank you for posting the additional information, it certainly helped. I'll try to do a prose explanation with less "math" in it, and then point you in what is the right direction.

That's certainly a long winded problem statement, and I believe the solution is actually simpler that your professor may be making it out to be. From reading the problem statement, a watermark has been made and was supplied to you. This watermark is just sampled Gaussian noise, such that it lacks coherent frequency content, i.e. the spectral energy of the watermark is not located at any specific frequency (as opposed to say, a constant frequency signal like a sinusoid).

So we've got our original signal, we have our watermark signal, now it's time to actually watermark. The simplest approach would just be adding the watermark signal to the original signal. Your professor has gone a step ahead and added 5 copies of the signal. Each one of these copies has its own time delay, as well as its own amplitude. So, after we add in our 5 watermarks to our signal, we have the signal Xm

Since there are 5 copies of the signal at 5 unique points in time in Xm, that means if we did a cross-correlation with our watermark signal and Xm, we would expect to see 5 distinct peaks at different amplitudes. This operation is typically called a matched filter, and you can think of it as using a finding the "locations" (in your professor's words, the delay parameters; think of this as when each watermark "starts" in Wm) of some given template (i.e. the watermark) in your recorded signal.

Your professor has gone ahead and detailed out how you can accomplish cross-correlation in the frequency domain. This is often the preferred method, since it is typically much more computationally efficient. Your professor has also detailed common ways to improve cross-correlation detection, specifically the use of windowing functions as well as the use of frequency normalization.

In turns out those methods he described will be very important for your success. The watermark signals are pretty low gain (naturally), so we'll need to maximize the signal to noise ratio (SNR) as much as possible.

I think that since this is seemingly an assignment of some sort, I'm not willing to just give you the answer in numeric or code form, but here's a pictorial output of what I got: Watermark Cross-Correlation

You can see that I've marked the 5 points corresponding to the time delayed version of the signal with red X marks. These peaks are easily 5x larger than any other point in the output of the cross-correlation, so one can easily conclude that these are statistically significant, and point to the location of the delayed watermark signals.

Here's some code I used. Feel free to play around with it and see if you get satisfactory results (note: "data" is your Xm signal, and "wm" is your watermark signal:

% Determine number of samples for the correlation lag vector
nsamps = numel(data);

% define a window function. Taylor windows give great performance
win    = taylorwin(nsamps,7,-10);

% window each signal
xin    = data;
wmw    = win .* wm;

% make the signals complex for phase coherency
xin    = hilbert(data);
wmw    = hilbert(wmw);

% perform cross-correlation in the frequency domain
xf     = ( fft((xin)) .* conj(fft((wmw))) );
% transform out of the frequency domain while normalizing
x      = ifft(xf ./ (abs(xf)+1));

lags   = linspace(-nsamps/2, nsamps/2, nsamps);

figure(1); hold off;
% find the 5 peaks, then plot them
[pks,locs] = findpeaks(fftshift(abs(x)),'NPeaks',5,'MinPeakHeight',0.0075);
hold on;
xlabel('Correlation Lags'); ylabel('Scaled Correlation Magnitude (dB)')
grid on;
title('Watermark Cross-Correlation');

So hopefully that gets you going in the right direction. Like I mentioned before, the watermark signals are pretty low gain, so make sure you do that normalization. The windowing function is arguably not necessary, but they're pretty standard in practice since they help your cross-correlation "behave" a bit better.

  • $\begingroup$ Thank you very much for this answer. I have feq questions if you decide to answer them. 1. The task says we should use $m[-n]$ and not $m[n]$ Should it be changed? 2. You have added "1" to your normalization. Perhaps to "break" the code so it doesn't give me an answer? But when i remove the "+1" the vector x is just vecotr full of NaNs This is the line I am refering to : x = ifft(xf ./ (abs(xf)+1)); $\endgroup$ – Scavenger23 Jan 5 at 23:35
  • $\begingroup$ I’ll start with the second one: when doing that normalization, it’s possible for one of the frequency bins to be a 0. By removing the +1, you’ll get an indeterminate form of x/0, hence your NaN output. I just made it +1 since the normalization is a bit arbitrary. You could instead use a very small number and achieve similar results. For m[-n], I included that in the DFT by using the conjugate in the frequency domain, which corresponds to “time reversal” in the time domain, which is typically demoted by m[-n]. Hope that helps make things a bit more clear! $\endgroup$ – matthewjpollard Jan 6 at 1:10
  • $\begingroup$ I should also note that the Hilbert transform is absolutely not necessary for your application. Phase is important in other areas, and the Hilbert transform allows you to maintain phase information. I think you’ll find that the results without using the Hilbert transform will be nearly identical (you may need to change the peak finding threshold though) $\endgroup$ – matthewjpollard Jan 6 at 1:12
  • $\begingroup$ I have added work i did if you are still willing to help me a little bit more $\endgroup$ – Scavenger23 Jan 6 at 12:46
  • $\begingroup$ So zoom in on that plot where you have the main spikes. Your problem statement says that the delays are between 0 and 100, so simply zoom into that range. I think you’ll notice that the magnitude is much larger than 0.075 on those peaks in that range. In my example that threshold was sufficient. For you, you will need to adjust the threshold in the find peaks command to a sufficient number. $\endgroup$ – matthewjpollard Jan 6 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.