Commit f1c4fa90 authored by remicres's avatar remicres
Browse files

ENH: now graphOperations use segmenter functions for memory computation

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