Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am working on an assignment where we have to use the NEC algorithm for inserting and extracting a watermark from an image file. Using the techniques described in this article. I am at the point where I want to apply the similarity function in Matlab:

$$\begin{align*} X &= (x_1,x_2,\dotsc,x_n)\quad\text{original watermark}\\ X^* &= (x^*_1,x^*_2,\dotsc,x^*_n)\quad\text{extracted watermark}\\\\ sim(X, X^*) &= \frac{X^* * X}{\sqrt{X^* * X^*}}\\ \end{align*}$$

After that, the purpose is to compare the result to a threshold value to take a decision.

EDIT Question: what is the best way to implement the sim() function? The values of the watermark vectors are doubles.

share|improve this question
1  
I don't see a question. –  Qiaochu Yuan Feb 28 '13 at 4:39

1 Answer 1

up vote 1 down vote accepted

Well if you talking from an efficient/fastest/concise point of view, then MATLAB is vectorized. Let x1 be the vector of original watermark and let x2 be the vector of the extracted watermark then I would just do something like

dot(x1,x2)/sqrt(dot(x2,x2))

or even

dot(x1,x2)/norm(x2,2). They are identical.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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