Optical Transfer Functions
TransferFunctions.OTFArray — Type
OTFArray{T<:Number,N} <: OpticalTransferFunction{N}Fields
data::AbstractMatrix{T}center::Coordinate{2}
TransferFunctions.RadialOTF — Type
RadialOTF{N} <: OpticalTransferFunction{N}If the pupil function of the system is symmetric, the OTF as well as the PSF are radially symmetric which can be used to optimize the calculations.
Implementation
attenuation(model::A, fr::Frequency)cutoff(model::A, [a=0])returning the largest frequencyfsuch thatattenuation(model, f) >= aifa > 0and
attenuation(model, f) > 0 if a = 0.
TransferFunctions.otf — Function
otf(tf::OpticalTransferFunction, Δxy::PixelSize{2}, wh::Dims{2})otf(tf::PointSpreadFunction{2}, A::SpatialMatrix; ε=0.01)Sample an OTF from the transfer function tf for the image A using the energy error ε.
See also psf
julia> tf = AiryDisc{2}(λ=488u"nm", NA=1.4);
julia> A = SpatialMatrix(testimage("mandril_gray"), Δ);
julia> A_otf = otf(tf, A; ε=0.05);If the allowed energy error is too small that the sampled PSF does not fit into the array size that is Fourier transformed, then the resulting OTF may not be accurate to the specified error. In that case a warning is printed.
julia> A_otf_bad = otf(tf, SampledArray(ones(5,5), 61u"nm")); # prints a warning
julia> A_otf_bad[1,1] ≈ 1 # OTF should be 1 at the origin but this is not enforced
false
julia> A_otf[1,1] ≈ 1 # For it to be true array `A` must be large enough to hold the PSF with the specified error
trueTransferFunctions.insupport — Function
insupport(otf::OpticalTransferFunction, fx::Frequency, fy::Frequency)TransferFunctions.cutoff — Function
cutoff(::RadialOTF, a=0.0)TransferFunctions.attenuation — Function
attenuation(otf::OpticalTransferFunction, ::Frequency, ::Frequency)Point Spread Functions
TransferFunctions.psf — Function
psf(tf::PointSpreadFunction, Δ, wh::Dims; normalize=true)Generate a PSF array size wh for the model tf with the pixel size Δ.
julia> tf = AiryDisc{2}(λ=488u"nm", NA=1.4);
julia> A_psf = psf(tf, 61u"nm", (-3:3, -3:3))
7×7 SampledArray{Float64, Quantity{Int64, 𝐋, Unitful.FreeUnits{(nm,), 𝐋, nothing}}, 2, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, (61 nm, 61 nm)} with indices -3:3×-3:3:
0.00154644 7.98472e-5 0.000815467 0.00205246 0.000815467 7.98472e-5 0.00154644
7.98472e-5 0.00416274 0.0194095 0.0291836 0.0194095 0.00416274 7.98472e-5
0.000815467 0.0194095 0.0602568 0.0836632 0.0602568 0.0194095 0.000815467
0.00205246 0.0291836 0.0836632 0.1141 0.0836632 0.0291836 0.00205246
0.000815467 0.0194095 0.0602568 0.0836632 0.0602568 0.0194095 0.000815467
7.98472e-5 0.00416274 0.0194095 0.0291836 0.0194095 0.00416274 7.98472e-5
0.00154644 7.98472e-5 0.000815467 0.00205246 0.000815467 7.98472e-5 0.00154644
julia> sum(A_psf) ≈ 1
truepsf(tf::PointSpreadFunction{2}, Δ, ε::Real; <kwargs>)Sample the PSF tf with a pixel size Δ over a window such that the energy error is less than ε.
kwargs are passed to the final psf function.
TransferFunctions.fit — Function
fit(::PSFModel, ::SpatialArray)TransferFunctions.FWHM — Function
FWHM(psf::PointSpreadFunction)Find the FWHM of the PSF psf in the x and y directions.
See also HWHM
julia> tf = IsotropicGaussian(488u"nm", 1.4);
julia> TF.FWHM(tf)
(179.33894905055288 nm, 179.33894905055288 nm, 93.61250264937092 nm)TransferFunctions.HWHM — Function
HWHM(psf::PointSpreadFunction)Find the HWHM of the PSF psf in all the axes directions.
See also FWHM
julia> tf = AiryDisc(λ=488u"nm", NA=1.4);
julia> TransferFunctions.HWHM(tf)
((-89.66947452527637 nm, 89.66947452527637 nm), (-89.66947452527637 nm, 89.66947452527637 nm), (-147.04617530370933 nm, 147.04617530370933 nm))Non-linear Transfer Functions
TransferFunctions.ImpulseResponseMapping — Type
ImpulseResponseMapping{2} <: LinearTransferFunction{2}An impulse response mapping is a description of a transfer function that prescribes an impulse response to every point in the object plane. This may be a point spread function or some other function that prescribes the response to the object plane point in the image plane.
An transfer defined by an impulse response mapping is a linear system, but is not translation invariant hence does not belong to the class of linear transfer functions.
Internal Utility Functions and Types
Functions
TransferFunctions.roundcenter — Function
roundcenter(r::RoundingMode, A)Calculate the center index of A (::AbstractArray/::Indices/::Size/::AbstractUnitRange) rounded with the mode r::RoundingMode.
See also roundupcenter, rounddowncenter, exactcenter
TransferFunctions.roundupcenter — Function
roundupcenter(A)Calculate center index of A rounded-up (i.e. fft center).
Examples
julia> TF.roundupcenter(ones(15,15))
CartesianIndex(8, 8)
julia> TF.roundupcenter((16,16))
CartesianIndex(9, 9)TransferFunctions.rounddowncenter — Function
rounddowncenter(A)Calculate center index of A rounded-down (i.e. ifft center).
Examples
julia> TF.rounddowncenter(ones(15,15))
CartesianIndex(8, 8)
julia> TF.rounddowncenter((16,16))
CartesianIndex(8, 8)TransferFunctions.exactcenter — Function
exactcenter(A)Calculate the exact center coordinate of A.
Examples
julia> TF.exactcenter(ones(15,15))
(8.0, 8.0)
julia> TF.exactcenter((16,16))
(8.5, 8.5)TransferFunctions.aroundorigin — Function
aroundorigin(s::Size, origin=(0,0,...))Return the offset axes of an array of size s around the origin.
TransferFunctions.contained — Function
contained(A, loc::Coordinate{N})Return true if the coordinate loc is contained in the axes of array A.
TransferFunctions.interior — Function
interior(inds::Indices{N}, kern::Indices{N})Return 'valid' indices for convolution of an array with indices inds with a kernel having the indices kern.
TransferFunctions.freqgrid — Function
freqgrid(s::Size, Δ)Generate a frequency grid for multidimensional FFTs of the signal of size s with the pixel size Δ (i.e. sampling rate 1/Δ)
julia> x_f, y_f = TF.freqgrid((5,5), 50u"nm");
julia> x_f
5×5 Matrix{Quantity{Float64, 𝐋^-1, Unitful.FreeUnits{(nm^-1,), 𝐋^-1, nothing}}}:
0.0 nm^-1 0.0 nm^-1 0.0 nm^-1 0.0 nm^-1 0.0 nm^-1
0.004 nm^-1 0.004 nm^-1 0.004 nm^-1 0.004 nm^-1 0.004 nm^-1
0.008 nm^-1 0.008 nm^-1 0.008 nm^-1 0.008 nm^-1 0.008 nm^-1
-0.008 nm^-1 -0.008 nm^-1 -0.008 nm^-1 -0.008 nm^-1 -0.008 nm^-1
-0.004 nm^-1 -0.004 nm^-1 -0.004 nm^-1 -0.004 nm^-1 -0.004 nm^-1
julia> y_f' == x_f
true
julia> _,_,z_f = TF.freqgrid((4,4,3), (50u"nm", 30u"nm", 15u"nm"));
julia> z_f
4×4×3 Array{Quantity{Float64, 𝐋^-1, Unitful.FreeUnits{(nm^-1,), 𝐋^-1, nothing}}, 3}:
[:, :, 1] =
0.0 nm^-1 0.0 nm^-1 0.0 nm^-1 0.0 nm^-1
0.0 nm^-1 0.0 nm^-1 0.0 nm^-1 0.0 nm^-1
0.0 nm^-1 0.0 nm^-1 0.0 nm^-1 0.0 nm^-1
0.0 nm^-1 0.0 nm^-1 0.0 nm^-1 0.0 nm^-1
[:, :, 2] =
0.0222222 nm^-1 0.0222222 nm^-1 0.0222222 nm^-1 0.0222222 nm^-1
0.0222222 nm^-1 0.0222222 nm^-1 0.0222222 nm^-1 0.0222222 nm^-1
0.0222222 nm^-1 0.0222222 nm^-1 0.0222222 nm^-1 0.0222222 nm^-1
0.0222222 nm^-1 0.0222222 nm^-1 0.0222222 nm^-1 0.0222222 nm^-1
[:, :, 3] =
-0.0222222 nm^-1 -0.0222222 nm^-1 -0.0222222 nm^-1 -0.0222222 nm^-1
-0.0222222 nm^-1 -0.0222222 nm^-1 -0.0222222 nm^-1 -0.0222222 nm^-1
-0.0222222 nm^-1 -0.0222222 nm^-1 -0.0222222 nm^-1 -0.0222222 nm^-1
-0.0222222 nm^-1 -0.0222222 nm^-1 -0.0222222 nm^-1 -0.0222222 nm^-1TransferFunctions.posgrid — Function
posgrid(a::Indices, Δ)
posgrid(s::Size, Δ; center=roundupcenter(s))Generate a position grid for sampled images with the pixel/voxel size Δ.
If a size s is passed generate a position grid with the given size and the center in center. If Δ is a tuple of Lengths then the elements are used for the sampling in the respective dimensions. If Δ is a single length, then it is used for all dimensions.
julia> x_p, y_p = TF.posgrid((-3:5, -1:3), (50u"nm", 20u"nm"));
julia> x_p
9×5 Matrix{Quantity{Int64, 𝐋, Unitful.FreeUnits{(nm,), 𝐋, nothing}}}:
-150 nm -150 nm -150 nm -150 nm -150 nm
-100 nm -100 nm -100 nm -100 nm -100 nm
-50 nm -50 nm -50 nm -50 nm -50 nm
0 nm 0 nm 0 nm 0 nm 0 nm
50 nm 50 nm 50 nm 50 nm 50 nm
100 nm 100 nm 100 nm 100 nm 100 nm
150 nm 150 nm 150 nm 150 nm 150 nm
200 nm 200 nm 200 nm 200 nm 200 nm
250 nm 250 nm 250 nm 250 nm 250 nm
julia> y_p
9×5 Matrix{Quantity{Int64, 𝐋, Unitful.FreeUnits{(nm,), 𝐋, nothing}}}:
-20 nm 0 nm 20 nm 40 nm 60 nm
-20 nm 0 nm 20 nm 40 nm 60 nm
-20 nm 0 nm 20 nm 40 nm 60 nm
-20 nm 0 nm 20 nm 40 nm 60 nm
-20 nm 0 nm 20 nm 40 nm 60 nm
-20 nm 0 nm 20 nm 40 nm 60 nm
-20 nm 0 nm 20 nm 40 nm 60 nm
-20 nm 0 nm 20 nm 40 nm 60 nm
-20 nm 0 nm 20 nm 40 nm 60 nm
julia> TF.posgrid((3,3,3), 50u"nm")[3]
3×3×3 Array{Quantity{Int64, 𝐋, Unitful.FreeUnits{(nm,), 𝐋, nothing}}, 3}:
[:, :, 1] =
-50 nm -50 nm -50 nm
-50 nm -50 nm -50 nm
-50 nm -50 nm -50 nm
[:, :, 2] =
0 nm 0 nm 0 nm
0 nm 0 nm 0 nm
0 nm 0 nm 0 nm
[:, :, 3] =
50 nm 50 nm 50 nm
50 nm 50 nm 50 nm
50 nm 50 nm 50 nmTransferFunctions.posaxes — Function
posaxes(a::SampledArray)Returns the positions of the axes of samples in a.
See also posgrid
julia> sa = SampledArray(reshape(1:16, (4,4)), 61u"nm");
julia> TF.posaxes(sa)
((61:61:244) nm, (61:61:244) nm)
julia> TF.posgrid(sa)[1]
4×4 Matrix{Quantity{Int64, 𝐋, Unitful.FreeUnits{(nm,), 𝐋, nothing}}}:
61 nm 61 nm 61 nm 61 nm
122 nm 122 nm 122 nm 122 nm
183 nm 183 nm 183 nm 183 nm
244 nm 244 nm 244 nm 244 nmTransferFunctions.fillsize — Function
fillsize(Δ::Length, N::Integer) => PixelSize{N}Construct a PixelSize with the same sampling Δ in every direction.
TransferFunctions.inner_axes — Function
inner_axes(A, edges)
inner_axes(A, K)Determine the inner axes of the array with edges edges or when filtered with kernel K.
See also outer_axes.
julia> TF.inner_axes(ones(100,100), ((2,4), (1,10)))
(3:96, 2:90)
julia> TF.inner_axes(ones(100,100), OAs.OffsetArray(ones(11,11), -5:5, -3:7))
(6:95, 4:93)Type Aliases
TransferFunctions.Size — Type
Size{N}N-dimensional size of an array. Alias for NTuple{N,Int}
TransferFunctions.Coordinate — Type
Coordinate{N,T}N-dimensional coordinate. Alias for NTuple{N,T<:Real}
TransferFunctions.PixelSize — Type
PixelSize{N}N-dimensional pixel size. Alias for NTuple{N,Length}
TransferFunctions.OneEdge — Type
OneEdgeAlias for Tuple{Int,Int}.
An edge is a tuple with the interpretation of (start, end) that determines the padding applied in a BorderArray or a TaperedArray.
See also Edges
TransferFunctions.Edges — Type
Edges{N}Edges of an N-dimensional array. Alias for NTuple{N,OneEdge}
See also OneEdge, TaperedArray, BorderArray
Unit Types
TransferFunctions.Frequency — Type
TransferFunctions.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 — Type
TransferFunctions.FrequencyUnits{U}A supertype for units of dimension Unitful.𝐋 ^ -1. Equivalent to Unitful.Units{U, Unitful.𝐋 ^ -1}.
See also: Unitful.Units.
TransferFunctions.FrequencyFreeUnits — Type
TransferFunctions.FrequencyFreeUnits{U}A supertype for Unitful.FreeUnits of dimension Unitful.𝐋 ^ -1. Equivalent to Unitful.FreeUnits{U, Unitful.𝐋 ^ -1}.