Processing
There are a variety of functions defined by HCIToolbox to process HCI data. In particular, routines like derotating cubes, collapsing data cubes, scaling SDI data, etc. are available.
Many of the methods that work on cubes of data try to multi-thread the operations along the time axis. Make sure you set the environment variable JULIA_NUM_THREADS before staring your runtime to take advantage of this.
Index
HCIToolbox.collapseHCIToolbox.collapse!HCIToolbox.cropHCIToolbox.cropviewHCIToolbox.derotateHCIToolbox.derotate!HCIToolbox.expandHCIToolbox.flattenHCIToolbox.shift_frameHCIToolbox.shift_frame!
API/Reference
HCIToolbox.collapse — Functioncollapse(cube; method=median, fill=0, degree=Linear())
collapse(cube, angles; method=:deweight, fill=0, degree=Linear())Combine all the frames of a cube using method. If angles are provided, will use derotate before combining.
If method is :deweight, the method of Bottom et al. 2017 will be used in which the combined image will be the derotated weighted sum of the frames weighted by the temporal variance. Keyword arguments will be passed to derotate.
References
Examples
julia> X = ones(3, 3, 2);
julia> collapse(X)
3×3 Matrix{Float64}:
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
julia> collapse(X, [0, 90])
3×3 Matrix{Float64}:
1.0 1.0 0.5
1.0 1.0 1.0
0.5 0.5 0.5
julia> collapse(X, [0, 90], fill=NaN)
3×3 Matrix{Float64}:
1.0 1.0 NaN
1.0 1.0 1.0
NaN NaN NaN
See Also
HCIToolbox.collapse! — Functioncollapse!(cube, angles; method=:deweight, fill=0)An in-place version of the derotating collapse. The only difference is in this version the cube will be derotated in-place.
HCIToolbox.crop — Functioncrop(frame, size; center=center(frame), force=false)
crop(cube, size; center=center(cube), force=false)Crop a frame or cube to size. size can be a tuple or an integer, which will make a square crop. The indices will be relative to center. To avoid uneven (odd) cropping, we may change size. To disable this behavior, set force to true. To avoid allocations, consider cropview.
HCIToolbox.cropview — Functioncropview(cube::AbstractArray{T, 3}, size; center=center(cube), force=false)Crop a frame to size, returning a view of the frame. size can be a tuple or an integer, which will make a square crop. The indices will be relative to center. To avoid uneven (odd) cropping, we may change size. To disable this behavior, set force to true.
See Also
cropview(frame::AbstractMatrix, size; center=center(frame), force=false)Crop a frame to size, returning a view of the frame. size can be a tuple or an integer, which will make a square crop. The indices will be relative to center. To avoid uneven (odd) cropping, we may change size. To disable this behavior, set force to true.
See Also
HCIToolbox.derotate — Functionderotate(frame, angle; fill=0, degree=Linear())Rotates frame counter-clockwise by angle, given in degrees. This is merely a convenient wrapper around ImageTransformations.imrotate.
derotate(cube, angles; fill=0, degree=Linear())Rotates an array using the given angles in degrees.
This will rotate frame i counter-clockwise. Any values outside the original axes will be replaced with fill. If the given angles are true parallactic angles, the resultant cube will have each frame aligned with top pointing North. degree is the corresponding Interpolations.Degree for the B-Spline used to subsample the pixel values.
Examples
julia> X = zeros(3, 3, 1); X[2, 1, 1] = 1;
julia> X[:, :, 1]
3×3 Matrix{Float64}:
0.0 0.0 0.0
1.0 0.0 0.0
0.0 0.0 0.0
julia> derotate(X, [90])[:, :, 1]
3×3 Matrix{Float64}:
0.0 0.0 0.0
0.0 4.44089e-16 0.0
0.0 0.0 0.0See Also
HCIToolbox.derotate! — Functionderotate!(cube, angles; fill=0, degree=Linear())In-place version of derotate which modifies cube.
HCIToolbox.expand — Functionexpand(matrix)Given a matrix of size (z, n), returns a cube of size (x, x, n) where x=√z.
Will throw an error if z is not a perfect square.
Examples
julia> X = ones(4, 3)
4×3 Matrix{Float64}:
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
julia> expand(X)[:, :, 1]
2×2 Matrix{Float64}:
1.0 1.0
1.0 1.0See Also
HCIToolbox.flatten — Functionflatten(cube)Given a cube of size (x, y, n) returns a matrix with size (x * y, n) where each row is a flattened image from the cube.
Examples
julia> X = ones(2, 2, 3);
julia> flatten(X)
4×3 Matrix{Float64}:
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0See Also
HCIToolbox.shift_frame — Functionshift_frame(frame, dx, dy; fill=0)
shift_frame(frame, dpos; fill=0)Shifts frame by dx and dy with bilinear interpolation. If necessary, empty indices will be filled with fill.
Examples
julia> shift_frame([0 0 0; 0 1 0; 0 0 0], 1, -1)
3×3 Matrix{Float64}:
0.0 0.0 0.0
0.0 0.0 0.0
1.0 0.0 0.0
julia> shift_frame(ans, (-1, 1), fill=NaN)
3×3 Matrix{Float64}:
NaN 0.0 0.0
NaN 1.0 0.0
NaN NaN NaNshift_frame(cube, dx, dy; fill=0)
shift_frame(cube, dpos; fill=0)Shift each frame of cube by dx and dy, which can be integers or vectors. The change in position can be given as a tuple, which can also be put into a vector to use across the cube. If a frame is shifted outside its axes, the empty indices will be filled with fill.
See Also
HCIToolbox.shift_frame! — Functionshift_frame!(cube, dx, dy; fill=0)
shift_frame!(cube, dpos; fill=0)In-place version of shift_frame which modifies cube.