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.

Multi-threading

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

API/Reference

HCIToolbox.collapseFunction
collapse(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

  1. Bottom et al. 2017 "Noise-weighted Angular Differential Imaging"

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

collapse!

source
HCIToolbox.collapse!Function
collapse!(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.

source
HCIToolbox.cropFunction
crop(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.

source
HCIToolbox.cropviewFunction
cropview(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

crop

source
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

crop

source
HCIToolbox.derotateFunction
derotate(frame, angle; fill=0, degree=Linear())

Rotates frame counter-clockwise by angle, given in degrees. This is merely a convenient wrapper around ImageTransformations.imrotate.

source
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.0

See Also

derotate!

source
HCIToolbox.expandFunction
expand(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.0

See Also

flatten

source
HCIToolbox.flattenFunction
flatten(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.0

See Also

expand

source
HCIToolbox.shift_frameFunction
shift_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    NaN
source
shift_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

shift_frame!

source