API/Reference

SubpixelRegistration.calculate_statsMethod
SubpixelRegistration.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

source
SubpixelRegistration.fourier_shift!Method
fourier_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.

source
SubpixelRegistration.phase_offsetMethod
phase_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)
source
SubpixelRegistration.phase_offsetMethod
phase_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.

source
SubpixelRegistration.registerMethod
register(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

phase_offset

source
SubpixelRegistration.upsampled_dftMethod
SubpixelRegistration.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.

source