TransferFunctions.TransferFunction
— TypeAn N
-dimensional transfer function
Types
TransferFunctions.Frequency
— TypeTransferFunctions.Frequency{T, U}
A supertype for quantities and levels of dimension Unitful.𝐋 ^ -1
with a value of type T
and units U
.
See also: Unitful.Quantity
, Unitful.Level
.
TransferFunctions.FrequencyUnits
— TypeTransferFunctions.FrequencyUnits{U}
A supertype for units of dimension Unitful.𝐋 ^ -1
. Equivalent to Unitful.Units{U, Unitful.𝐋 ^ -1}
.
See also: Unitful.Units
.
TransferFunctions.FrequencyFreeUnits
— TypeTransferFunctions.FrequencyFreeUnits{U}
A supertype for Unitful.FreeUnits
of dimension Unitful.𝐋 ^ -1
. Equivalent to Unitful.FreeUnits{U, Unitful.𝐋 ^ -1}
.
Functions
TransferFunctions.psf
— FunctionIntensity point spread function i.e. the intensity ratio and phase shift of the sample intensity density
TransferFunctions.ipsf
— FunctionIntensity point spread function
TransferFunctions.apsf
— FunctionAmplitude point spread function
TransferFunctions.otf
— Functionoptical transfer function
TransferFunctions.pupil
— Functionpupil function
TransferFunctions.ptf
— Functionphase transfer function
TransferFunctions.mtf
— Functionmodulation transfer function
Utility Functions and Traits
TransferFunctions.roundupcenter
— FunctionTransferFunctions.roundupcenter(arr::AbstractArray)
Calculate center index of arr
rounded-up (i.e. fft
center)
Examples
julia> TF.roundupcenter(ones(15,15))
(8, 8)
julia> TF.roundupcenter(ones(16,16))
(9, 9)
julia> TF.roundupcenter(ones(15,15,15))
(8, 8, 8)
TransferFunctions.exactcenter
— Function TransferFunctions.exactcenter(a::AbstractArray)
Calculate the exact center index of a
Examples
julia> TF.exactcenter(ones(15,15))
(8.0, 8.0)
julia> TF.exactcenter(ones(16,16))
(8.5, 8.5)
julia> TF.exactcenter(ones(15,15,15))
(8.0, 8.0, 8.0)
TransferFunctions.RadiallySymmetric
— TypeIf the pupil function of the system is symmetric, the OTF as well as the PSF are radially symmteric which can be used to optimize the calculations.
Apodization
TransferFunctions.apodize
— Functionapodize(apo::Apodization, A::AbstractArray{<:Number,N}, cutoff::Real, width::Real) where {N}
Apply apodization to the input array A
.
Arguments
apo::Apodization
: The type of apodization to apply.A::AbstractArray{<:Number,N}
: The input array to be apodized.cutoff::Real
: The cutoff frequency for the apodization.width::Real
: The width of the transition region for the apodization.
TransferFunctions.taperedges
— Functiontaperedges([apo], A, width::Int, [border="replicate"]; dims=1:N)
taperedges([apo], A, (w1,...,wM), [border="replicate"]; dims =1:M)
taperedges([apo], A, ((w1_start,...,wM_start), (w1_end,...,wM_end)), [border="replicate"]; dims=1:M)
Taper a given width of the array A
's edges using apo::Apodization
apo
: Apodization function to use for the tapering. Default isCosine
.border="replicate"
: Similarly as withimfilter
, the arrayA
may be extended to avoid loss of the data at the edgeswidth::NTuple{M,Int}
orInt
orTuple{NTuple{M,Int},NTuple{M,Int}}
: The width of tapering at the edges.dims::NTuple{M,Int}
: The dimensions along which to taper the edges.
Apodization Functions
TransferFunctions.Apodization
— TypeApodization
Abstract type for apodization functions.
TransferFunctions.Blackman
— TypeBlackman{α::Real} == SineSum{3, ((1 - α) / 2, 1 / 2, α / 2) } <: Apodization
Default is α = 0.16
.
See also ExactBlackman
TransferFunctions.ExactBlackman
— TypeExactBlackman == Blackman{683 // 4652}
TransferFunctions.Connes
— TypeConnes <: Apodization
TransferFunctions.Cosine
— TypeCosine == PowerCosine{1} <: Apodization
- zero-phase function: $w₀(r) = \cos(πr/2)$
- instrument function: $I(k) = 4\cos(2k)/(π(1 - 16k²))$
TransferFunctions.Gaussian
— TypeGaussian(σ::Real) <: Apodization
Gaussian apodization function with a given standard deviation σ
.
- zero-phase function: $w₀(r) = e^{-r²/2σ²}$
TransferFunctions.Hamming
— TypeHamming == SineSum{2, (25//46, 21//46) } <: Apodization
TransferFunctions.Welch
— TypeWelch <: Apodization
- zero-phase function: $w₀(r) = 1 - r²$
TransferFunctions.BlackmanNuttall
— TypeBlackmanNuttall == SineSum{4, (0.3635819, 0.4891775, 0.1365995, 0.0106411) } <: Apodization
TransferFunctions.PowerCosine
— TypePowerCosine{α<:Real} <: Apodization
- zero-phase function: $w₀(r) = cos(πr/2)^α$
TransferFunctions.Triangular
— TypeTriangular <: Apodization
Formulas:
- zero-phase function: $w₀(r) = 1-|r|$
- instrument function: $I(k) = \mathop{sinc}²(π k)$
TransferFunctions.Nuttall
— TypeNuttall == SineSum{4, (0.355768, 0.487396, 0.144232, 0.012604) } <: Apodization
TransferFunctions.SineSum
— TypeSineSum{N::UInt, Cs::NTuple{N, Real}} <: Apodization
- zero-phase function: $w₀(r) = ∑ᴺₖ₌₀ (-1)ᵏ Cs[k] \cos(πk(r + 1))$
Instances: Hamming
, Nuttall
, BlackmanNuttall
, BlackmanHarris
, FlatTop
, Blackman
and ExactBlackman
TransferFunctions.BlackmanHarris
— TypeBlackmanHarris == SineSum{4, (0.35875, 0.48829, 0.14128, 0.01168) } <: Apodization
TransferFunctions.FlatTop
— TypeFlatTop == SineSum{5, (0.21557895, 0.41663158, 0.277263158, 0.083578947, 0.006947365) } <: Apodization
MATLAB varaint of the flat-top filter
TransferFunctions.Hann
— TypeHann == PowerCosine{2} <: Apodization
Formulas:
- zero-phase function: $w₀(r) = \cos²(πr/2)$
Deprecations
TransferFunctions.padtosize
— FunctionTransferFunctions.padtosize(a::AbstractArray{T,N}, size...; fourier=false, padvalue=0)
TransferFunctions.padtosize(a::AbstractArray{T,N}, size; fourier=false, padvalue=0)
Pad a
to a size
Padding is done in a way which ensures that if a
is symmetric and decreases to zero on the edges (!!) such that eltype(fft(a)) <: Real
, then, if possible, output is symmetric under the DFT and elyptype(fft(a_padded)) <: Real
). If a
is in the Fourier domain, then fourier
should de set to true
.
Arguments:
size
: size of the output array. Ifsize isa Integer
then size along all the dimensions issize
fourier
:a
is in the Fourier domain (default:false
).
Examples:
julia> TF.padtosize(reshape(1:4, 2,2), 3, 3)
3×3 Matrix{Int64}:
0 0 0
0 1 3
0 2 4
julia> TF.padtosize(reshape(1:4, 2,2), 4, 4)
4×4 Matrix{Int64}:
0 0 0 0
0 1 3 0
0 2 4 0
0 0 0 0
julia> TF.padtosize(reshape(1:4, 2,2), 3, 3; fourier=true)
3×3 Matrix{Int64}:
4 2 0
3 1 0
0 0 0
julia> TF.padtosize(reshape(1:4, 2,2), 4, 4; fourier=true)
4×4 Matrix{Int64}:
1 0 0 3
0 0 0 0
0 0 0 0
2 0 0 4
julia> ones(1,1) |> fft
1×1 Matrix{ComplexF64}:
1.0 + 0.0im
julia> TF.padtosize(ones(1,1), 2,2) |> fft
2×2 Matrix{ComplexF64}:
1.0+0.0im -1.0+0.0im
-1.0+0.0im 1.0+0.0im
julia> ones(2,2) |> fft
2×2 Matrix{ComplexF64}:
4.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im
julia> TF.padtosize(ones(2,2), 3, 3) |> fft # can be made symmetric
3×3 Matrix{ComplexF64}:
4.0+0.0im -2.0+0.0im -2.0+0.0im
-2.0+0.0im 1.0+0.0im 1.0+0.0im
-2.0+0.0im 1.0+0.0im 1.0+0.0im
julia> TF.padtosize(ones(2,2), 4, 4) |> fft # cannot be symmetric
4×4 Matrix{ComplexF64}:
4.0+0.0im -2.0-2.0im 0.0+0.0im -2.0+2.0im
-2.0-2.0im 0.0+2.0im 0.0+0.0im 2.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
-2.0+2.0im 2.0+0.0im 0.0+0.0im 0.0-2.0im
julia> @assert all(-10^-5 .< imag(fft(TF.padtosize(ones(2,2), 5, 5))) .< 10^-5) # .== 0 (numerical errors)