dicsubset.hpp

namespace subset

Functions

void fill_from_img(subset::Pixels &ss_ref, const int ss_x, const int ss_y, const int px_hori, const int px_vert, const Image &img)

Extracts a square subset of pixels from an image and stores the data in a Subset object.

This function copies a square region of pixel data from the specified starting coordinates (ss_x, ss_y) in the input image into the ss_def structure. The size of the square subset is determined by ss_def->size. Both the pixel values and their corresponding coordinates are stored in ss_def.

Parameters:
  • ss_x – X-coordinate (column) of the TOP-LEFT CORNER of the subset in the image.

  • ss_y – Y-coordinate (row) of the TOP-LEFT CORNER of the subset in the image.

  • img_def – Pointer to the source image (util::Image) from which to extract pixel data.

  • ss_def – Pointer to the destination subset (subset::Pixels) where extracted pixel values and coordinates are stored.

template<typename T>
void fill_impl(subset::Pixels &ss_ref, const std::vector<T> &data, int ss_x, int ss_y, int px_hori)
void fill_from_centre_coords(subset::Pixels &ss_def, const double cx, const double cy, const Interpolator &interp_def)

Fills a subset of pixels from an image using centre coordinates.

Samples pixel values from the interpolator over a grid centred at (cx, cy). Equivalent to fill_from_img_subpx but takes centre coordinates rather than the top-left corner, and stores both pixel coordinates and values in ss_def.

Parameters:
  • ss_def – Destination subset where pixel coordinates and values are stored.

  • cx – X-coordinate of the CENTRE of the subset in the image.

  • cy – Y-coordinate of the CENTRE of the subset in the image.

  • interp_defInterpolator for the image from which to sample pixel data.

void fill_from_img_subpx(subset::Pixels &ss_def, const double subpx_x, const double subpx_y, const Interpolator &interp_def)

Extracts a square subset of pixels from an image and stores the data in a Subset object.

This function copies a square region of pixel data from the specified starting coordinates (ss_x, ss_y) in the input image into the ss_def structure. The size of the square subset is determined by ss_def->size. Both the pixel values and their corresponding coordinates are stored in ss_def.

Parameters:
  • ss_ref – Pointer to the destination subset (subset::Pixels) where extracted pixel info will be stored

  • ss_x – X-coordinate (column) of the TOP-LEFT CORNER of the subset in the image.

  • ss_y – Y-coordinate (row) of the TOP-LEFT CORNER of the subset in the image.

  • interp_ref – interpolator for the reference image from which to extract pixel data.

void fill_from_shape_params(subset::Pixels &ss_def, const double cx, const double cy, const std::vector<double> &p, const Interpolator &interp_def, util::ShapeFunc shape_func)

Populates a deformed subset with interpolated image values using shape function parameters.

Applies the shape function to map reference subset coordinates (centred at cx, cy) to deformed image coordinates, then interpolates the image intensity at each mapped location.

Parameters:
  • ss_def – Output subset to populate with deformed coordinates and interpolated values.

  • cx – Global x-coordinate of the SUBSET CENTRE in the reference image.

  • cy – Global y-coordinate of the SUBSET CENTRE in the reference image.

  • p – Shape function parameters (e.g. displacement, strain components).

  • interp_defInterpolator for the deformed image.

  • shape_func – Shape function type enum.

subset::Grid create_grid(const bool *img_roi, const int ss_step, const int ss_size_x, const int ss_size_y, const int px_hori, const int px_vert, const bool partial)

Generates a list of subsets based on the provided image ROI and parameters.

This function creates a list of subsets (defined by their coordinates) from a binary mask (img_roi) that indicates the region of interest in the image. The subsets are generated with specified size and step values.

Parameters:
  • img_roi – Pointer to a binary mask indicating the region of interest in the image.

  • px_hori – Number of horizontal pixels in the image.

  • px_vert – Number of vertical pixels in the image.

  • ss_size – Size of each subset (in pixels).

  • ss_step – Step size for generating subsets.

Returns:

A subset::Grid object containing the generated subsets and their neighbours.

static inline bool px_in_img_dims(const int px_x, const int px_y, const int px_hori, const int px_vert)
static inline bool px_in_roi(const int px_x, const int px_y, const int px_hori, const int px_vert, const bool *img_roi)
static inline void get_centre(double &cx, double &cy, const double ss_x, const double ss_y, const int size_x, const int size_y)

Returns central subset coordinates for given subset corner values and dimensions.

Parameters:
  • cx[out] – x pixel coordinate of subset centre

  • cy[out] – y pixel coordinate of subset centre

  • ss_x[in] – x pixel coordinate of subset corner

  • ss_y[in] – y pixel coordinate of subset corner

  • size_x[in] – subset size in x

  • size_y[in] – subset size in y

static inline void get_corner(double &corner_x, double &corner_y, const double cx, const double cy, const int size_x, const int size_y)

Returns corner subset coordinates for given subset centre values and dimensions.

Parameters:
  • cx[out] – x pixel coordinate of subset centre

  • cy[out] – y pixel coordinate of subset centre

  • ss_x[in] – x pixel coordinate of subset corner

  • ss_y[in] – y pixel coordinate of subset corner

  • size_x[in] – subset size in x

  • size_y[in] – subset size in y

double zncc(const subset::Pixels &ss_ref, const subset::Pixels &ss_def)
struct Grid

Public Members

int num
int step
int size_x
int size_y
int num_ss_x
int num_ss_y
int num_in_mask
std::vector<double> coords
std::vector<int> mask
std::vector<std::vector<int>> neigh
std::vector<bool> active_ss
int active_total
struct Pixels
#include <dicsubset.hpp>

holds a subset with pixel data and dimensions.

This struct holds the pixel values, coordinates, and dimensions of a square subset.

Public Functions

inline Pixels(int ss_size_x, int ss_size_y, bool store_coords = true)
inline bool has_coords() const

Public Members

std::vector<double> vals
std::vector<double> x
std::vector<double> y
int size_x
int size_y
int num_px
int sum