Code documentation

Core

image_ema_project.core.cost_function(p, x, y, f, g, W)

The cost function to minimize in the optimization process. The element-wise difference between the reference image f(x, y) and a tansformed current image g(W(x, y)).

Parameters:
  • p (array of shape (n,)) – The geometric transform parameters to optimize.
  • x (array of shape (w,)) – The x-coordinates of reference image pixel grid.
  • y (array of shape (h,)) – The y-coordinates of reference image pixel grid.
  • f (array of shape (H, W)) – The reference image.
  • g (array of shape (H, W)) – The current image.
  • W (callable) – The geometric transform function with the signature W(x, y, p, g), that evaluates and returns the current image values at transformed coordinates for the parameters p.
Returns:

Vector of residuals.

Return type:

residual (array of shape (w*h,))

image_ema_project.core.get_displacements(images, point, roi_size)

Calculate displacements of a selected point in the image. Uses the Lucas-Kanade image alignment algorithm for simple translations.

Parameters:
  • images (array of shape (N, h, w)) – Image data array.
  • point (array of shape (2,)) – The position of the point to analyze, [X, Y].
  • roi_size (array of shape (2,)) – The region-of-interest dimensions, [W, H]. The ROI dimensions must be odd numbers!
Returns:

The image-identified translations [dx, dy]

(in pixels).

Return type:

d (array of shape (2, N))

image_ema_project.core.roi_xy(point, roi_size)

Get grid coordinates of the selected region of interest.

Parameters:
  • point (array of shape (2,)) – The position of the point to analyze, [X, Y].
  • roi_size (array of shape (2,)) – The region-of-interest dimensions, [W, H]. The ROI dimensions must be odd numbers!
Returns:

The x coordinates of the ROI point grid. y (array of shape (H,)): The y coordinates of the ROI point grid.

Return type:

x (array of shape (W,))

image_ema_project.core.translation(x, y, p, g)

Geometric transform function of simple translation. Interpolates the image g(x, y) using cubic B-splineinterpolation and evaluates its pixel values at g(y+p[1], x+p[0]).

Parameters:
  • x (array of shape (w,)) – The x-coordinates of reference image pixel grid.
  • y (array of shape (h,)) – The y-coordinates of reference image pixel grid.
  • p (array of shape (2,)) – The translation parameters [dx, dy].
  • g (array of shape (H, W)) – The image to be evaluated.
Returns:

The transformed image.

Return type:

residual (array of shape (h, w))