dicbruteforce.hpp¶
-
namespace brute¶
Functions
-
void init(std::string &cost_function, std::string &search_method)¶
Initializes the cost function and search method.
Sets cost function and search method based on the provided string values. If an unrecognized value is provided, default ‘SSD’ and ‘SPIRAL’ values are used.
- Parameters:
cost_function – (std::string) reference representing the cost function (“SSD”, “NSSD”, “ZNSSD”).
search_method – (std::string) reference representing the search method (“EXHAUSTIVE”, “SPIRAL”).
-
void expanding_wavefront(const int ss_x, const int ss_y, const double *img_ref, const int px_hori, const int px_vert, util::Subset &ss_def, util::Subset &ss_ref, brute::Parameters &brute)¶
Performs a spiral search for the optimal translation.
Searches for the best rigid subset translation by following a spiral path from a starting point. The search stops when the cost function value is below a specified tolerance.
- Parameters:
ss_x – Horizontal coordinate of the starting point.
ss_y – Vertical coordinate of the starting point.
img_ref – Pointer to the reference image.
px_vert – Vertical size of the image.
px_hori – Horizontal size of the image.
ss_def – Pointer to the subset definition.
ss_ref – Pointer to the reference subset.
brute – Pointer to the brute force parameters.
- Returns:
result is populated in brute.p_rigid.
-
void exhaustive(const int ss_x, const int ss_y, const double *img_ref, const int px_hori, const int px_vert, util::Subset &ss_def, util::Subset &ss_ref, brute::Parameters &brute)¶
Performs an exhaustive search for the optimal translation.
Searches all possible rigid subset translations within a specified range to cost function minimum.
- Parameters:
ss_x – Horizontal coordinate of the starting point.
ss_y – Vertical coordinate of the starting point.
img_ref – Pointer to the reference image.
px_vert – Vertical size of the image.
px_hori – Horizontal size of the image.
ss_def – Pointer to the subset definition.
ss_ref – Pointer to the reference subset.
brute – Pointer to the brute force parameters.
- Returns:
result is populated in brute.p_rigid.
-
double ssd(const double *img_ref, const int px_hori, const int px_vert, util::Subset &ss_def, util::Subset &ss_ref, const int p0, const int p1)¶
Computes the Sum of Squared Differences (SSD) during a brute force search.
This function calculates the SSD between the subset in the reference image and the target subset.
- Parameters:
ss_x – Horizontal coordinate of the starting point.
ss_y – Vertical coordinate of the starting point.
img_ref – Pointer to the reference image.
px_vert – Vertical size of the image.
px_hori – Horizontal size of the image.
ss_def – Pointer to the subset definition.
ss_ref – Pointer to the reference subset.
p0 – int value for the x-coordinate of the translation.
p1 – int value for the y-coordinate of the translation.
- Returns:
The computed SSD value.
-
double nssd(const double *img_ref, const int px_hori, const int px_vert, util::Subset &ss_def, util::Subset &ss_ref, const int p0, const int p1)¶
Computes the Normalized Sum of Squared Differences (NSSD) during a brute force search.
This function calculates the NSSD between the subset in the reference image and the target subset. The cost is normalized by the sum of squared pixel values in the reference and target subsets.
- Parameters:
ss_x – Horizontal coordinate of the starting point.
ss_y – Vertical coordinate of the starting point.
img_ref – Pointer to the reference image.
px_vert – Vertical size of the image.
px_hori – Horizontal size of the image.
ss_def – Pointer to the subset definition.
ss_ref – Pointer to the reference subset.
p0 – int value for the x-coordinate of the translation.
p1 – int value for the y-coordinate of the translation.
- Returns:
The computed NSSD value.
-
double znssd(const double *img_ref, const int px_hori, const int px_vert, util::Subset &ss_def, util::Subset &ss_ref, const int p0, const int p1)¶
Computes the Zero-Mean Normalized Sum of Squared Differences (ZNSSD) during a brute force search.
This function calculates the ZNSSD between the subset in the reference image and the target subset. The pixel values are normalized by their mean and the cost is computed based on the squared differences.
- Parameters:
ss_x – Horizontal coordinate of the starting point.
ss_y – Vertical coordinate of the starting point.
img_ref – Pointer to the reference image.
px_vert – Vertical size of the image.
px_hori – Horizontal size of the image.
ss_def – Pointer to the subset definition.
ss_ref – Pointer to the reference subset.
p0 – int value for the x-coordinate of the translation.
p1 – int value for the y-coordinate of the translation.
- Returns:
The computed ZNSSD value.
-
inline bool is_perimeter_point(int dx, int dy, int r)¶
Checks if a point (dx, dy) lies on the perimeter of a square of radius r.
A point is considered on the perimeter if its horizontal or vertical distance from the center equals the radius.
- Parameters:
dx – Horizontal offset from subset centre location.
dy – Vertical offset from subset centre location.
r – Radius of the square perimeter.
- Returns:
(bool) True if the point lies on the perimeter, false otherwise.
-
inline bool is_within_image(int xmin, int ymin, int xmax, int ymax, int width, int height)¶
Checks if a rectangular region is fully contained within image bounds.
Evaluates whether the rectangle defined by its corner coordinates lies entirely within the image dimensions.
- Parameters:
xmin – (
int
) Minimum x-coordinate of the rectangle.ymin – (
int
) Minimum y-coordinate of the rectangle.xmax – (
int
) Maximum x-coordinate of the rectangle.ymax – (
int
) Maximum y-coordinate of the rectangle.width – (int) Width of the image.
height – (int) Height of the image.
- Returns:
(bool) True if the rectangle is fully inside the image, false otherwise.
-
inline bool is_within_range(int p0, int p1, int range)¶
Checks if two values lie within the specified symmetric integer range.
The range is interpreted as [-range, range). This function checks whether both values are within that range.
- Parameters:
p0 – (int) first rigid shape function parameter (x).
p1 – (int) Second rigid shape function parameter (y).
range – (int) Half-width of the symmetric range (exclusive).
- Returns:
(bool) True if both values are within the range, false otherwise.
-
struct Parameters¶
- #include <dicbruteforce.hpp>
Parameters for the brute force search method.
Public Functions
-
inline Parameters(double bf_threshold_, int max_disp_)¶
-
inline Parameters(double bf_threshold_, int max_disp_)¶
-
void init(std::string &cost_function, std::string &search_method)¶