clearex.registration.tre
Functions
|
Compute BRIEF descriptors at a set of row/column keypoints. |
|
Estimate a proxy target-registration error by repeated holdout. |
|
Fit a robust geometric transform using RANSAC. |
|
Match points by mutual nearest-neighbor assignment. |
|
Register two particle images and summarize landmark error metrics. |
|
Compute residual summary statistics for a fitted transform. |
|
Convert row/column coordinates to x/y coordinates. |
- clearex.registration.tre.brief_descriptors_at_keypoints(img, keypoints_rc, patch_size=31, n_bits=256)
Compute BRIEF descriptors at a set of row/column keypoints.
- Parameters:
img (numpy.ndarray) – Input 2D image.
keypoints_rc (numpy.ndarray) – Candidate keypoints in
(row, col)format.patch_size (int, default=31) – BRIEF patch size in pixels.
n_bits (int, default=256) – Descriptor length in bits.
- Returns:
Rounded keypoints that produced valid descriptors and their BRIEF descriptor matrix.
- Return type:
tuple of numpy.ndarray
- clearex.registration.tre.xy_from_rc(rc)
Convert row/column coordinates to x/y coordinates.
- Parameters:
rc (numpy.ndarray) – Array of coordinates in
(row, col)order.- Returns:
Coordinates in
(x, y)order.- Return type:
numpy.ndarray
- clearex.registration.tre.fit_transform_ransac(src_xy, dst_xy, model='similarity', residual_threshold=2.0, max_trials=1000)
Fit a robust geometric transform using RANSAC.
- Parameters:
src_xy (numpy.ndarray) – Source points in
(x, y)order.dst_xy (numpy.ndarray) – Destination points in
(x, y)order.model ({"similarity", "affine"}, default="similarity") – Transform family used by RANSAC.
residual_threshold (float, default=2.0) – Maximum inlier residual in pixels.
max_trials (int, default=1000) – Maximum number of RANSAC iterations.
- Returns:
Robust transform model and the Boolean inlier mask returned by
skimage.measure.ransac().- Return type:
tuple
- clearex.registration.tre.registration_errors(model, src_xy, dst_xy)
Compute residual summary statistics for a fitted transform.
- Parameters:
model (skimage.transform.SimilarityTransform or skimage.transform.AffineTransform) – Transform used to map source points into destination space.
src_xy (numpy.ndarray) – Source points in
(x, y)order.dst_xy (numpy.ndarray) – Target points in
(x, y)order.
- Returns:
Residual vector, RMS residual, median residual, and 95th percentile residual, all in pixels.
- Return type:
tuple
- clearex.registration.tre.cv_tre_proxy(src_xy, dst_xy, n_splits=20, test_fraction=0.2, random_state=0, model='similarity')
Estimate a proxy target-registration error by repeated holdout.
- Parameters:
src_xy (numpy.ndarray) – Source points in
(x, y)order.dst_xy (numpy.ndarray) – Destination points in
(x, y)order.n_splits (int, default=20) – Number of random holdout repetitions.
test_fraction (float, default=0.2) – Fraction of matches assigned to each holdout split.
random_state (int, default=0) – Seed for the split generator.
model ({"similarity", "affine"}, default="similarity") – Transform family evaluated during cross-validation.
- Returns:
RMS holdout error and the full array of holdout residuals.
- Return type:
tuple
- clearex.registration.tre.particle_registration_tre(img1, img2, fwhm_px=10.0, invert=False, thresholds=(0.03, 0.03), brief_patch_size=31, model='similarity', ransac_residual_threshold=2.0, show_debug=False, optimize=False)
Register two particle images and summarize landmark error metrics.
- Parameters:
img1 (numpy.ndarray) – Fixed image in 2D.
img2 (numpy.ndarray) – Moving image in 2D.
fwhm_px (float, default=10.0) – Expected particle full width at half maximum in pixels.
invert (bool, default=False) – If
True, invert both preprocessed images before blob detection.thresholds (tuple of float, default=(0.03, 0.03)) – Detection thresholds for
img1andimg2.brief_patch_size (int, default=31) – Patch size used for BRIEF descriptors.
model ({"similarity", "affine"}, default="similarity") – Geometric model fitted during robust registration.
ransac_residual_threshold (float, default=2.0) – Inlier threshold in pixels for RANSAC.
show_debug (bool, default=False) – If
True, plot intermediate match diagnostics.optimize (bool, default=False) – If
True, stop after detection and visualization to help tune detector parameters.
- Returns:
Registration summary dictionary, or
Nonewhenoptimize=Trueand the helper exits after visualization.- Return type:
dict or None
- Raises:
ValueError – If either input image is not 2D.
- clearex.registration.tre.mutual_nn_pairs(fixed_rc, moving_rc, max_dist=None)
Match points by mutual nearest-neighbor assignment.
- Parameters:
fixed_rc (numpy.ndarray) – Fixed points in
(row, col)format.moving_rc (numpy.ndarray) – Moving points in
(row, col)format, typically already mapped into fixed-image space.max_dist (float, optional) – Maximum distance allowed for a retained match.
- Returns:
Pair indices
[moving_idx, fixed_idx]and their corresponding Euclidean distances.- Return type:
tuple of numpy.ndarray