Commit 7df06429 authored by remicres's avatar remicres

ENH: remote writing tiles on disk

parent 91852f09
......@@ -14,6 +14,7 @@ namespace lsgrm
/* 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. */
......@@ -24,29 +25,26 @@ namespace lsgrm
void SetImageDivision(bool f);
void SetInputImage(ImageType * inputImage);
void SetTileDirectory(const std::string& str);
void SetTemporaryDirectory(const std::string& str);
void SetOutputGraphDirectory(const std::string& str);
void SetTileWidth(const unsigned int v);
void SetTileHeight(const unsigned int v);
void SetNumberOfFirstIterations(const unsigned int v);
void SetSpecificParameters(const SegmentationParameterType& params);
void SetThreshold(const float& t);
void SetInternalMemoryAvailable(long long unsigned int v); // expecting a value in Mbytes.
void SetAutomaticTilingLayout(bool value);
typename LabelImageType::Pointer GetLabeledClusteredOutput();
private:
void GetAutomaticConfiguration();
long unsigned int GetMaximumNumberOfNodesInMemory();
/* Parameters given by the user */
long long unsigned int m_Memory; // RAM available for the computation.
ImageType * m_InputImage; // Input image
std::string m_TileDirectory; // Directory containing tiles (if the process of dividing is not activated
// then the directory must contain the tiles and the info.txt file.)
std::string m_TemporaryDirectory; // Directory used to store intermediate files during the process.
std::string m_OutputGraphDirectory;
std::string m_OutputLabelImage; // Output label image path.
bool m_ImageDivisionActivated; // The input image must be divided.
bool m_CleanTemporaryDirectory; // Clean the temporary directory.
......@@ -61,8 +59,11 @@ namespace lsgrm
unsigned int m_Margin;
unsigned int m_TileWidth;
unsigned int m_TileHeight;
bool m_AutomaticTilingLayout;
std::vector<ProcessingTile> m_Tiles;
typename LabelImageType::Pointer m_LabelImage;
};
} // end of namespace lsgrm
......
......@@ -19,102 +19,99 @@ template<class TSegmenter>
void Controller<TSegmenter>::RunSegmentation()
{
// Rajouter un if pour vérifier si l'utilisateur a enclenché la procédure automatique
// Automatic procedure
if(m_Memory < 1)
{
this->GetAutomaticConfiguration();
}
else
{
m_Margin = static_cast<unsigned int>(pow(2, m_NumberOfFirstIterations + 1) - 2);
}
if(m_ImageDivisionActivated)
{
// Compute the splitting scheme
SplitOTBImage<ImageType>(m_InputImage, m_TileWidth, m_TileHeight, m_Margin, m_NumberOfFirstIterations,
SplitOTBImage<ImageType>(m_InputImage, m_TileWidth, m_TileHeight, m_Margin,
m_NbTilesX, m_NbTilesY, m_Tiles);
// // Boolean indicating if there are remaining fusions
// bool isFusion = false;
//
// // Run first partial segmentation
// boost::timer t; t.restart();
// auto accumulatedMemory = RunFirstPartialSegmentation<TSegmenter>(
// m_InputImage,
// m_SpecificParameters,
// m_Threshold,
// m_NumberOfFirstIterations,
// 3,
// m_Tiles,
// m_TileDirectory,
// m_NbTilesX,
// m_NbTilesY,
// m_Margin,
// m_TileWidth,
// m_TileHeight,
// m_InputImage->GetLargestPossibleRegion().GetSize()[0],
// m_InputImage->GetLargestPossibleRegion().GetSize()[1],
// m_TemporaryDirectory,
// isFusion);
//
// // Gathering useful variables
// GatherUsefulVariables(accumulatedMemory, isFusion);
//
// // Time monitoring
// ShowTime(t);
//
// while(accumulatedMemory > m_Memory && isFusion)
// {
//
// isFusion = false;
// accumulatedMemory = RunPartialSegmentation<TSegmenter>(m_SpecificParameters,
// m_Threshold,
// 3,
// m_Tiles,
// m_TemporaryDirectory,
// m_NbTilesX,
// m_NbTilesY,
// m_TileWidth,
// m_TileHeight,
// m_InputImage->GetLargestPossibleRegion().GetSize()[0],
// m_InputImage->GetLargestPossibleRegion().GetSize()[1],
// m_InputImage->GetNumberOfComponentsPerPixel(),
// isFusion);
//
// // Gathering useful variables
// GatherUsefulVariables(accumulatedMemory, isFusion);
//
// // Time monitoring
// ShowTime(t);
// }
//
//
//#ifdef OTB_USE_MPI
// if (otb::MPIConfig::Instance()->GetMyRank() != 0)
// return;
//#endif
//
// if(accumulatedMemory <= m_Memory)
if (true)
// Boolean indicating if there are remaining fusions
bool isFusion = false;
// Run first partial segmentation
boost::timer t; t.restart();
auto accumulatedMemory = RunFirstPartialSegmentation<TSegmenter>(
m_InputImage,
m_SpecificParameters,
m_Threshold,
m_NumberOfFirstIterations,
3,
m_Tiles,
m_NbTilesX,
m_NbTilesY,
m_TileWidth,
m_TileHeight,
m_InputImage->GetLargestPossibleRegion().GetSize()[0],
m_InputImage->GetLargestPossibleRegion().GetSize()[1],
m_TemporaryDirectory,
isFusion);
// Gathering useful variables
GatherUsefulVariables(accumulatedMemory, isFusion);
// Time monitoring
ShowTime(t);
while(accumulatedMemory > m_Memory && isFusion)
{
// Merge all the graphs
MergeAllGraphsAndAchieveSegmentation<TSegmenter>(
isFusion = false;
accumulatedMemory = RunPartialSegmentation<TSegmenter>(
m_SpecificParameters,
m_Threshold,
3,
m_Tiles,
m_TemporaryDirectory,
m_NbTilesX,
m_NbTilesY,
m_TileWidth,
m_TileHeight,
m_InputImage->GetLargestPossibleRegion().GetSize()[0],
m_InputImage->GetLargestPossibleRegion().GetSize()[1],
m_InputImage->GetNumberOfComponentsPerPixel(),
m_OutputGraphDirectory);
isFusion);
// Gathering useful variables
GatherUsefulVariables(accumulatedMemory, isFusion);
// Time monitoring
ShowTime(t);
}
#ifdef OTB_USE_MPI
if (otb::MPIConfig::Instance()->GetMyRank() != 0)
return;
#endif
if(accumulatedMemory <= m_Memory)
{
// Merge all the graphs
m_LabelImage = MergeAllGraphsAndAchieveSegmentation<TSegmenter>(
m_SpecificParameters,
m_Threshold,
m_Tiles,
m_TemporaryDirectory,
m_NbTilesX,
m_NbTilesY,
m_InputImage->GetLargestPossibleRegion().GetSize()[0],
m_InputImage->GetLargestPossibleRegion().GetSize()[1],
m_InputImage->GetNumberOfComponentsPerPixel());
// ShowTime(t);
// ShowTime(t);
}
else
{
// That means there are no more possible fusions but we can not store the ouput graph
// That means there are no more possible fusions but we can not store the output graph
// Todo do not clean up temporary directory before copying resulting graph to the output directory
// In the output directory add an info file to give the number of tiles.
}
......@@ -128,8 +125,9 @@ void Controller<TSegmenter>::RunSegmentation()
}
template<class TSegmenter>
void Controller<TSegmenter>::GetAutomaticConfiguration()
long unsigned int Controller<TSegmenter>::GetMaximumNumberOfNodesInMemory()
{
m_Memory = getMemorySize();
assert(m_Memory > 0);
......@@ -141,15 +139,70 @@ void Controller<TSegmenter>::GetAutomaticConfiguration()
using NodePointer = typename TSegmenter::NodePointerType;
using EdgeType = typename TSegmenter::EdgeType;
// long long unsigned int sizePerNode = sizeof(NodePointer) + sizeof(NodeType) + 1 + 4 *(sizeof(EdgeType) + sizeof(float)); // last term is specific to BS.
// long long unsigned int sizePerNode = sizeof(NodePointer) + sizeof(NodeType) + 1 + 4 *(sizeof(EdgeType) + sizeof(float)); // last term is specific to BS.
long long unsigned int sizePerNode = sizeof(NodePointer);
sizePerNode += sizeof(NodeType) + 1;
sizePerNode += sizeof(float) * m_InputImage->GetNumberOfComponentsPerPixel(); //Specific to BS: means, squeredMeans, spectralSums, stds
sizePerNode += 4 * (sizeof(EdgeType) + sizeof(float)); // 4 neighbors
long unsigned int maximumNumberOfNodes = std::ceil(m_Memory / sizePerNode);
unsigned int tileDimension = std::sqrt(maximumNumberOfNodes);
long unsigned int maximumNumberOfNodes = (long unsigned int) std::ceil(((float) m_Memory) / ((float) sizePerNode));
return maximumNumberOfNodes;
}
template<class TSegmenter>
void Controller<TSegmenter>::GetAutomaticConfiguration()
{
// Compute the maximum number of nodes that can fit the memory
unsigned long int maximumNumberOfNodesInMemory = GetMaximumNumberOfNodesInMemory();
// With a margin, this number will be actually 4 times greater
// (assuming that maxMargin = tileDimension/2)
maximumNumberOfNodesInMemory /= 4;
// Find the largest tile with the lowest compactness
const unsigned int imageWidth = m_InputImage->GetLargestPossibleRegion().GetSize()[0];
const unsigned int imageHeight = m_InputImage->GetLargestPossibleRegion().GetSize()[1];
unsigned int nbOfTiles = 1; // total number of tiles
m_NbTilesX = 1;
m_NbTilesY = 1;
const unsigned long int nbOfNodesInImage = imageWidth*imageHeight;
unsigned int tileWidth(0), tileHeight(0);
while( nbOfNodesInImage / ((float) nbOfTiles) > maximumNumberOfNodesInMemory)
{
// Get the multiples of k. For each one, compute the
// layout which has the minimum tile compactness
float lowestCompactness = itk::NumericTraits<float>::max();
for (unsigned int layoutNCol = 1; layoutNCol<=nbOfTiles; layoutNCol++)
{
if (nbOfTiles % layoutNCol == 0) // Is it a multiple of the nb of Tiles?
{
// Compute tile compactness
unsigned int layoutNRow = nbOfTiles / layoutNCol;
tileWidth = imageWidth / layoutNCol;
tileHeight = imageHeight / layoutNRow;
float perimeter = tileWidth + tileHeight;
float surface = tileWidth * tileHeight;
float compactness = perimeter / surface;
// Update minimum compactness
if (lowestCompactness > compactness)
{
lowestCompactness = compactness;
m_NbTilesX = layoutNCol;
m_NbTilesY = layoutNRow;
}
}
} // for each multiple of k
nbOfTiles++;
} // while
// Compute the tile size
m_TileWidth = static_cast<unsigned int>(imageWidth/m_NbTilesX);
m_TileHeight = static_cast<unsigned int>(imageHeight/m_NbTilesY);
// Compute the stability margin. The naive strategy consider a margin value and a stable size equal.
unsigned int tileDimension = std::min(m_TileWidth, m_TileHeight);
unsigned int niter = 1;
unsigned int maxMargin = tileDimension/2;
unsigned int currMargin = static_cast<unsigned int>(pow(2, niter + 1) - 2);
......@@ -162,22 +215,27 @@ void Controller<TSegmenter>::GetAutomaticConfiguration()
currMargin = static_cast<unsigned int>(pow(2, niter + 1) - 2);
}
m_TileWidth = tileDimension - prevMargin;
m_TileHeight = m_TileWidth;
m_Margin = prevMargin;
m_NumberOfFirstIterations = niter - 1;
std::cerr <<
"Configuration: \n" <<
"Available RAM: " << m_Memory << "\n" <<
"Max. number of nodes: " << maximumNumberOfNodes << "\n" <<
"Max. tile dimension: " << tileDimension << "\n" <<
"Nb. iter: " << niter << "\n" <<
"Margin: " << prevMargin << "\n" <<
"Tile size: " << m_TileWidth << " x " << m_TileHeight << std::endl;
std::cout <<
"--- Configuration: \n" <<
"\tAvailable RAM: " << m_Memory << "\n" <<
"\tInput image dimensions: " << imageWidth << " x " << imageHeight << "\n" <<
"\tMaximum number of nodes in memory: " << maximumNumberOfNodesInMemory << "\n" <<
"\tOptimal square tile size: " << tileDimension << "\n" <<
"\tNumber of first iterations: " << niter << "\n" <<
"\tStability margin: " << prevMargin << "\n" <<
"\tComputed tile size: " << m_TileWidth << " x " << m_TileHeight << std::endl;
}
template <class TSegmenter>
void Controller<TSegmenter>::SetTemporaryDirectory(const std::string& str)
{
m_TemporaryDirectory = str;
}
template <class TSegmenter>
void Controller<TSegmenter>::SetInternalMemoryAvailable(long long unsigned int v) // expecting a value in Mbytes.
{
......@@ -192,27 +250,15 @@ void Controller<TSegmenter>::SetImageDivision(bool f)
}
template<class TSegmenter>
void Controller<TSegmenter>::SetInputImage(ImageType * inputImage)
{
m_InputImage = inputImage;
}
template<class TSegmenter>
void Controller<TSegmenter>::SetOutputGraphDirectory(const std::string& str)
void Controller<TSegmenter>::SetAutomaticTilingLayout(bool value)
{
m_OutputGraphDirectory = str;
m_AutomaticTilingLayout = value;
}
template<class TSegmenter>
void Controller<TSegmenter>::SetTileDirectory(const std::string& str)
{
m_TileDirectory = str;
}
template<class TSegmenter>
void Controller<TSegmenter>::SetTemporaryDirectory(const std::string& str)
void Controller<TSegmenter>::SetInputImage(ImageType * inputImage)
{
m_TemporaryDirectory = str;
m_InputImage = inputImage;
}
template<class TSegmenter>
......@@ -245,4 +291,11 @@ void Controller<TSegmenter>::SetThreshold(const float& t)
{
m_Threshold = t;
}
template<class TSegmenter>
typename Controller<TSegmenter>::LabelImageType::Pointer
Controller<TSegmenter>::GetLabeledClusteredOutput()
{
return m_LabelImage;
}
} // end of namespace lsgrm
......@@ -14,7 +14,7 @@ struct ProcessingTile
long int rows[2]; // lower and upper rows (-1 means that the row has not be considered)
long int columns[2]; // lower and upper columns (-1 means that the row has not be considered)
long int tileNeighbors[8]; // tile Neighbors at (top, top right, right, bottom right, bottom, bottom left, left, top left)
bool margin[4]; // Is there a margin at top, left, bottom or right
long int margin[4]; // Is there a margin at top, left, bottom or right
otb::VectorImage<double>::RegionType region; // The image region
};
......@@ -25,19 +25,17 @@ typename TSegmenter::ImageType::Pointer ReadImageRegion(
typename TSegmenter::ImageType::RegionType region);
template<class TSegmenter>
void MergeAllGraphsAndAchieveSegmentation(
typename TSegmenter::LabelImageType::Pointer
MergeAllGraphsAndAchieveSegmentation(
const typename TSegmenter::ParameterType& params,
const float& threshold,
std::vector<ProcessingTile>& tiles,
const std::string& tmpDir,
const unsigned int nbTilesX,
const unsigned int nbTilesY,
const unsigned int tileWidth,
const unsigned int tileHeight,
const unsigned int imageWidth,
const unsigned int imageHeight,
const unsigned int imageBands,
const std::string& outputGraphDirectory);
const unsigned int imageBands);
template<class TSegmenter>
long long unsigned int RunFirstPartialSegmentation(
......@@ -47,10 +45,8 @@ long long unsigned int RunFirstPartialSegmentation(
const unsigned int niter,
const unsigned int niter2,
std::vector<ProcessingTile>& tiles,
const std::string& tileDir,
const unsigned int nbTilesX,
const unsigned int nbTilesY,
const unsigned int margin,
const unsigned int tileWidth,
const unsigned int tileHeight,
const unsigned int imageWidth,
......@@ -67,8 +63,6 @@ long long unsigned int RunPartialSegmentation(
const std::string& tmpDir,
const unsigned int nbTilesX,
const unsigned int nbTilesY,
const unsigned int tileWidth,
const unsigned int tileHeight,
const unsigned int imageWidth,
const unsigned int imageHeight,
const unsigned int imageBands,
......@@ -110,14 +104,11 @@ void BuildBorderPixelMap(typename TSegmenter::GraphType& graph,
template<class TSegmenter>
void AddStabilityMargin(typename TSegmenter::GraphType& graph,
ProcessingTile& tile,
const std::string& tmpDir,
const unsigned int row,
const unsigned int col,
const unsigned int nbTilesX,
const unsigned int nbTilesY,
const unsigned int tileWidth,
const unsigned int tileHeight);
const unsigned int nbTilesY);
template<class TSegmenter>
void WriteStabilityMargin(std::unordered_map<
......@@ -170,7 +161,6 @@ void RescaleGraph(typename TSegmenter::GraphType& graph,
ProcessingTile& tile,
const unsigned int rowTile,
const unsigned int colTile,
const unsigned int margin,
const unsigned int tileWidth,
const unsigned int tileHeight,
const unsigned int imageWidth);
......
......@@ -22,19 +22,17 @@ typename TSegmenter::ImageType::Pointer ReadImageRegion(
}
template<class TSegmenter>
void MergeAllGraphsAndAchieveSegmentation(
typename TSegmenter::LabelImageType::Pointer
MergeAllGraphsAndAchieveSegmentation(
const typename TSegmenter::ParameterType& params,
const float& threshold,
std::vector<ProcessingTile>& tiles,
const std::string& tmpDir,
const unsigned int nbTilesX,
const unsigned int nbTilesY,
const unsigned int tileWidth,
const unsigned int tileHeight,
const unsigned int imageWidth,
const unsigned int imageHeight,
const unsigned int imageBands,
const std::string& outputGraphDirectory)
const unsigned int imageBands)
{
// TODO parallelize this ...
......@@ -48,11 +46,14 @@ void MergeAllGraphsAndAchieveSegmentation(
std::cout << "--- Graph aggregation...\n" << std::endl;
std::cout << "Reading graphs" << std::endl;
for(unsigned int row = 0; row < nbTilesY; ++row)
{
for(unsigned int col = 0; col < nbTilesX; col++)
{
// std::cout << "*" << std::flush;
std::cout << "\tImporting graph of tile " << (row*nbTilesX + col) << " / " << (nbTilesX*nbTilesY) << std::endl;
typename TSegmenter::GraphType graph;
// Load the graph
......@@ -66,43 +67,35 @@ void MergeAllGraphsAndAchieveSegmentation(
}
}
std::cout << "\nRemoving duplicated nodes and updating neighbors..." << std::endl;
std::cout << "Removing duplicated nodes and updating neighbors" << std::endl;
// TODO this might be parallelized...
for(unsigned int row = 0; row < nbTilesY; ++row)
{
for(unsigned int col = 0; col < nbTilesX; col++)
{
// std::cout << "*" << std::flush;
// if (MyTurn(myrank,nprocs,row*nbTilesX + col))
{
std::cout << "Cleaning nodes of tile " << (row*nbTilesX + col) << " on " << (nbTilesX*nbTilesY) << std::endl;
std::cout << "Cleaning nodes of tile " << (row*nbTilesX + col) << " / " << (nbTilesX*nbTilesY) << std::endl;
std::unordered_map<long unsigned int,
std::vector<typename TSegmenter::NodePointerType> > borderPixelMap;
std::cout << "BuildBorderPixelMap" << std::endl;
std::cout << "\tBuildBorderPixelMap..." << std::endl;
BuildBorderPixelMap<TSegmenter>(segmenter.m_Graph, tiles[row*nbTilesX + col], row, col,
nbTilesX, nbTilesY, borderPixelMap, imageWidth);
std::cout << "RemoveDuplicatedNodes" << std::endl;
std::cout << "\tRemoveDuplicatedNodes..." << std::endl;
RemoveDuplicatedNodes<TSegmenter>(borderPixelMap, segmenter.m_Graph, imageWidth);
std::cout << "UpdateNeighborsOfNoneDuplicatedNodes" << std::endl;
std::cout << "\tUpdateNeighborsOfNoneDuplicatedNodes..." << std::endl;
UpdateNeighborsOfNoneDuplicatedNodes<TSegmenter>(borderPixelMap,
imageWidth,
imageHeight);
}
UpdateNeighborsOfNoneDuplicatedNodes<TSegmenter>(borderPixelMap, imageWidth, imageHeight);
}
}
std::cout << "\nAchieve segmentation process..." << std::endl;
std::cout << "Achieve segmentation process" ;
// Segmentation of the graph
segmenter.SetImageWidth(imageWidth);
......@@ -115,16 +108,10 @@ void MergeAllGraphsAndAchieveSegmentation(
lsrm::GraphOperations<TSegmenter>::PerfomAllIterationsWithLMBFAndConstThreshold(segmenter);
// Write output graph to the output graph directory
WriteGraph<TSegmenter>(segmenter.m_Graph, outputGraphDirectory, 0, 0);
// // Write output graph to the output graph directory
// WriteGraph<TSegmenter>(segmenter.m_Graph, tmpDir, 0, 0);
typedef unsigned long int LabelPixelType;
typedef otb::Image<LabelPixelType, 2> LabelImageType;
typedef otb::ImageFileWriter<LabelImageType> LabelImageWriterType;
auto labelWriter = LabelImageWriterType::New();
labelWriter->SetFileName("out/labelImage.tif");
labelWriter->SetInput(segmenter.GetLabeledClusteredOutput());
labelWriter->Update();
return segmenter.GetLabeledClusteredOutput();
}
......@@ -136,8 +123,6 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::Paramet
const std::string& tmpDir,
const unsigned int nbTilesX,
const unsigned int nbTilesY,
const unsigned int tileWidth,
const unsigned int tileHeight,
const unsigned int imageWidth,
const unsigned int imageHeight,
const unsigned int imageBands,
......@@ -155,7 +140,6 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::Paramet
{
for(unsigned int col = 0; col < nbTilesX; col++)
{
//std::cout << "*" << std::flush;
if (MyTurn(row*nbTilesX + col))
{
TSegmenter segmenter;
......@@ -170,9 +154,8 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::Paramet
// Add stability margin to the graph
{
std::cout << "\tAdd stability margin..." << std::endl;
AddStabilityMargin<TSegmenter>(segmenter.m_Graph, tiles[row*nbTilesX + col], tmpDir,
row, col, nbTilesX, nbTilesY,
tileWidth, tileHeight);
AddStabilityMargin<TSegmenter>(segmenter.m_Graph, tmpDir,
row, col, nbTilesX, nbTilesY);
std::unordered_map<long unsigned int,
......@@ -196,7 +179,6 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::Paramet
}
// Segmentation of the graph
segmenter.SetImageWidth(imageWidth);
segmenter.SetImageHeight(imageHeight);
......@@ -213,6 +195,7 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::Paramet
isFusion = true;
std::cout << "\tRemove unstable segments..." << std::endl;
// Remove unstable segments
RemoveUnstableSegments<TSegmenter>(segmenter.m_Graph, tiles[row*nbTilesX + col], imageWidth);
......@@ -546,14 +529,11 @@ void BuildBorderPixelMap(typename TSegmenter::GraphType& graph,
template<class TSegmenter>
void AddStabilityMargin(typename TSegmenter::GraphType& graph,
ProcessingTile& tile,
const std::string& tmpDir,
const unsigned int row,
const unsigned int col,
const unsigned int nbTilesX,
const unsigned int nbTilesY,
const unsigned int tileWidth,
const unsigned int tileHeight)
const unsigned int nbTilesY)
{
std::string nodesPath;
std::string edgesPath;
......@@ -708,10 +688,8 @@ long long unsigned int RunFirstPartialSegmentation(
const unsigned int niter,
const unsigned int niter2,
std::vector<ProcessingTile>& tiles,
const std::string& tileDir,
const unsigned int nbTilesX,
const unsigned int nbTilesY,
const unsigned int margin,
const unsigned int tileWidth,
const unsigned int tileHeight,
const unsigned int imageWidth,
......@@ -745,7 +723,7 @@ long long unsigned int RunFirstPartialSegmentation(
typename ImageType::Pointer imageTile = ReadImageRegion<TSegmenter>(inputPtr, currentTile.region);
// Segmenting image
std::cout << "Segmenting tile" << std::endl;
std::cout << "\tSegmenting";
TSegmenter segmenter;
segmenter.SetParam(params);
segmenter.SetThreshold(threshold);
......@@ -758,26 +736,25 @@ long long unsigned int RunFirstPartialSegmentation(
isFusion = true;
// Rescale the graph to be in the reference of the image
std::cout << "Rescale graph" << std::endl;
std::cout << "\tRescale graph" << std::endl;
RescaleGraph<TSegmenter>(segmenter.m_Graph,
tiles[row*nbTilesX + col],
row,
col,
margin,
tileWidth,
tileHeight,
imageWidth);
// Remove unstable segments
std::cout << "Removing unstable segments" << std::endl;
std::cout << "\tRemoving unstable segments" << std::endl;
RemoveUnstableSegments<TSegmenter>(segmenter.m_Graph, tiles[row*nbTilesX + col], imageWidth);
// Retrieve the amount of memory to store this graph
std::cout << "Get graph memory" << std::endl;
std::cout << "\tGet graph memory" << std::endl;
accumulatedMemory += GetGraphMemory<TSegmenter>(segmenter.m_Graph);
// Write graph to temporay directory (warning specific to Baatz & Schape !!!)
std::cout << "Write graph" << std::endl;
std::cout << "\tWrite graph" << std::endl;