dicutil.hpp

namespace util

Functions

void extract_image(double *img_def_stack, int image_number, int px_hori, int px_vert)

Extracts a single image from a stacked image array and stores it in an Image object.

Takes a specific 2D image (identified by image_number) from a 3D image stack (img_def_stack) and stores its pixel values into the vals field of the provided util::Image structure.

Parameters:
  • img_def – Pointer to a util::Image object that will be populated with the extracted image data.

  • img_def_stack – Pointer to a flat array representing a stack of images stored sequentially (row-major order).

  • image_number – Index of the image to extract from the stack (0-based).

void extract_ss(util::Subset &ss_ref, const int ss_x, const int ss_y, const int px_hori, const int px_vert, const double *img_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_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 (util::Subset) where extracted pixel values and coordinates are stored.

void extract_ss_subpx(util::Subset &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 (util::Subset) 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.

int get_num_params(std::string &shape_func)
SubsetData gen_ss_list(const bool *img_roi, const int ss_step, const int ss_size, const int px_hori, const int px_vert, const bool partial = false)

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 SubsetData object containing the generated subsets and their neighbours.

void append_results(int img_num, int ss, util::Results &res, int num_ss)
void resize_results(int num_def_img, int num_ss, int num_params, bool at_end)
void save_to_disk(int img, const util::SaveConfig &saveconf, const util::SubsetData &ssdata, const int num_def_img, const int num_params, const std::vector<std::string> &filenames)
inline bool is_valid_in_dims(const int px_x, const int px_y, const int px_hori, const int px_vert)
inline bool is_valid_in_roi(const int px_x, const int px_y, const int px_hori, const int px_vert, const bool *img_roi)
inline void write_int(std::ofstream &out, int val)
inline void write_uint8t(std::ofstream &out, int val)
inline void write_dbl(std::ofstream &out, double val)
int next_pow2(int n)
void gen_size_and_step_vector(std::vector<int> &ss_sizes, std::vector<int> &ss_steps, const int ss_size, const int ss_step, const int max_disp)
void create_progress_bar(indicators::ProgressBar &bar, const std::string &bar_title, const int num_ss)
void update_progress_bar(indicators::ProgressBar &bar, int i, int num_ss, int &prev_pct)

Variables

std::vector<int> niter_arr
std::vector<double> u_arr
std::vector<double> v_arr
std::vector<double> p_arr
std::vector<double> ftol_arr
std::vector<double> xtol_arr
std::vector<double> cost_arr
struct Config

Public Members

int ss_step
int ss_size
int max_iter
int px_hori
int px_vert
int num_def_img
int num_params
double precision
double opt_threshold
double bf_threshold
int max_disp
std::pair<int, int> rg_seed
std::string corr_crit
std::string shape_func
std::string interp_routine
std::string scan_method
std::vector<std::string> filenames
bool fft_mad
double fft_mad_scale
unsigned int debug_level
struct Image
#include <dicutil.hpp>

Represents an image with pixel data and dimensions.

This struct holds the pixel values of an image along with its dimensions. The pixel data is stored in row-major order.

Public Members

double *vals
int px_hori
int px_vert
int num
struct PairHash

Public Functions

inline std::size_t operator()(const std::pair<int, int> &p) const
struct Results

Public Functions

inline Results(size_t num_params)

Public Members

std::vector<double> p
double u = 0.0
double v = 0.0
double mag = 0.0
double ftol = 0.0
double xtol = 0.0
int iter = 0
double cost = 0.0
uint8_t converged = false
struct SaveConfig

Public Members

std::string basepath
std::string prefix
std::string delimiter
bool binary
bool at_end
bool output_unconverged
bool shape_params
struct Subset
#include <dicutil.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 Subset(int ss_size)

Public Members

std::vector<double> vals
std::vector<double> x
std::vector<double> y
int size
int num_px
struct SubsetData

Public Members

int num
int step
int size
int num_ss_x
int num_ss_y
int num_in_mask
std::vector<int> coords
std::vector<int> mask
std::vector<std::vector<int>> neigh
class Timer

Public Functions

inline Timer(const std::string &label)
inline ~Timer()

Private Members

std::string label_
std::chrono::high_resolution_clock::time_point start_