I am looking for a way to store matrix-like structures of sensor measurements, that are again matrices or vectors themselves. To give a more concrete example: Lets take an image, where a single pixel's RGB value can be represented as a Eigen::Vector3f
. As such an entire image would become something like
typedef Eigen::Array<Eigen::Vector3f, Eigen::Dynamic, Eigen::Dynamic> Image
.
Adding one more level on top we could have
typedef Eigen::Array<Image, Eigen::Dynamic, 1> VideoRecording
or
typedef Eigen::Array<Image, Eigen::Dynamic, Eigen::Dynamic Image> CamaraArrayCapture
.
Now, I don't need to do a lot of math on those outer storage containers, though some top-level multiplication and addition operator would be convenient for normalization purposes. However, what would be essential for me is block operations, e.g. for accessing an images Blue channel or retrieving all images in a VideoRecording
from a certain time. Last but not least I'd like the container to be iterable.
While thinking this through I came up with the following ideas:
Using plain a
Eigen::Array
orEigen::Matrix
as shown in the introduction and implement a few free functions returning something like ofEigen::Array<Eigen::Map<Eigen::Matrix<float,Eigen::Dynamic,1>>>
for nested block operations. While this might be the fastest to implement I don't really like this, since nested Eigen Matrices are officially not really supported...Use the same as above, but instead of having free functions, wrap it in a custom class, so that the a library's user won't expect unsupported operation like
VideoRecording
xVideoRecording
multiplication to work.Use an
Eigen::Tensor
from Eigen-unsupported for data storage. It does very powerful slicing operations, but I would loose all semantics about the included data. Also resizing a dataset would become quite inefficient size, since it would require to copy all data from all past images.There is an
Eigen::Image
class, which stores an RGB image as a3 x (row*cols)
matrix, where each column represents a pixel. Judging from the fact, that the class does not even have its own entry in Eigen's Wiki and the few Google hits I found I guess this class isn't widely known and/or used. Also it would still leave the problem on how to represent a structure of multiple images.When you tool is a hammer, everything looks like a nail - Forget about using an Eigen type for the outer structure and use something else, e.g. by implementing a class with an
std::vector
member. As this implies to re-build all block operation from scratch this feels a bit like re-inventing the wheel to me...
While I currently favor option two, I must admit that I am not really happy with either of these approaches... Since I am for sure not the first one asking how to represent an Image using Eigen types I am wondering if I am missing something and what would be the best practice to implement something this?
Eigen::Image
refers to en.wikipedia.org/wiki/Image_(mathematics) – chtzPointCloud
for Eigen Vectors I don't think it comes with a general purpose type that I could use for the kinematic states... – exocore