11#include <opencv2/core.hpp>
25using EigenPairs = std::array<std::pair<EigenValue, EigenVector>, 3>;
62 const cv::Vec3i& index,
85 const cv::Vec3d& index,
106 const cv::Vec3i& index,
130 const cv::Vec3d& index,
141template <
typename DType>
144 const cv::Vec3i& center,
150 for (std::int32_t k = center(2) - rz, c = 0; k <= center(2) + rz;
152 for (std::int32_t j = center(1) - ry, b = 0; j <= center(1) + ry;
154 for (std::int32_t i = center(0) - rx, a = 0; i <= center(0) + rx;
156 v(a, b, c) = DType(volume->intensityAt(i, j, k));
169template <
typename DType>
172 const cv::Vec3d& center,
176 const cv::Vec3d& xvec = {1, 0, 0},
177 const cv::Vec3d& yvec = {0, 1, 0},
178 const cv::Vec3d& zvec = {0, 0, 1})
180 Tensor3D<DType> v(2 * rx + 1, 2 * ry + 1, 2 * rz + 1);
181 for (
int c = 0; c < 2 * rz + 1; ++c) {
182 for (
int b = 0; b < 2 * ry + 1; ++b) {
183 for (
int a = 0; a < 2 * rx + 1; ++a) {
184 auto xOffset = -rx + a;
185 auto yOffset = -ry + b;
186 auto zOffset = -rz + c;
187 auto p = center + (xvec * xOffset) + (yvec * yOffset) +
189 v(a, b, c) = DType(volume->interpolateAt(p));
A 3rd-order tensor object.
std::shared_ptr< Volume > Pointer
Volume Cartographer library
StructureTensor ComputeVoxelStructureTensor(const Volume::Pointer &volume, int vx, int vy, int vz, int radius=1, int kernelSize=3)
Compute the structure tensor for a voxel position.
StructureTensor ComputeSubvoxelStructureTensor(const Volume::Pointer &volume, double vx, double vy, double vz, int radius=1, int kernelSize=3)
Compute the structure tensor for a subvoxel position.
static const auto ZERO_STRUCTURE_TENSOR
Tensor3D< DType > ComputeVoxelNeighbors(const Volume::Pointer &volume, const cv::Vec3i ¢er, std::int32_t rx, std::int32_t ry, std::int32_t rz)
Get an axis-aligned cuboid subvolume centered on a voxel.
EigenPairs ComputeVoxelEigenPairs(const Volume::Pointer &volume, int x, int y, int z, int radius=1, int kernelSize=3)
Compute the eigenvalues and eigenvectors from the structure tensor for a voxel position.
std::array< std::pair< EigenValue, EigenVector >, 3 > EigenPairs
cv::Matx33d StructureTensor
Tensor3D< DType > ComputeSubvoxelNeighbors(const Volume::Pointer &volume, const cv::Vec3d ¢er, int rx, int ry, int rz, const cv::Vec3d &xvec={1, 0, 0}, const cv::Vec3d &yvec={0, 1, 0}, const cv::Vec3d &zvec={0, 0, 1})
Get an axis-aligned cuboid subvolume centered on a subvoxel.
EigenPairs ComputeSubvoxelEigenPairs(const Volume::Pointer &volume, double x, double y, double z, int radius=1, int kernelSize=3)
Compute the eigenvalues and eigenvectors from the structure tensor for a subvoxel position.