public class HessianMatrix extends Object
Constructor and Description |
---|
HessianMatrix() |
public static <T extends RealType<T>,U extends RealType<U>> RandomAccessibleInterval<U> calculateMatrix(RandomAccessible<T> source, RandomAccessibleInterval<U> gaussian, RandomAccessibleInterval<U> gradient, RandomAccessibleInterval<U> hessianMatrix, OutOfBoundsFactory<U,? super RandomAccessibleInterval<U>> outOfBounds, double... sigma) throws IncompatibleTypeException
source
- n-dimensional input RandomAccessibleInterval
gaussian
- n-dimensional output parameter
RandomAccessibleInterval
gradient
- n+1-dimensional RandomAccessibleInterval
for storing
the gradients along all axes of the smoothed source (size of
last dimension is n)hessianMatrix
- n+1-dimensional RandomAccessibleInterval
for storing
all second partial derivatives as a linear representation
(size of last dimension is n * ( n + 1 ) / 2) of upper
triangular Hessian matrix: For n-dimensional input,
hessianMatrix
(m) will be populated along the nth
dimension like this: [m11, m12, ... , m1n, m22, m23, ... ,
mnn]outOfBounds
- OutOfBoundsFactory
that specifies how out of bound
pixels of intermediate results should be handled (necessary
for gradient computation).sigma
- Scale for Gaussian smoothing.IncompatibleTypeException
public static <T extends RealType<T>> RandomAccessibleInterval<T> calculateMatrix(RandomAccessible<T> source, RandomAccessibleInterval<T> gradient, RandomAccessibleInterval<T> hessianMatrix, OutOfBoundsFactory<T,? super RandomAccessibleInterval<T>> outOfBounds)
source
- n-dimensional pre-smoothed RandomAccessible
. It is the
callers responsibility to smooth the input at the desired
scales.gradient
- n+1-dimensional RandomAccessibleInterval
for storing
the gradients along all axes of the smoothed source (size of
last dimension is n)hessianMatrix
- n+1-dimensional RandomAccessibleInterval
for storing
all second partial derivatives as a linear representation
(size of last dimension is n * ( n + 1 ) / 2) of upper
triangular Hessian matrix: For n-dimensional input,
hessianMatrix
(m) will be populated along the nth
dimension like this: [m11, m12, ... , m1n, m22, m23, ... ,
mnn]outOfBounds
- OutOfBoundsFactory
that specifies how out of bound
pixels of intermediate results should be handled (necessary
for gradient computation).public static <T extends RealType<T>> RandomAccessibleInterval<T> calculateMatrix(RandomAccessible<T> gradients, RandomAccessibleInterval<T> hessianMatrix)
gradients
- n+1-dimensional RandomAccessible
containing the
gradients along all axes of the smoothed source (size of last
dimension is n)hessianMatrix
- n+1-dimensional RandomAccessibleInterval
for storing
all second partial derivatives as a linear representation
(size of last dimension is n * ( n + 1 ) / 2) of upper
triangular Hessian matrix: For n-dimensional input,
hessianMatrix
(m) will be populated along the nth
dimension like this: [m11, m12, ... , m1n, m22, m23, ... ,
mnn]public static <T extends RealType<T>,U extends RealType<U>> RandomAccessibleInterval<U> calculateMatrix(RandomAccessible<T> source, RandomAccessibleInterval<U> gaussian, RandomAccessibleInterval<U> gradient, RandomAccessibleInterval<U> hessianMatrix, OutOfBoundsFactory<U,? super RandomAccessibleInterval<U>> outOfBounds, int nTasks, ExecutorService es, double... sigma) throws IncompatibleTypeException, InterruptedException, ExecutionException
source
- n-dimensional input RandomAccessibleInterval
gaussian
- n-dimensional output parameter
RandomAccessibleInterval
gradient
- n+1-dimensional RandomAccessibleInterval
for storing
the gradients along all axes of the smoothed source (size of
last dimension is n)hessianMatrix
- n+1-dimensional RandomAccessibleInterval
for storing
all second partial derivatives as a linear representation
(size of last dimension is n * ( n + 1 ) / 2) of upper
triangular Hessian matrix: For n-dimensional input,
hessianMatrix
(m) will be populated along the nth
dimension like this: [m11, m12, ... , m1n, m22, m23, ... ,
mnn]outOfBounds
- OutOfBoundsFactory
that specifies how out of bound
pixels of intermediate results should be handled (necessary
for gradient computation).nTasks
- Number of tasks used for parallel computation of eigenvalues.es
- ExecutorService
providing workers for parallel
computation. Service is managed (created, shutdown) by caller.sigma
- Scale for Gaussian smoothing.IncompatibleTypeException
ExecutionException
InterruptedException
public static <T extends RealType<T>> RandomAccessibleInterval<T> calculateMatrix(RandomAccessible<T> source, RandomAccessibleInterval<T> gradient, RandomAccessibleInterval<T> hessianMatrix, OutOfBoundsFactory<T,? super RandomAccessibleInterval<T>> outOfBounds, int nTasks, ExecutorService es) throws IncompatibleTypeException, InterruptedException, ExecutionException
source
- n-dimensional pre-smoothed RandomAccessible
. It is the
callers responsibility to smooth the input at the desired
scales.gradient
- n+1-dimensional RandomAccessibleInterval
for storing
the gradients along all axes of the smoothed source (size of
last dimension is n)hessianMatrix
- n+1-dimensional RandomAccessibleInterval
for storing
all second partial derivatives as a linear representation
(size of last dimension is n * ( n + 1 ) / 2) of upper
triangular Hessian matrix: For n-dimensional input,
hessianMatrix
(m) will be populated along the nth
dimension like this: [m11, m12, ... , m1n, m22, m23, ... ,
mnn]outOfBounds
- OutOfBoundsFactory
that specifies how out of bound
pixels of intermediate results should be handled (necessary
for gradient computation).nTasks
- Number of tasks used for parallel computation of eigenvalues.es
- ExecutorService
providing workers for parallel
computation. Service is managed (created, shutdown) by caller.IncompatibleTypeException
ExecutionException
InterruptedException
public static <T extends RealType<T>> RandomAccessibleInterval<T> calculateMatrix(RandomAccessible<T> gradient, RandomAccessibleInterval<T> hessianMatrix, int nTasks, ExecutorService es) throws IncompatibleTypeException, InterruptedException, ExecutionException
gradient
- n+1-dimensional RandomAccessible
containing the
gradients along all axes of the smoothed source (size of last
dimension is n)hessianMatrix
- n+1-dimensional RandomAccessibleInterval
for storing
all second partial derivatives as a linear representation
(size of last dimension is n * ( n + 1 ) / 2) of upper
triangular Hessian matrix: For n-dimensional input,
hessianMatrix
(m) will be populated along the nth
dimension like this: [m11, m12, ... , m1n, m22, m23, ... ,
mnn]nTasks
- Number of tasks used for parallel computation of eigenvalues.es
- ExecutorService
providing workers for parallel
computation. Service is managed (created, shutdown) by caller.IncompatibleTypeException
ExecutionException
InterruptedException
public static <T extends RealType<T>> IntervalView<T> scaleHessianMatrix(RandomAccessibleInterval<T> hessian, double[] sigma)
calculateMatrix(net.imglib2.RandomAccessible<T>, net.imglib2.RandomAccessibleInterval<U>, net.imglib2.RandomAccessibleInterval<U>, net.imglib2.RandomAccessibleInterval<U>, net.imglib2.outofbounds.OutOfBoundsFactory<U, ? super net.imglib2.RandomAccessibleInterval<U>>, double...)
methods assume that the voxels
of the input data are isotropic. This is not always the case and the
finite differences would need to be normalized accordingly. As the
derivative is a linear transformation re-normalization (scaling) of the
Hessian matrix produces the desired result. In general, the normalization
is arbitrary and we choose to normalize such that the second derivative
remains unchanged along the dimension for which the extent of a voxel is
the smallest.
Note that the returned object is a View
on the Hessian matrix and
values are re-normalized as they are queried. For repeated use of the
re-normalized Hessian matrix, it might be beneficial to persist the
re-normalized values by copying into a RandomAccessibleInterval
.hessian
- Hessian matrix to be re-normalized (scaled).
hessian
is an n+1 dimensional
RandomAccessibleInterval
that stores a linear
representation of the upper triangular n-dimensional Hessian
matrix along the last dimension as specified in
calculateMatrix(RandomAccessible, RandomAccessibleInterval)
.sigma
- Specify the voxel size for each dimension.View
of the hessian matrix stored in
hessian
Copyright © 2015–2022 ImgLib2. All rights reserved.