PhantomGenerator.h 2.56 KB
Newer Older
1
2
#pragma once

3
#include "elsaDefines.h"
4
5
6
7
8
#include "DataContainer.h"

namespace elsa
{
    /**
9
     * @brief This class generates 2d/3d phantoms, like the Shepp-Logan phantom.
10
     *
11
12
13
     * @author Maximilian Hornung - initial code
     * @author David Frank - fixes and modifications
     * @author Tobias Lasser - rewrite
14
     *
15
     * @tparam data_t data type for the DataContainer, defaulting to real_t
16
     */
Jens Petit's avatar
Jens Petit committed
17
18
19
20
21
    template <typename data_t = real_t>
    class PhantomGenerator
    {
    public:
        /**
22
         * @brief Create a modified Shepp-Logan phantom in 2d or 3d (with enhanced contrast).
Jens Petit's avatar
Jens Petit committed
23
24
25
26
27
28
         *
         * The phantom specifications are adapted from Matlab (which in turn references A.K. Jain,
         * "Fundamentals of Digital Image Processing", p. 439, and P.A. Toft, "The Radon Transform,
         * Theory and Implementation", p. 199).
         *
         * Warning: the 3D version is currently very inefficient to compute (cubic algorithm).
29
30
31
32
         *
         * @param[in] sizes a 2d/3d vector indicating the requested size (has to be square!)
         *
         * @returns DataContainer of specified size containing the phantom.
Jens Petit's avatar
Jens Petit committed
33
34
         */
        static DataContainer<data_t> createModifiedSheppLogan(IndexVector_t sizes);
35

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        /**
         * @brief Create a phantom with a simple n-dimensional rectangle  going from lower to upper.
         * It is assumed that lower < upper.
         *
         * @param[in] volumesize size of the volume
         * @param[in] lower the lower corner of the rectangle
         * @param[in] upper the upper corner of the rectangle
         */
        static DataContainer<data_t> createRectanglePhantom(IndexVector_t volumesize,
                                                            IndexVector_t lower,
                                                            IndexVector_t upper);

        /**
         * @brief Create a phantom with a simple n-dimensional sphere centered in the middle with
         * given raidus
         *
         * @param[in] volumesize size of the volume
         * @param[in] radius the radius of the circle
         */
        static DataContainer<data_t> createCirclePhantom(IndexVector_t volumesize, data_t radius);

Jens Petit's avatar
Jens Petit committed
57
58
59
    private:
        /// scale sizes from [0,1] to the (square) phantom size, producing indices (integers)
        static index_t scale(const DataDescriptor& dd, data_t value);
60

Jens Petit's avatar
Jens Petit committed
61
62
63
64
        /// scale and shift center coordinates to the (square) phantom size, producing indices
        /// (integers)
        static index_t scaleShift(const DataDescriptor& dd, data_t value);
    };
65
} // namespace elsa