Sampled Arrays

A SampledArray is a light wrapper on a parent::AbstractArray that holds the sampling rate in every dimension.

Sampling

Only equidistant sampling is supported.

TransferFunctions.SampledArrayType
SampledArray{T,ST,N,AA<:AbstractArray} <: AbstractArray{T,N}

An N-dimensional sampled array with data of type T sample single spacing of type ST.

The restriction of ST being a single type means that SampledArray is not able to represent arrays that have different dimensions in each direction.

See also SampledMatrix, SampledVector, SpatialArray

source
TransferFunctions.SampledMatrixType
SampledMatrix{T,ST,AM} <: AbstractMatrix{T}

Two-dimensional array with elements of type T with a given sample spacing of type ST. Alias for SampledArray{T,ST,2,AM}.

source
TransferFunctions.SampledVectorType
SampledVector{T,ST,AV} <: AbstractVector{T}

One-dimensional array with elements of type T with a given sample spacing of type ST. Alias for SampledArray{T,ST,1,AV}.

source

Most relevant for microscopy images is the SpatialArray which is a SampledArray with Length being the dimension of the sampling.

TransferFunctions.SpatialMatrixType
SpatialMatrix{T,AM} <: AbstractMatrix{T}

Two-dimensional array with elements of type T with a given sampling distance in both directions. Alias for SpatialArray{T,2,AM}.

source
TransferFunctions.SpatialVectorType
SpatialVector{T,AV} <: AbstractVector{T}

One-dimensional array with elements of type T with a given sampling distance. Alias for SpatialArray{T,1,AV}.

source

You can construct a SampledArray by providing the parent and the sampling

A_sampled = SpatialArray(A, 61u"nm")
A_nonequally_sampled = SpatialArray(A, (61u"nm", 54u"nm"))

Methods on SampledArrays

To get the sampling vertices, you can use TransferFunctions.sample_vertices

TransferFunctions.sample_verticesMethod
sample_vertices(a::SampledArray, [pos])

Returns the vertices of the samples of a as SVector{2} equivalent to [x, y].

julia> sa = SampledArray(reshape(1:16, (4,4)), 61u"nm");

julia> TF.sample_vertices(sa)
4×4 Matrix{StaticArraysCore.SVector{2, Quantity{Int64, 𝐋, Unitful.FreeUnits{(nm,), 𝐋, nothing}}}}:
 [61 nm, 61 nm]   [61 nm, 122 nm]   [61 nm, 183 nm]   [61 nm, 244 nm]
 [122 nm, 61 nm]  [122 nm, 122 nm]  [122 nm, 183 nm]  [122 nm, 244 nm]
 [183 nm, 61 nm]  [183 nm, 122 nm]  [183 nm, 183 nm]  [183 nm, 244 nm]
 [244 nm, 61 nm]  [244 nm, 122 nm]  [244 nm, 183 nm]  [244 nm, 244 nm]

julia> TF.sample_vertices(sa, TF.mid)
4×4 Matrix{StaticArraysCore.SVector{2, Quantity{Float64, 𝐋, Unitful.FreeUnits{(nm,), 𝐋, nothing}}}}:
 [91.5 nm, 91.5 nm]   [91.5 nm, 152.5 nm]   [91.5 nm, 213.5 nm]   [91.5 nm, 274.5 nm]
 [152.5 nm, 91.5 nm]  [152.5 nm, 152.5 nm]  [152.5 nm, 213.5 nm]  [152.5 nm, 274.5 nm]
 [213.5 nm, 91.5 nm]  [213.5 nm, 152.5 nm]  [213.5 nm, 213.5 nm]  [213.5 nm, 274.5 nm]
 [274.5 nm, 91.5 nm]  [274.5 nm, 152.5 nm]  [274.5 nm, 213.5 nm]  [274.5 nm, 274.5 nm]

julia> TF.sample_vertices(sa, TF.right)
4×4 Matrix{StaticArraysCore.SVector{2, Quantity{Int64, 𝐋, Unitful.FreeUnits{(nm,), 𝐋, nothing}}}}:
 [122 nm, 122 nm]  [122 nm, 183 nm]  [122 nm, 244 nm]  [122 nm, 305 nm]
 [183 nm, 122 nm]  [183 nm, 183 nm]  [183 nm, 244 nm]  [183 nm, 305 nm]
 [244 nm, 122 nm]  [244 nm, 183 nm]  [244 nm, 244 nm]  [244 nm, 305 nm]
 [305 nm, 122 nm]  [305 nm, 183 nm]  [305 nm, 244 nm]  [305 nm, 305 nm]
source