Commit f1892f1d authored by remicres's avatar remicres
Browse files

ENH: fallback to tiling=none when layout size is 1

Showing with 26 additions and 6 deletions
+26 -6
...@@ -35,6 +35,8 @@ public: ...@@ -35,6 +35,8 @@ public:
Controller(); Controller();
~Controller(); ~Controller();
void Modified();
void RunSegmentation(); void RunSegmentation();
void SetSpecificParameters(const SegmentationParameterType& params); void SetSpecificParameters(const SegmentationParameterType& params);
...@@ -42,9 +44,9 @@ public: ...@@ -42,9 +44,9 @@ public:
void SetInternalMemoryAvailable(long long unsigned int v); // expecting a value in Mbytes. void SetInternalMemoryAvailable(long long unsigned int v); // expecting a value in Mbytes.
/* Accessors */ /* Accessors */
void SetTilingModeNone(){m_TilingMode = LSGRM_TILING_NONE;}; void SetTilingModeNone(){m_TilingMode = LSGRM_TILING_NONE; Modified();};
void SetTilingModeUser(){m_TilingMode = LSGRM_TILING_USER;}; void SetTilingModeUser(){m_TilingMode = LSGRM_TILING_USER; Modified();};
void SetTilingModeAuto(){m_TilingMode = LSGRM_TILING_AUTO;}; void SetTilingModeAuto(){m_TilingMode = LSGRM_TILING_AUTO; Modified();};
typename LabelImageType::Pointer GetLabeledClusteredOutput(); typename LabelImageType::Pointer GetLabeledClusteredOutput();
std::vector<std::string> GetTemporaryFilesList(); std::vector<std::string> GetTemporaryFilesList();
......
...@@ -23,6 +23,13 @@ Controller<TSegmenter>::~Controller() ...@@ -23,6 +23,13 @@ Controller<TSegmenter>::~Controller()
{ {
} }
template<class TSegmenter>
void Controller<TSegmenter>::Modified()
{
Superclass::Modified();
m_Tiles.clear();
}
template<class TSegmenter> template<class TSegmenter>
void Controller<TSegmenter>::RunSegmentation() void Controller<TSegmenter>::RunSegmentation()
{ {
...@@ -53,7 +60,12 @@ void Controller<TSegmenter>::RunSegmentation() ...@@ -53,7 +60,12 @@ void Controller<TSegmenter>::RunSegmentation()
m_NbTilesX, m_NbTilesY, m_TemporaryFilesPrefix); m_NbTilesX, m_NbTilesY, m_TemporaryFilesPrefix);
// If there is only one tile, then fallback to LSGRM_TILING_NONE case // If there is only one tile, then fallback to LSGRM_TILING_NONE case
m_TilingMode = LSGRM_TILING_NONE; if (m_Tiles.size() == 1)
{
std::cout << "Only one tile is needed. Fallback to tiling=none." << std::endl;
SetTilingModeNone();
}
} }
if (m_TilingMode == LSGRM_TILING_AUTO || m_TilingMode == LSGRM_TILING_USER) if (m_TilingMode == LSGRM_TILING_AUTO || m_TilingMode == LSGRM_TILING_USER)
...@@ -163,6 +175,9 @@ void Controller<TSegmenter>::RunSegmentation() ...@@ -163,6 +175,9 @@ void Controller<TSegmenter>::RunSegmentation()
} }
else if (m_TilingMode == LSGRM_TILING_NONE)// tiling_mode is none else if (m_TilingMode == LSGRM_TILING_NONE)// tiling_mode is none
{ {
// Update input image
m_InputImage->Update();
// Use classic grm // Use classic grm
TSegmenter segmenter; TSegmenter segmenter;
segmenter.SetParam(m_SpecificParameters); segmenter.SetParam(m_SpecificParameters);
...@@ -171,6 +186,9 @@ void Controller<TSegmenter>::RunSegmentation() ...@@ -171,6 +186,9 @@ void Controller<TSegmenter>::RunSegmentation()
segmenter.SetNumberOfIterations(m_NumberOfIterations); segmenter.SetNumberOfIterations(m_NumberOfIterations);
segmenter.SetInput(m_InputImage); segmenter.SetInput(m_InputImage);
segmenter.Update(); segmenter.Update();
// Get label image
m_LabelImage = segmenter.GetLabeledClusteredOutput();
} }
else else
{ {
...@@ -181,6 +199,7 @@ void Controller<TSegmenter>::RunSegmentation() ...@@ -181,6 +199,7 @@ void Controller<TSegmenter>::RunSegmentation()
/* /*
* Compute the memory occupied by one node * Compute the memory occupied by one node
* TODO: compute the exact value
*/ */
template<class TSegmenter> template<class TSegmenter>
unsigned int Controller<TSegmenter>::GetNodeMemory() unsigned int Controller<TSegmenter>::GetNodeMemory()
...@@ -228,8 +247,7 @@ long unsigned int Controller<TSegmenter>::GetMaximumNumberOfNodesInMemory() ...@@ -228,8 +247,7 @@ long unsigned int Controller<TSegmenter>::GetMaximumNumberOfNodesInMemory()
} }
template<class TSegmenter> template<class TSegmenter>
void void Controller<TSegmenter>::ComputeMaximumStabilityMargin(unsigned int width,
Controller<TSegmenter>::ComputeMaximumStabilityMargin(unsigned int width,
unsigned int height, unsigned int &niter, unsigned int &margin) unsigned int height, unsigned int &niter, unsigned int &margin)
{ {
itkDebugMacro(<< "Computing maximum stability margin"); itkDebugMacro(<< "Computing maximum stability margin");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment