CortidQCT  1.2.2.52
LoadFromBST.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "VolumeSize.h"
15 #include "VoxelSize.h"
16 
17 #include <Eigen/Core>
18 #include <ImageStack/ImageStack.h>
19 #include <ImageStack/ImageStackLoaderBST.h>
20 #include <ImageStack/ResolutionDecorator.h>
21 #include <gsl/gsl>
22 
23 namespace CortidQCT {
24 
25 namespace IO {
26 
40 template <class F> void loadFromBST(std::string const &filename, F &&f) {
41  using Decorator = ImageStack::ResolutionDecorator;
42  using Img = ImageStack::ImageStack<float, ImageStack::HostStorage, Decorator>;
43  using Loader = ImageStack::ImageStackLoaderBST<Img>;
44 
45  auto const img = Img(Loader(filename));
46 
47  auto const mapping = img.map();
48  auto const size = img.size().template cast<std::size_t>().eval();
49  auto const resol = img.resolution.template cast<float>().eval();
50  VoxelSize voxelSize{resol.x(), resol.y(), resol.z()};
51  VolumeSize volumeSize{size.x(), size.y(), size.z()};
52 
53  f(mapping.data(), volumeSize, voxelSize);
54 }
55 
56 } // namespace IO
57 
58 } // namespace CortidQCT
Name namespace for CortidQCT library.
Definition: CortidQCT.h:23
This header contains the definition of the VoxelSize type.
void loadFromBST(std::string const &filename, F &&f)
Loads a BST file and calles the given functional with the loaded data.
Definition: LoadFromBST.h:40
Size type for a 3D voxel.
Definition: VolumeSize.h:22
Size type for a 3D voxel.
Definition: VoxelSize.h:22
This header contains the definition of the VolumeSize type.