# Similarity

(Redirected from Dissimilarity)

Similarity may refer to:

## In signal processing

Similarity between two different signals is also important in the field of signal processing. Below are some common methods for calculating similarity.

For instance, let's consider two signals represented as ${\displaystyle x[m,n]}$ and ${\displaystyle y[m,n]}$, where ${\displaystyle m=0,1,2,...,M-1}$ and ${\displaystyle n=0,1,2,...,N-1}$.

### Maximum error (ME)

Measuring the maximum magnitude of the difference between two signals. Maximum error is useful for assessing the worst-case scenario of prediction accuracy
${\displaystyle ME=\max(\left|y[m,n]-x[m,n]\right|)}$

### Mean squared error (MSE)

Measuring the average squared difference between two signals. Unlike the maximum error, mean squared error takes into account the overall magnitude and spread of errors, offering a comprehensive assessment of the difference between the two signals.
${\displaystyle MSE={\frac {1}{MN}}\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|y[m,n]-x[m,n]\right|^{2}}$

### Normalized mean square error (NMSE)

NMSE is an extension of MSE. It is calculated by normalizing the MSE with the signal power, enabling fair comparisons across different datasets and scales.
${\displaystyle NMSE={\frac {\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|y[m,n]-x[m,n]\right|^{2}}{\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|x[m,n]\right|^{2}}}}$

### Root-mean-square deviation (RMSE)

RMSE is derived from MSE by taking the square root of the MSE. It downscale the MSE, providing a more interpretable and comparable measure for better understanding for outcome.
${\displaystyle RMSE={\sqrt {\frac {\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|y[m,n]-x[m,n]\right|^{2}}{\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|x[m,n]\right|^{2}}}}}$

### Normalized root-mean-square error (NRMSE)

An extension of RMSE, which allows for signal comparisons between different datasets and models with varying scales.
${\displaystyle NRMSE={\sqrt {\frac {\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|y[m,n]-x[m,n]\right|^{2}}{\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|x[m,n]\right|^{2}}}}}$

### Signal-to-noise ratio (SNR)

In signal processing, SNR is calculated as the ratio of signal power to noise power, typically expressed in decibels.
A high SNR indicates a clear signal, while a low SNR suggests that the signal is corrupted by noise. In this context, the signal MSE can be considered as noise, and the similarity between two signals can be viewed as the equation below:
${\displaystyle SNR=10\log _{10}{\frac {\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|x[m,n]\right|^{2}}{\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|y[m,n]-x[m,n]\right|^{2}}}}$

### Peak signal-to-noise ratio (PSNR)

A metric used to measure the maximum power of a signal to the noise. It is commonly used in image signals because the pixel intensity in an image does not directly represent the actual signal value. Instead, the pixel intensity corresponds to color values, such as white being represented as 255 and black as 0
• Gray scale image:
${\displaystyle PSNR_{gray}=10\log _{10}{\frac {X_{max}^{2}}{{\frac {1}{MN}}\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|y[m,n]-x[m,n]\right|^{2}}}}$
• Color image:
${\displaystyle PSNR_{color}=10\log _{10}{\frac {X_{max}^{2}}{{\frac {1}{3MN}}\sum _{R,G,B}\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|y[m,n]-x[m,n]\right|^{2}}}}$

### ${\displaystyle L_{\alpha }}$-Norm

A mathematical concept used to measure the distance between two vectors. In signal processing, the L-norm is employed to quantify the difference between two signals. The L1-norm corresponds to the Manhattan distance, while the L2-norm corresponds to the Euclidean distance .
${\displaystyle \left\|y-x\right\|_{\alpha }=\left(\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|y[m,n]-x[m,n]\right|^{\alpha }\right)^{\frac {1}{\alpha }}}$
${\displaystyle {\frac {1}{MN}}\left\|y-x\right\|_{\alpha }={\frac {1}{MN}}\left(\sum _{m=0}^{M-1}\sum _{n=0}^{N-1}\left|y[m,n]-x[m,n]\right|^{\alpha }\right)^{\frac {1}{\alpha }}}$

### Structural similarity (SSIM)

SSIM is a similarity metric specifically designed for measuring the similarity between two image signals. Unlike other similarity measures, SSIM leverages the strong interdependencies between neighboring pixels, providing a measure that closely aligns with human visual perception and feeling of similarity.
${\displaystyle {\hbox{SSIM}}(x,y)={\frac {(2\mu _{x}\mu _{y}+c_{1})(2\sigma _{xy}+c_{2})}{(\mu _{x}^{2}+\mu _{y}^{2}+c_{1})(\sigma _{x}^{2}+\sigma _{y}^{2}+c_{2})}}}$
with:
• ${\displaystyle \mu _{x}}$ the pixel sample mean of ${\displaystyle x}$;
• ${\displaystyle \mu _{y}}$ the pixel sample mean of ${\displaystyle y}$;
• ${\displaystyle \sigma _{x}^{2}}$ the variance of ${\displaystyle x}$;
• ${\displaystyle \sigma _{y}^{2}}$ the variance of ${\displaystyle y}$;
• ${\displaystyle \sigma _{xy}}$ the covariance of ${\displaystyle x}$ and ${\displaystyle y}$;
• ${\displaystyle c_{1}=(k_{1}L)^{2}}$, ${\displaystyle c_{2}=(k_{2}L)^{2}}$ two variables to stabilize the division with weak denominator;
• ${\displaystyle L}$ the dynamic range of the pixel-values (typically this is ${\displaystyle 2^{\#bits\ per\ pixel}-1}$);
• ${\displaystyle k_{1}=0.01}$ and ${\displaystyle k_{2}=0.03}$ by default.