hologradpy.error_metrics

This module contains functions to characterise light potentials.

Functions

normalize(img, roi[, thres])

Normalises an image by dividing it by the pixel sum in a region of interest. Only pixels brighter than

fidelity(signal, a_tar, phi_tar, a_out, phi_out)

Calculate fidelity between two electric fields in a region of interest (signal region).

rms(signal, i_target, i_out[, frac])

Calculate normalised root-mean-squared error between two images inside a region of interest. Only pixels which are brighter

rms_phase(phi)

Calculates the root-mean-squared error of an image.

psnr(signal, i_target, i_out)

Calculates the peak signal-to-noise ratio between two images in a region of interest according to

eff(signal, i_out)

Calculates the predicted efficiency of a light potential by dividing the pixel sum in the signal region by

Module Contents

hologradpy.error_metrics.normalize(img, roi, thres=0.5)

Normalises an image by dividing it by the pixel sum in a region of interest. Only pixels brighter than thres * max(roi * img) are taken into account.

Parameters:
  • img – Input image.

  • roi – Binary mask containing region of interest.

  • thres – Pixel value threshold (see above).

Returns:

Normalised image.

hologradpy.error_metrics.fidelity(signal, a_tar, phi_tar, a_out, phi_out)

Calculate fidelity between two electric fields in a region of interest (signal region).

Parameters:
  • signal – Binary mask containing the region of interest.

  • a_tar – Target amplitude pattern.

  • phi_tar – Target phase pattern.

  • a_out – Amplitude of light potential.

  • phi_out – Phase of light potential.

Returns:

Fidelity.

hologradpy.error_metrics.rms(signal, i_target, i_out, frac=0.5)

Calculate normalised root-mean-squared error between two images inside a region of interest. Only pixels which are brighter than frac * max(i_target_norm) are taken into account, where i_target_norm is the normalised target intensity pattern.

Parameters:
  • signal – Binary mask containing region of interest (signal region).

  • i_target – Target intensity pattern.

  • i_out – Intensity pattern of light potential.

  • frac – Threshold as explained above.

Returns:

Normalised rms error.

hologradpy.error_metrics.rms_phase(phi)

Calculates the root-mean-squared error of an image.

Parameters:

phi – Phase pattern.

Returns:

Root-mean-squared error.

hologradpy.error_metrics.psnr(signal, i_target, i_out)

Calculates the peak signal-to-noise ratio between two images in a region of interest according to https://doi.org/10.1364/OE.24.006249.

Parameters:
  • signal – Binary mask containing region of interest (signal region).

  • i_target – Target intensity pattern.

  • i_out – Intensity pattern of light potential.

Returns:

Peak signal-to-noise ratio [dB].

hologradpy.error_metrics.eff(signal, i_out)

Calculates the predicted efficiency of a light potential by dividing the pixel sum in the signal region by the pixel sum in the entire pattern.

Parameters:
  • signal – Binary mask containing the signal region.

  • i_out – Intensity pattern of the light potential.

Returns:

Efficiency.