Evaluating the similarity of watermarks 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.

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.
