lsgrmController.h 3.73 KB
Newer Older
1
2
3
4
5
#ifndef __LSGRM_CONTROLLER_H
#define __LSGRM_CONTROLLER_H
#include "lsrmGetInternalMemory.h"
#include "lsgrmSplitter.h"
#include "lsgrmGraphOperations.h"
6
#include "itkObject.h"
7
#include "itkMacro.h"
8
9

namespace lsgrm
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{
template<class TSegmenter>
class ITK_EXPORT Controller : public itk::Object
{
public:

  /** Standard class typedef */
  typedef Controller Self;
  typedef itk::LightObject                     Superclass;
  typedef itk::SmartPointer<Self>              Pointer;
  typedef itk::SmartPointer<const Self>        ConstPointer;

  /** Runtime information support. */
  itkTypeMacro(Controller, itk::Object);

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

  /** Enum for tiling mode */
  enum LSGRMTilingMode
    {
    LSGRM_TILING_NONE,
    LSGRM_TILING_USER,
    LSGRM_TILING_AUTO
    };

  /* Some convenient typedefs */
  using SegmenterType = TSegmenter;
  using ImageType = typename SegmenterType::ImageType;
  using LabelImageType = typename SegmenterType::LabelImageType;
  using SegmentationParameterType = typename SegmenterType::ParameterType;

  /* Default constructor and destructor. */
  Controller();
  ~Controller();

  void RunSegmentation();

  void SetSpecificParameters(const SegmentationParameterType& params);
  void SetInputImage(ImageType * inputImage);
  void SetInternalMemoryAvailable(long long unsigned int v); // expecting a value in Mbytes.

  /* Accessors */
  void SetTilingModeNone(){m_TilingMode = LSGRM_TILING_NONE;};
  void SetTilingModeUser(){m_TilingMode = LSGRM_TILING_USER;};
  void SetTilingModeAuto(){m_TilingMode = LSGRM_TILING_AUTO;};

  typename LabelImageType::Pointer GetLabeledClusteredOutput();

  itkGetMacro(Margin, unsigned int);
  itkGetMacro(TemporaryFilesList, std::vector<std::string>);

  itkGetMacro(CleanTemporaryDirectory, bool);
  itkSetMacro(CleanTemporaryDirectory, bool);

  itkGetMacro(TemporaryDirectory, std::string);
  itkSetMacro(TemporaryDirectory, std::string);

  itkGetMacro(Threshold, float);
  itkSetMacro(Threshold, float);

  itkGetMacro(NumberOfIterations, unsigned int);
  itkSetMacro(NumberOfIterations, unsigned int);

  itkGetMacro(NbTilesX, unsigned int);
  itkSetMacro(NbTilesX, unsigned int);

  itkGetMacro(NbTilesY, unsigned int);
  itkSetMacro(NbTilesY, unsigned int);

  itkGetMacro(NumberOfFirstIterations, unsigned int);
  itkSetMacro(NumberOfFirstIterations, unsigned int);

  itkGetMacro(TileWidth, unsigned int);
  itkSetMacro(TileWidth, unsigned int);

  itkGetMacro(TileHeight, unsigned int);
  itkSetMacro(TileHeight, unsigned int);

private:

  void GetAutomaticConfiguration();
  long unsigned int GetMaximumNumberOfNodesInMemory();

  /* Parameters given by the user */
  std::string m_TemporaryDirectory;      // Directory used to store intermediate files during the process.
  bool        m_CleanTemporaryDirectory; // Clean the temporary directory.
  ImageType * m_InputImage;              // Input image

  /* Segmentation parameters */
  SegmentationParameterType m_SpecificParameters; // Specific parameters
  float                     m_Threshold;          // Threshold
  unsigned int              m_NumberOfIterations; // Number of iterations

  /* Parameters given by the user or computed automatically
   * depending of the chosen mode
   */
  long long unsigned int m_Memory; // RAM available for the computation.
  unsigned int m_NbTilesX;
  unsigned int m_NbTilesY;
  unsigned int m_NumberOfFirstIterations;
  unsigned int m_TileWidth;
  unsigned int m_TileHeight;

  /* read-only variables */
  unsigned int m_Margin;
  std::vector<ProcessingTile> m_Tiles;
  std::vector<std::string> m_TemporaryFilesList;
  LSGRMTilingMode m_TilingMode;
  typename LabelImageType::Pointer m_LabelImage;
};
121
122
123
124
} // end of namespace lsgrm

#include "lsgrmController.txx"
#endif