Commit f1c4fa90 authored by remicres's avatar remicres

ENH: now graphOperations use segmenter functions for memory computation

parent 9f8abd77
......@@ -145,7 +145,7 @@ void WriteGraph(typename TSegmenter::GraphType& graph,
const unsigned int col);
template<class TSegmenter>
long long unsigned int GetGraphMemory(typename TSegmenter::GraphType& graph);
long long unsigned int GetGraphMemory(TSegmenter segmenter);
template<class TSegmenter>
void RemoveUnstableSegments(typename TSegmenter::GraphType& graph,
......
......@@ -190,22 +190,22 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::Paramet
segmenter.SetDoBFSegmentation(false);
segmenter.SetNumberOfIterations(niter);
std::cout << "\tPartial segmentation.." << std::endl;
std::cout << "\tPartial segmentation";
auto merge = lsrm::GraphOperations<TSegmenter>::PerfomAllIterationsWithLMBFAndConstThreshold(segmenter);
if(merge == true)
isFusion = true;
std::cout << "\tRemove unstable segments..." << std::endl;
// Remove unstable segments
std::cout << "\tRemove unstable segments..." << std::endl;
RemoveUnstableSegments<TSegmenter>(segmenter.m_Graph, tiles[row*nbTilesX + col], imageWidth);
// Retrieve the amount of memory to store this graph
accumulatedMemory += GetGraphMemory<TSegmenter>(segmenter.m_Graph);
std::cout << "\tGet graph memory..." << std::endl;
accumulatedMemory += GetGraphMemory<TSegmenter>(segmenter);
std::cout << "\tWrite graph..." << std::endl;
// Write graph to temporay directory (warning specific to Baatz & Schape !!!)
std::cout << "\tWrite graph..." << std::endl;
WriteGraph<TSegmenter>(segmenter.m_Graph, tmpDir, row, col);
}
}
......@@ -717,7 +717,7 @@ long long unsigned int RunFirstPartialSegmentation(
{
// Reading images
ProcessingTile currentTile = tiles[row*nbTilesX + col];
std::cout << "Processing tile " << row*nbTilesX + col <<
std::cout << "Processing tile " << (row*nbTilesX + col) << " / " << (nbTilesX*nbTilesY) <<
" (" << col << ", " << row << ")" <<
" start: [" << currentTile.region.GetIndex()[0] << ", " << currentTile.region.GetIndex()[1] <<
"] size: [" << currentTile.region.GetSize()[0] << ", " << currentTile.region.GetSize()[1] << "]" << std::endl;
......@@ -753,7 +753,7 @@ long long unsigned int RunFirstPartialSegmentation(
// Retrieve the amount of memory to store this graph
std::cout << "\tRetrieving graph memory..." << std::endl;
accumulatedMemory += GetGraphMemory<TSegmenter>(segmenter.m_Graph);
accumulatedMemory += GetGraphMemory<TSegmenter>(segmenter);
// Write graph to temporay directory (warning specific to Baatz & Schape !!!)
std::cout << "\tWriting graph..." << std::endl;
......@@ -1134,23 +1134,26 @@ void WriteGraph(typename TSegmenter::GraphType& graph,
}
template<class TSegmenter>
long long unsigned int GetGraphMemory(typename TSegmenter::GraphType& graph)
long long unsigned int GetGraphMemory(TSegmenter segmenter)
{
long long unsigned int memory = 0;
long unsigned int numberOfMoves = 0;
// Amount of memory needed to store the nodes
memory += graph.m_Nodes.size() * (sizeof(*graph.m_Nodes.begin()) + sizeof(graph.m_Nodes.begin()) + 4 * sizeof(float));
for(auto& node : graph.m_Nodes)
{
memory += node->m_Edges.size() * (sizeof(*node->m_Edges.begin()) + sizeof(node->m_Edges.begin()));
numberOfMoves += node->m_Contour.size();
}
memory += std::ceil(numberOfMoves / 4);
// TSegmenter::GraphType graph = segmenter.graph;
// long long unsigned int memory = 0;
// long unsigned int numberOfMoves = 0;
//
// // Amount of memory needed to store the nodes
// memory += graph.m_Nodes.size() * (sizeof(*graph.m_Nodes.begin()) + sizeof(graph.m_Nodes.begin()) + 4 * sizeof(float));
//
// for(auto& node : graph.m_Nodes)
// {
// memory += node->m_Edges.size() * (sizeof(*node->m_Edges.begin()) + sizeof(node->m_Edges.begin()));
// numberOfMoves += node->m_Contour.size();
// }
//
// memory += std::ceil(numberOfMoves / 4);
//
// return memory;
return memory;
return segmenter.GetGraphMemory();
}
template<class TSegmenter>
......
Markdown is supported
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