Utility types and functions for image-registration workflows in the HolyLab ecosystem.
This package depends on RegisterCore.jl, which lives in the HolyLab registry. Add that registry once before installing:
using Pkg
pkg"registry add General https://github.com/HolyLab/HolyLabRegistry.git"
Pkg.add("RegisterUtilities")Counter yields every Vector{Int} index from [1,1,…,1] to max in
column-major (first-index-fastest) order. Unlike CartesianIndices, the
yielded values are plain vectors, which is convenient for arithmetic.
using RegisterUtilities
c = Counter((2, 3))
collect(c)
# [[1,1],[2,1],[1,2],[2,2],[1,3],[2,3]]
length(Counter((4, 5, 6))) # 120Returns the 1-based center of a block with the given dimensions, using the
same convention as MismatchArray blocks: center of dimension i is
(sz[i] >> 1) + 1.
block_center(5) # (3,)
block_center(4, 6) # (3, 4)
block_center(5, 5, 5) # (3, 3, 3)Fills a 2-D array where each element (i,j) equals uᵀ Q u, with
u = [i,j] - center and center = block_center(m,n) .+ shift. The second
method wraps the result in a MismatchArray with a given denominator.
using RegisterUtilities, LinearAlgebra
Q = [1.0 0.0; 0.0 1.0] # identity — distance² from center
A = quadratic(5, 5, [0, 0], Q)
# 5×5 matrix of squared distances from the block center (3, 3)
using RegisterCore
denom = ones(5, 5)
ma = quadratic(denom, [0, 0], Q) # returns a MismatchArrayConverts a heterogeneous or overly-wide array (e.g. Array{Real}) to the
narrowest concrete type that holds all its values.
A = Real[1, 2.0, 3f0]
B = tighten(A)
eltype(B) # Float64