improc.evaluation package

Submodules

improc.evaluation.quality module

improc.evaluation.quality.mse(o, r)[source]

Mean Squared Error

The Mean Squared Error (MSE) is expressed as

\[{\rm MSE} = \frac{1}{MN}\sum_{i=1}^{M}\sum_{j=0}^{N}[|{\bm I}(i,j)|, |\hat{\bm I}(i, j)|]^2 \]
Parameters:
  • o (ndarray) – Orignal signal matrix.
  • r (ndarray) – Reconstructed signal matrix
Returns:

MSE – Mean Squared Error

Return type:

float

improc.evaluation.quality.normalization(x)[source]
improc.evaluation.quality.psnr(ref, A, Vpeak=None, mode='simple')[source]

Peak Signal-to-Noise Ratio

The Peak Signal-to-Noise Ratio (PSNR) is expressed as

\[{\rm PSNR} = 10 \log10(\frac{V_{peak}^2}{\rm MSE}) \]

For float data, \(V_{peak} = 1\);

For interges, \(V_{peak} = 2^{nbits}\), e.g. uint8: 255, uint16: 65535 …

Parameters:
  • o (array_like) – Reference data array. For image, it’s the original image.
  • r (array_like) – The data to be compared. For image, it’s the reconstructed image.
  • Vpeak (float, int or None, optional) – The peak value. If None, computes automaticly.
  • mode (str or None, optional) – ‘simple’ or ‘rich’. ‘simple’ (default) –> just return psnr i.e. ‘rich’ –> return psnr, mse, Vpeak, imgtype.
Returns:

PSNR – Peak Signal to Noise Ratio value.

Return type:

float

improc.evaluation.quality.showorirec(imgs_ori, imgs_rec, mode='rich')[source]

improc.evaluation.ssims module

improc.evaluation.ssims.create_window(winsize, channel)[source]
improc.evaluation.ssims.gaussian(winsize, sigma)[source]
improc.evaluation.ssims.gssim(X, Y, win=None, winsize=11, L=None, k1=0.01, k2=0.03, alpha=1, beta=1, gamma=1, isavg=True, full=False)[source]
improc.evaluation.ssims.ssim(X, Y, win=None, winsize=11, L=None, k1=0.01, k2=0.03, alpha=1, beta=1, gamma=1, isavg=True, full=False)[source]

Structural similarity index

\[\begin{aligned} l(x, y) &=\frac{2 \mu_{x} \mu_{y}+c_{1}}{\mu_{x}^{2}+\mu_{y}^{2}+c_{1}} \\ c(x, y) &=\frac{2 \sigma_{x} \sigma_{y}+c_{2}}{\sigma_{x}^{2}+\sigma_{y}^{2}+c_{2}} \\ s(x, y) &=\frac{\sigma_{x y}+c_{3}}{\sigma_{x} \sigma_{y}+c_{3}} \end{aligned} \]

where, \(c_1 = (k_1 L)^2, c_2 = (k_2 L)^2, c_3 = c_2 / 2\), \(L\) is the dynamic range of the pixel-values (typically this is \(2 ^{\# \text { bits per pixel }}-1\). The structure similarity index is expressed as

\[\operatorname{SSIM}(x, y)=\left[l(x, y)^{\alpha} \cdot c(x, y)^{\beta} \cdot s(x, y)^{\gamma}\right]. \]

When \(\alpha=\beta=\gamma=1\), SSIM is equal to

\[\operatorname{SSIM}(x, y)=\frac{\left(2 \mu_{x} \mu_{y}+c_{1}\right)\left(2 \sigma_{x y}+ c_{2}\right)}{\left(\mu_{x}^{2}+\mu_{y}^{2}+c_{1}\right)\left(\sigma_{x}^{2}+\sigma_{y}^{2}+c_{2}\right)} \]

See “Image Quality Assessment: From Error Visibility to Structural Similarity” by Wang et al.

Parameters:
  • X ({ndarray}) – reconstructed
  • Y ({ndarray}) – referenced
  • win ({[type]}, optional) – [description] (the default is None, which [default_description])
  • winsize ({number}, optional) – [description] (the default is 11, which [default_description])
  • L ({integer}, optional) – the dynamic range of the pixel-values (typically this is \(2 ^{\# \text { bits per pixel }}-1\). (the default is 255)
  • k1 ({number}, optional) – [description] (the default is 0.01, which [default_description])
  • k2 ({number}, optional) – [description] (the default is 0.03, which [default_description]) sizeavg : {bool}, optional whether to average (the default is True, which average the result)
  • alpha ({number}, optional) – luminance weight (the default is 1)
  • beta ({number}, optional) – contrast weight (the default is 1)
  • gamma ({number}, optional) – structure weight (the default is 1)
  • isavg ({bool}, optional) – IF True, return the average SSIM index of the whole iamge,
  • full ({bool}, optional) – IF True, return SSIM, luminance, contrast and structure index (the default is False, which only return SSIM)

Module contents