xdesign.metrics

Coverage metrics

Objects and methods for computing coverage based quality metrics.

These methods are based on the scanning trajectory only.

Module author: Daniel J Ching <carterbox@users.noreply.github.com>

Functions:

coverage_approx(gmin, gsize, ngrid, ...[, ...])

Approximate procedure coverage with a Riemann sum.

xdesign.metrics.coverage.coverage_approx(gmin, gsize, ngrid, probe_size, theta, h, v, weights=None, anisotropy=1, num_rays=16)[source]

Approximate procedure coverage with a Riemann sum.

The intersection between the beam and each pixel is approximated by using a Reimann sum of n rectangles: width beam.size / n and length dist where dist is the length of segment of the line alpha which passes through the pixel parallel to the beam.

If anisotropy is True, then coverage_map.shape is (M, N, 2, 2), where the two extra dimensions contain coverage anisotopy information as a second order tensor.

Parameters
  • procedure (Probe generator) – A generator which defines a scanning procedure by returning a sequence of Probe objects.

  • region (np.array [cm]) – A rectangle in which to map the coverage. Specify the bounds as [[min_x, max_x], [min_y, max_y]]. i.e. column vectors pointing to the min and max corner.

  • pixel_size (float [cm]) – The edge length of the pixels in the coverage map in centimeters.

  • n (int) – The number of lines per beam

  • anisotropy (bool) – Whether the coverage map includes anisotropy information

Returns

coverage_map (numpy.ndarray) – A discretized map of the Probe coverage.

See also

plot.plot_coverage_anisotropy()

Full-reference metrics

Defines full-referene image quality metricsself.

These methods require a ground truth in order to make a quality assessment.

Module author: Daniel J Ching <carterbox@users.noreply.github.com>

Functions:

pcc(A, B[, masks])

Return the Pearson product-moment correlation coefficients (PCC).

ssim(img1, img2[, sigma, L, K, scale, ...])

Return the Structural SIMilarity index (SSIM) of two images.

msssim(img0, img1[, nlevels, sigma, L, K, ...])

Multi-Scale Structural SIMilarity index (MS-SSIM).

class xdesign.metrics.fullref.ImageQuality(original, reconstruction)[source]

Bases: object

Store information about image quality.

img0
Type

array

img1

Stacks of reference and deformed images.

Type

array

metrics

A dictionary with image quality information organized by scale. metric[scale] = (mean_quality, quality_map)

Type

dict

method

The metric used to calculate the quality

Type

string

quality(method='MSSSIM', L=1.0, **kwargs)[source]

Compute the full-reference image quality of each image pair.

Available methods include SSIM [4], MSSSIM [5], VIFp [3]

Parameters
  • method (string, optional, (default: MSSSIM)) – The quality metric desired for this comparison. Options include: SSIM, MSSSIM, VIFp

  • L (scalar) – The dynamic range of the data. This value is 1 for float representations and 2^bitdepth for integer representations.

xdesign.metrics.fullref.msssim(img0, img1, nlevels=5, sigma=1.2, L=1.0, K=(0.01, 0.03), alpha=4, beta_gamma=None)[source]

Multi-Scale Structural SIMilarity index (MS-SSIM).

Parameters
  • img0 (array)

  • img1 (array) – Two images for comparison.

  • nlevels (int) – The max number of levels to analyze

  • sigma (float) – Sets the standard deviation of the gaussian filter. This setting determines the minimum scale at which quality is assessed.

  • L (scalar) – The dynamic range of the data. This value is 1 for float representations and 2^bitdepth for integer representations.

  • K (2-tuple) – A list of two constants which help prevent division by zero.

  • alpha (float) – The exponent which weights the contribution of the luminance term.

  • beta_gamma (list) – The exponent which weights the contribution of the contrast and structure terms at each level.

Returns

metrics (dict) – A dictionary with image quality information organized by scale. metric[scale] = (mean_quality, quality_map) The valid range for SSIM is [-1, 1].

References

Multi-scale Structural Similarity Index (MS-SSIM) Z. Wang, E. P. Simoncelli and A. C. Bovik, “Multi-scale structural similarity for image quality assessment,” Invited Paper, IEEE Asilomar Conference on Signals, Systems and Computers, Nov. 2003

xdesign.metrics.fullref.pcc(A, B, masks=None)[source]

Return the Pearson product-moment correlation coefficients (PCC).

Parameters
  • A, B (ndarray) – The two images to be compared

  • masks (list of ndarrays, optional) – If supplied, the data under each mask is computed separately.

Returns

covariances (array, list of arrays)

xdesign.metrics.fullref.ssim(img1, img2, sigma=1.2, L=1, K=(0.01, 0.03), scale=None, alpha=4, beta_gamma=4)[source]

Return the Structural SIMilarity index (SSIM) of two images.

A modified version of the Structural SIMilarity index (SSIM) based on an implementation by Helder C. R. de Oliveira, based on the implementation by Antoine Vacavant, ISIT lab, antoine.vacavant@iut.u-clermont1.fr http://isit.u-clermont1.fr/~anvacava

xdesign.metrics.fullref.img1
Type

array

xdesign.metrics.fullref.img2

Two images for comparison.

Type

array

xdesign.metrics.fullref.sigma

Sets the standard deviation of the gaussian filter. This setting determines the minimum scale at which quality is assessed.

Type

float

xdesign.metrics.fullref.L

The dynamic range of the data. The difference between the minimum and maximum of the data: 2^bitdepth for integer representations.

Type

scalar

xdesign.metrics.fullref.K

A list of two constants which help prevent division by zero.

Type

2-tuple

xdesign.metrics.fullref.alpha

The exponent which weights the contribution of the luminance term.

Type

float

xdesign.metrics.fullref.beta_gamma

The exponent which weights the contribution of the contrast and structure terms at each level.

Type

list

Returns

metrics (dict) – A dictionary with image quality information organized by scale. metric[scale] = (mean_quality, quality_map) The valid range for SSIM is [-1, 1].

References

Z. Wang, A. C. Bovik, H. R. Sheikh and E. P. Simoncelli. Image quality assessment: From error visibility to structural similarity. IEEE Transactions on Image Processing, 13(4):600–612, 2004.

Z. Wang and A. C. Bovik. Mean squared error: Love it or leave it? - A new look at signal fidelity measures. IEEE Signal Processing Magazine, 26(1):98–117, 2009.

Silvestre-Blanes, J., & Pérez-Lloréns, R. (2011, September). SSIM and their dynamic range for image quality assessment. In ELMAR, 2011 Proceedings (pp. 93-96). IEEE.

Standards-based metrics