Welcome to sewar’s documentation!

Full reference metrics

sewar.full_ref.ergas(GT, P, r=4, ws=8)[source]

calculates erreur relative globale adimensionnelle de synthese (ergas).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
  • r – ratio of high resolution to low resolution (default=4).
  • ws – sliding window size (default = 8).
Returns:

float – ergas value.

sewar.full_ref.mse(GT, P)[source]

calculates mean squared error (mse).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
Returns:

float – mse value.

sewar.full_ref.msssim(GT, P, weights=[0.0448, 0.2856, 0.3001, 0.2363, 0.1333], ws=11, K1=0.01, K2=0.03, MAX=None)[source]

calculates multi-scale structural similarity index (ms-ssim).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
  • weights – weights for each scale (default = [0.0448, 0.2856, 0.3001, 0.2363, 0.1333]).
  • ws – sliding window size (default = 11).
  • K1 – First constant for SSIM (default = 0.01).
  • K2 – Second constant for SSIM (default = 0.03).
  • MAX – Maximum value of datarange (if None, MAX is calculated using image dtype).
Returns:

float – ms-ssim value.

sewar.full_ref.psnr(GT, P, MAX=None)[source]

calculates peak signal-to-noise ratio (psnr).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
  • MAX – maximum value of datarange (if None, MAX is calculated using image dtype).
Returns:

float – psnr value in dB.

sewar.full_ref.psnrb(GT, P)[source]

Calculates PSNR with Blocking Effect Factor for a given pair of images (PSNR-B)

Parameters:
  • GT – first (original) input image in YCbCr format or Grayscale.
  • P – second (corrected) input image in YCbCr format or Grayscale..
Returns:

float – psnr_b.

sewar.full_ref.rase(GT, P, ws=8)[source]

calculates relative average spectral error (rase).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
  • ws – sliding window size (default = 8).
Returns:

float – rase value.

sewar.full_ref.rmse(GT, P)[source]

calculates root mean squared error (rmse).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
Returns:

float – rmse value.

sewar.full_ref.rmse_sw(GT, P, ws=8)[source]

calculates root mean squared error (rmse) using sliding window.

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
  • ws – sliding window size (default = 8).
Returns:

tuple – rmse value,rmse map.

sewar.full_ref.sam(GT, P)[source]

calculates spectral angle mapper (sam).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
Returns:

float – sam value.

sewar.full_ref.scc(GT, P, win=[[-1, -1, -1], [-1, 8, -1], [-1, -1, -1]], ws=8)[source]

calculates spatial correlation coefficient (scc).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
  • fltr – high pass filter for spatial processing (default=[[-1,-1,-1],[-1,8,-1],[-1,-1,-1]]).
  • ws – sliding window size (default = 8).
Returns:

float – scc value.

sewar.full_ref.ssim(GT, P, ws=11, K1=0.01, K2=0.03, MAX=None, fltr_specs=None, mode='valid')[source]

calculates structural similarity index (ssim).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
  • ws – sliding window size (default = 8).
  • K1 – First constant for SSIM (default = 0.01).
  • K2 – Second constant for SSIM (default = 0.03).
  • MAX – Maximum value of datarange (if None, MAX is calculated using image dtype).
Returns:

tuple – ssim value, cs value.

sewar.full_ref.uqi(GT, P, ws=8)[source]

calculates universal image quality index (uqi).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
  • ws – sliding window size (default = 8).
Returns:

float – uqi value.

sewar.full_ref.vifp(GT, P, sigma_nsq=2)[source]

calculates Pixel Based Visual Information Fidelity (vif-p).

Parameters:
  • GT – first (original) input image.
  • P – second (deformed) input image.
  • sigma_nsq – variance of the visual noise (default = 2)
Returns:

float – vif-p value.

No reference metrics

sewar.no_ref.d_lambda(ms, fused, p=1)[source]

calculates Spectral Distortion Index (D_lambda).

Parameters:
  • ms – low resolution multispectral image.
  • fused – high resolution fused image.
  • p – parameter to emphasize large spectral differences (default = 1).
Returns:

float – D_lambda.

sewar.no_ref.d_s(pan, ms, fused, q=1, r=4, ws=7)[source]

calculates Spatial Distortion Index (D_S).

Parameters:
  • pan – high resolution panchromatic image.
  • ms – low resolution multispectral image.
  • fused – high resolution fused image.
  • q – parameter to emphasize large spatial differences (default = 1).
  • r – ratio of high resolution to low resolution (default=4).
  • ws – sliding window size (default = 7).
Returns:

float – D_S.

sewar.no_ref.qnr(pan, ms, fused, alpha=1, beta=1, p=1, q=1, r=4, ws=7)[source]

calculates Quality with No Reference (QNR).

Parameters:
  • pan – high resolution panchromatic image.
  • ms – low resolution multispectral image.
  • fused – high resolution fused image.
  • alpha – emphasizes relevance of spectral distortions to the overall.
  • beta – emphasizes relevance of spatial distortions to the overall.
  • p – parameter to emphasize large spectral differences (default = 1).
  • q – parameter to emphasize large spatial differences (default = 1).
  • r – ratio of high resolution to low resolution (default=4).
  • ws – sliding window size (default = 7).
Returns:

float – QNR.

Indices and tables