API/Reference
SubpixelRegistration.calculate_stats
SubpixelRegistration.coregister
SubpixelRegistration.coregister!
SubpixelRegistration.fourier_shift
SubpixelRegistration.fourier_shift!
SubpixelRegistration.phase_offset
SubpixelRegistration.phase_offset
SubpixelRegistration.register
SubpixelRegistration.upsampled_dft
SubpixelRegistration.calculate_stats
— MethodSubpixelRegistration.calculate_stats(crosscor_maxima, source_freq, target_freq)
Calculate the normalized root-mean-square error (NRMSE) and total phase difference between the two complex arrays, source_freq
and target_freq
, with maximum cross-correlation value crosscor_maxima
SubpixelRegistration.coregister!
— Methodcoregister!(cube; dims, kwargs...)
Coregister slices in cube
, modifying it in place.
See also
SubpixelRegistration.coregister
— Methodcoregister(cube; dims, refidx=firstindex(cube, dims), upsample_factor=1)
Coregister a cube of data along dims
, using the refidx
slice as the source frame. Other keyword arguments will be passed to phase_offset
See also
SubpixelRegistration.fourier_shift!
— Methodfourier_shift!(image_freq::AbstractMatrix{<:Complex}, shift, phasediff=0)
Shift the given image, which is already in frequency-space, by shift
along each axis. Modifies image_freq
in place.
SubpixelRegistration.fourier_shift
— Methodfourier_shift(image, shift)
Shift the given image
by shift
along each axis, using the Fourier phase information.
SubpixelRegistration.phase_offset
— Methodphase_offset(source, target; upsample_factor=1, normalize=false)
Return the shift between source
and target
along each axis by measuring the maximum in the cross-correlation between the images. This algorithm can achieve 1/upsample_factor
precision by locally upsampling the cross-correlation via a matrix-multiplication DFT.[1] If normalize
is true
, the phase of the cross-correlation in Fourier space is divided by its magnitude. In some applications, phase normalization can increase performance, but usually at a trade-off for worse low-noise performance.
Examples
julia> image = reshape(1.0:100.0, 10, 10);
julia> shift = (-1.6, 2.8)
(-1.6, 2.8)
julia> target = fourier_shift(image, shift);
julia> phase_offset(image, target)
(shift = (2.0, -3.0), error = 0.013095117382042387, phasediff = 0.0)
julia> phase_offset(image, target; upsample_factor=5)
(shift = (1.6, -2.8), error = -9972.926257260056, phasediff = 0.0)
julia> phase_offset(image, target; upsample_factor=5, normalize=true)
(shift = (1.8, -2.8), error = 0.9999999971143979, phasediff = 0.0)
julia> @. isapprox(ans.shift, -1 * shift, atol=1/5)
(true, true)
SubpixelRegistration.phase_offset
— Methodphase_offset(plan, source_freq, target_freq; upsample_factor=1, normalize=false)
Returns the phase shift between the two images which have already been Fourier transformed with the given plan
.
SubpixelRegistration.register
— Methodregister(source, target; upsample_factor=1)
Register target
image to source
image by first finding the phase offset (phase_offset
), and then Fourier shifting target
with fourier_shift
.
Examples
julia> image = reshape(1.0:100.0, 10, 10);
julia> shift = (-1.6, 2.8)
(-1.6, 2.8)
julia> target = fourier_shift(image, shift);
julia> target_shift = register(image, target; upsample_factor=5);
See also
SubpixelRegistration.upsampled_dft
— MethodSubpixelRegistration.upsampled_dft(data, region_size, upsample_factor, offsets)
Calculate the cross-correlation in a region of size region_size
via an upsampled DFT. The DFT uses matrix-multiplication to super-sample the input by upsample_factor
. The frequencies will be shifted and centered around offsets
.
- 1Manuel Guizar-Sicairos, Samuel T. Thurman, and James R. Fienup, "Efficient subpixel image registration algorithms," Opt. Lett. 33, 156-158 (2008)