19#include <opencv2/core/mat.hpp>
69 Tensor(
const std::string &fname);
89 const float &
operator()(
int i,
int j,
int k)
const;
120 void remap(
float vmin = 0.f,
float vmax = 1.f);
166 void to_png(
const std::string &fname,
int depth = CV_8U);
Header file defining basic vector and matrix manipulation classes.
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
A class to represent a multi-dimensional tensor.
Definition tensor.hpp:37
void remap(float vmin=0.f, float vmax=1.f)
Remap the tensor values to a new range.
Definition tensor.cpp:84
float min() const
Find the minimum value in the tensor.
Definition tensor.cpp:79
Array get_slice(int k) const
Get a 2D slice of the tensor along the z-axis.
Definition tensor.cpp:63
float max() const
Find the maximum value in the tensor.
Definition tensor.cpp:74
Vec3< int > shape
Shape of the tensor in 3D space.
Definition tensor.hpp:42
float & operator()(int i, int j, int k)
Access an element of the tensor.
Definition tensor.cpp:53
std::vector< uint8_t > to_img_8bit()
Convert the tensor to an 8-bit image represented as a vector.
Definition tensor.cpp:149
void set_slice(int k, const Array &slice)
Set a 2D slice of the tensor along the z-axis.
Definition tensor.cpp:110
cv::Mat to_cv_mat()
Convert the tensor to an OpenCV matrix.
Definition tensor.cpp:119
std::vector< float > vector
Flattened vector containing the tensor's elements.
Definition tensor.hpp:47
Tensor resample_to_shape_xy(Vec2< int > new_shape_xy)
Resamples the tensor to a new 2D shape (x, y), shape along z is not changed.
Definition tensor.cpp:97
void to_png(const std::string &fname, int depth=CV_8U)
Saves the Tensor as a PNG image file.
Definition tensor.cpp:140
Definition algebra.hpp:28
Vec2 class for basic manipulation of 2D vectors.
Definition algebra.hpp:40
Vec3 class for basic manipulation of 3D vectors.
Definition algebra.hpp:281