Commit 9c4810ec authored by remi cresson's avatar remi cresson
Browse files

Merge branch 'msbuild_portability'

parents a8984a3b 555fe98c
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include "lsgrmFullLambdaScheduleSegmenter.h" #include "lsgrmFullLambdaScheduleSegmenter.h"
#include "lsgrmController.h" #include "lsgrmController.h"
// Graph to label image (streaming version)
#include "otbStreamingGraphToImageFilter.h"
#include "otbStreamingImageVirtualWriter.h"
// system tools // system tools
#include <itksys/SystemTools.hxx> #include <itksys/SystemTools.hxx>
...@@ -65,6 +69,7 @@ private: ...@@ -65,6 +69,7 @@ private:
void DoInit() void DoInit()
{ {
SetName("GenericRegionMerging"); SetName("GenericRegionMerging");
SetDescription("This application allows to use the Large Scale Generic Region Merging library " SetDescription("This application allows to use the Large Scale Generic Region Merging library "
"(LSGRM) and provides currently 3 homogeneity criteria: Euclidean Distance, " "(LSGRM) and provides currently 3 homogeneity criteria: Euclidean Distance, "
...@@ -107,6 +112,7 @@ private: ...@@ -107,6 +112,7 @@ private:
AddChoice("tiling.none", "No tiling layout"); AddChoice("tiling.none", "No tiling layout");
AddParameter(ParameterType_Int, "memory", "Restrict memory use (mb)"); AddParameter(ParameterType_Int, "memory", "Restrict memory use (mb)");
MandatoryOff("memory"); MandatoryOff("memory");
} }
...@@ -162,17 +168,20 @@ private: ...@@ -162,17 +168,20 @@ private:
* This function sets the generic parameters of a controller and runs the segmentation * This function sets the generic parameters of a controller and runs the segmentation
*/ */
template<class TSegmenter> template<class TSegmenter>
UInt32ImageType::Pointer SetGenericParametersAndRunSegmentation(const typename TSegmenter::ParamType params){ void
SetGenericParametersAndRunSegmentation(const typename TSegmenter::ParamType params){
// Instantiate the controller // Instantiate the controller
typedef typename lsgrm::Controller<TSegmenter> ControlerType; typedef typename lsgrm::Controller<TSegmenter> ControlerType;
typename ControlerType::Pointer controller = ControlerType::New(); typename ControlerType::Pointer controller = ControlerType::New();
using GraphType = typename ControlerType::GraphType;
// Set specific parameters // Set specific parameters
controller->SetSpecificParameters(params); controller->SetSpecificParameters(params);
// Set input image // Set input image
controller->SetInputImage(GetParameterFloatVectorImage("in")); ImageType::Pointer inputImage = GetParameterFloatVectorImage("in");
controller->SetInputImage(inputImage);
// Set threshold // Set threshold
float thres = GetParameterFloat("threshold"); float thres = GetParameterFloat("threshold");
...@@ -219,25 +228,37 @@ private: ...@@ -219,25 +228,37 @@ private:
// Run the segmentation // Run the segmentation
controller->RunSegmentation(); controller->RunSegmentation();
// Prepare the label image source
typedef lsgrm::StreamingGraphToImageFilter<GraphType, UInt32ImageType> LabelImageSourceType;
typename LabelImageSourceType::Pointer labelImageSource = LabelImageSourceType::New();
labelImageSource->SetGraph(controller->GetOutputGraph());
labelImageSource->SetOutputSize(inputImage->GetLargestPossibleRegion().GetSize());
labelImageSource->SetOutputOrigin(inputImage->GetOrigin());
labelImageSource->SetOutputSpacing(inputImage->GetSpacing());
labelImageSource->SetOutputProjectionRef(inputImage->GetProjectionRef());
labelImageSource->GenerateOutputInformation();
m_LabelImageSource = static_cast<itk::ImageSource<UInt32ImageType>*>(labelImageSource);
SetParameterOutputImage<UInt32ImageType>("out", m_LabelImageSource->GetOutput());
// TODO: find an intelligent value of RAM
if (dynamic_cast<OutputImageParameter*>(GetParameterByKey("out")))
{
OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(GetParameterByKey("out"));
paramDown->SetRAMValue(256);
}
// Get temporary files list // Get temporary files list
m_TemporaryFilesList = controller->GetTemporaryFilesList(); m_TemporaryFilesList = controller->GetTemporaryFilesList();
// Return the label image
return controller->GetLabeledClusteredOutput();
} }
void DoExecute() void DoExecute()
{ {
/*
TODO: the output directory in case the global graph cannot fit in memory (lsgrmController.txx)
*/
// Input image
ImageType::Pointer inputImage = GetParameterFloatVectorImage("in"); ImageType::Pointer inputImage = GetParameterFloatVectorImage("in");
// Output image
UInt32ImageType::Pointer labelImage = UInt32ImageType::New();
// Switch criterion // Switch criterion
int inputCriterion = GetParameterInt("criterion"); int inputCriterion = GetParameterInt("criterion");
if (inputCriterion == CRITERION_BAATZ) if (inputCriterion == CRITERION_BAATZ)
...@@ -245,29 +266,23 @@ private: ...@@ -245,29 +266,23 @@ private:
grm::BaatzParam params; grm::BaatzParam params;
params.m_SpectralWeight = GetParameterFloat("criterion.bs.cw"); params.m_SpectralWeight = GetParameterFloat("criterion.bs.cw");
params.m_ShapeWeight = GetParameterFloat("criterion.bs.sw"); params.m_ShapeWeight = GetParameterFloat("criterion.bs.sw");
labelImage = SetGenericParametersAndRunSegmentation<BaatzSegmenterType>(params); SetGenericParametersAndRunSegmentation<BaatzSegmenterType>(params);
} }
else if (inputCriterion == CRITERION_SPRING) else if (inputCriterion == CRITERION_SPRING)
{ {
grm::SpringParam params; grm::SpringParam params;
labelImage = SetGenericParametersAndRunSegmentation<SpringSegmenterType>(params); SetGenericParametersAndRunSegmentation<SpringSegmenterType>(params);
} }
else if (inputCriterion == CRITERION_FLS) else if (inputCriterion == CRITERION_FLS)
{ {
grm::FLSParam params; grm::FLSParam params;
labelImage = SetGenericParametersAndRunSegmentation<FLSSegmenterType>(params); SetGenericParametersAndRunSegmentation<FLSSegmenterType>(params);
} }
else else
{ {
otbAppLogFATAL("Unknow criterion!") otbAppLogFATAL("Unknow criterion!")
} }
// Set output image projection, origin and spacing for labelImage
labelImage->SetProjectionRef(inputImage->GetProjectionRef());
labelImage->SetOrigin(inputImage->GetOrigin());
labelImage->SetSpacing(inputImage->GetSpacing());
SetParameterOutputImage<UInt32ImageType>("out", labelImage);
} }
void AfterExecuteAndWriteOutputs() void AfterExecuteAndWriteOutputs()
...@@ -291,6 +306,7 @@ private: ...@@ -291,6 +306,7 @@ private:
private: private:
std::vector<std::string> m_TemporaryFilesList; std::vector<std::string> m_TemporaryFilesList;
itk::ImageSource<UInt32ImageType>::Pointer m_LabelImageSource;
}; // app class }; // app class
} // end of namespace wrapper } // end of namespace wrapper
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "itkObject.h" #include "itkObject.h"
#include "itkMacro.h" #include "itkMacro.h"
namespace lsgrm namespace lsgrm
{ {
template<class TSegmenter> template<class TSegmenter>
...@@ -30,6 +31,7 @@ public: ...@@ -30,6 +31,7 @@ public:
using ImageType = typename SegmenterType::ImageType; using ImageType = typename SegmenterType::ImageType;
using LabelImageType = typename SegmenterType::LabelImageType; using LabelImageType = typename SegmenterType::LabelImageType;
using SegmentationParameterType = typename SegmenterType::ParamType; using SegmentationParameterType = typename SegmenterType::ParamType;
using GraphType = typename SegmenterType::GraphType;
/* Default constructor and destructor. */ /* Default constructor and destructor. */
Controller(); Controller();
...@@ -48,7 +50,6 @@ public: ...@@ -48,7 +50,6 @@ public:
void SetTilingModeUser(){m_TilingMode = LSGRM_TILING_USER; Modified();}; void SetTilingModeUser(){m_TilingMode = LSGRM_TILING_USER; Modified();};
void SetTilingModeAuto(){m_TilingMode = LSGRM_TILING_AUTO; Modified();}; void SetTilingModeAuto(){m_TilingMode = LSGRM_TILING_AUTO; Modified();};
typename LabelImageType::Pointer GetLabeledClusteredOutput();
std::vector<std::string> GetTemporaryFilesList(); std::vector<std::string> GetTemporaryFilesList();
itkGetMacro(Margin, unsigned int); itkGetMacro(Margin, unsigned int);
...@@ -77,6 +78,8 @@ public: ...@@ -77,6 +78,8 @@ public:
itkGetMacro(TileHeight, unsigned int); itkGetMacro(TileHeight, unsigned int);
itkSetMacro(TileHeight, unsigned int); itkSetMacro(TileHeight, unsigned int);
itkGetMacro(OutputGraph, GraphType);
private: private:
/** Enum for tiling mode */ /** Enum for tiling mode */
...@@ -91,7 +94,7 @@ private: ...@@ -91,7 +94,7 @@ private:
void ComputeMaximumStabilityMargin(unsigned int width, unsigned int height, unsigned int &iter, unsigned int &margin); void ComputeMaximumStabilityMargin(unsigned int width, unsigned int height, unsigned int &iter, unsigned int &margin);
void CheckMemorySize(); void CheckMemorySize();
unsigned int GetNodeMemory(); unsigned int GetNodeMemory();
long unsigned int GetMaximumNumberOfNodesInMemory(); std::size_t GetMaximumNumberOfNodesInMemory();
/* Parameters given by the user */ /* Parameters given by the user */
std::string m_TemporaryFilesPrefix; // Path used to store intermediate files during the process. std::string m_TemporaryFilesPrefix; // Path used to store intermediate files during the process.
...@@ -116,7 +119,8 @@ private: ...@@ -116,7 +119,8 @@ private:
LSGRMTilingMode m_TilingMode; // tiling mode (none/user/auto) LSGRMTilingMode m_TilingMode; // tiling mode (none/user/auto)
unsigned int m_Margin; // stability margin related to m_NumberOfFirstIterations unsigned int m_Margin; // stability margin related to m_NumberOfFirstIterations
std::vector<ProcessingTile> m_Tiles; // list of tiles std::vector<ProcessingTile> m_Tiles; // list of tiles
typename LabelImageType::Pointer m_LabelImage; // output label image GraphType m_OutputGraph; // Output graph
}; };
} // end of namespace lsgrm } // end of namespace lsgrm
......
...@@ -18,6 +18,7 @@ Controller<TSegmenter>::Controller() ...@@ -18,6 +18,7 @@ Controller<TSegmenter>::Controller()
m_NbTilesY = 0; m_NbTilesY = 0;
m_Threshold = 75; m_Threshold = 75;
m_Memory = 0; m_Memory = 0;
} }
template<class TSegmenter> template<class TSegmenter>
...@@ -87,6 +88,7 @@ void Controller<TSegmenter>::RunSegmentation() ...@@ -87,6 +88,7 @@ void Controller<TSegmenter>::RunSegmentation()
// Run first partial segmentation // Run first partial segmentation
boost::timer t; t.restart(); boost::timer t; t.restart();
auto accumulatedMemory = RunFirstPartialSegmentation<TSegmenter>( auto accumulatedMemory = RunFirstPartialSegmentation<TSegmenter>(
m_InputImage, m_InputImage,
m_SpecificParameters, m_SpecificParameters,
...@@ -150,7 +152,7 @@ void Controller<TSegmenter>::RunSegmentation() ...@@ -150,7 +152,7 @@ void Controller<TSegmenter>::RunSegmentation()
if(accumulatedMemory <= m_Memory) if(accumulatedMemory <= m_Memory)
{ {
// Merge all the graphs // Merge all the graphs
m_LabelImage = MergeAllGraphsAndAchieveSegmentation<TSegmenter>( m_OutputGraph = MergeAllGraphsAndAchieveSegmentation<TSegmenter>(
m_SpecificParameters, m_SpecificParameters,
m_Threshold, m_Threshold,
m_Tiles, m_Tiles,
...@@ -195,14 +197,15 @@ void Controller<TSegmenter>::RunSegmentation() ...@@ -195,14 +197,15 @@ void Controller<TSegmenter>::RunSegmentation()
segmenter.SetInput(m_InputImage); segmenter.SetInput(m_InputImage);
segmenter.Update(); segmenter.Update();
// Get label image m_OutputGraph = segmenter.m_Graph;
m_LabelImage = segmenter.GetLabeledClusteredOutput();
} }
else else
{ {
itkExceptionMacro(<<"Unknow tiling mode!"); itkExceptionMacro(<<"Unknow tiling mode!");
} }
// TODO: [MPI] broadcast the graph to other nodes
} }
/* /*
...@@ -264,7 +267,7 @@ void Controller<TSegmenter>::CheckMemorySize() ...@@ -264,7 +267,7 @@ void Controller<TSegmenter>::CheckMemorySize()
* Compute the maximum number of nodes which can fit in the memory * Compute the maximum number of nodes which can fit in the memory
*/ */
template<class TSegmenter> template<class TSegmenter>
long unsigned int Controller<TSegmenter>::GetMaximumNumberOfNodesInMemory() std::size_t Controller<TSegmenter>::GetMaximumNumberOfNodesInMemory()
{ {
itkDebugMacro(<< "Computing maximum number of nodes in memory"); itkDebugMacro(<< "Computing maximum number of nodes in memory");
...@@ -433,16 +436,16 @@ void Controller<TSegmenter>::SetSpecificParameters(const SegmentationParameterTy ...@@ -433,16 +436,16 @@ void Controller<TSegmenter>::SetSpecificParameters(const SegmentationParameterTy
m_SpecificParameters = params; m_SpecificParameters = params;
} }
template<class TSegmenter> //template<class TSegmenter>
typename Controller<TSegmenter>::LabelImageType::Pointer //typename Controller<TSegmenter>::LabelImageType::Pointer
Controller<TSegmenter>::GetLabeledClusteredOutput() //Controller<TSegmenter>::GetLabeledClusteredOutput()
{ //{
#ifdef OTB_USE_MPI //#ifdef OTB_USE_MPI
// Get the label image from the master process (the one which achieves segmentation) // // Get the label image from the master process (the one which achieves segmentation)
BroadcastImage<typename TSegmenter::LabelImageType>(m_LabelImage); // BroadcastImage<typename TSegmenter::LabelImageType>(m_LabelImage);
#endif //#endif
return m_LabelImage; // return m_LabelImage;
} //}
template <class TSegmenter> template <class TSegmenter>
std::vector<std::string> Controller<TSegmenter>::GetTemporaryFilesList() std::vector<std::string> Controller<TSegmenter>::GetTemporaryFilesList()
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "grmGraphOperations.h" #include "grmGraphOperations.h"
#include "otbVectorImage.h" #include "otbVectorImage.h"
#include "otbMultiChannelExtractROI.h" #include "otbMultiChannelExtractROI.h"
#include "itkGrayscaleFillholeImageFilter.h"
namespace lsgrm namespace lsgrm
{ {
...@@ -32,7 +31,7 @@ typename TSegmenter::ImageType::Pointer ReadImageRegion( ...@@ -32,7 +31,7 @@ typename TSegmenter::ImageType::Pointer ReadImageRegion(
typename TSegmenter::ImageType::RegionType region); typename TSegmenter::ImageType::RegionType region);
template<class TSegmenter> template<class TSegmenter>
typename TSegmenter::LabelImageType::Pointer typename TSegmenter::GraphType
MergeAllGraphsAndAchieveSegmentation( MergeAllGraphsAndAchieveSegmentation(
const typename TSegmenter::ParamType& params, const typename TSegmenter::ParamType& params,
const float& threshold, const float& threshold,
...@@ -79,13 +78,13 @@ void RemoveUselessNodes(ProcessingTile& tile, ...@@ -79,13 +78,13 @@ void RemoveUselessNodes(ProcessingTile& tile,
template<class TSegmenter> template<class TSegmenter>
void UpdateNeighborsOfNoneDuplicatedNodes(std::unordered_map<long unsigned int, void UpdateNeighborsOfNoneDuplicatedNodes(std::unordered_map<std::size_t,
std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap, std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap,
const unsigned int imageWidth, const unsigned int imageWidth,
const unsigned int imageHeight); const unsigned int imageHeight);
template<class TSegmenter> template<class TSegmenter>
void RemoveDuplicatedNodes(std::unordered_map<long unsigned int, void RemoveDuplicatedNodes(std::unordered_map<std::size_t,
std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap, std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap,
typename TSegmenter::GraphType& graph, typename TSegmenter::GraphType& graph,
const unsigned int imageWidth); const unsigned int imageWidth);
...@@ -97,9 +96,10 @@ void BuildBorderPixelMap(typename TSegmenter::GraphType& graph, ...@@ -97,9 +96,10 @@ void BuildBorderPixelMap(typename TSegmenter::GraphType& graph,
const unsigned int colTile, const unsigned int colTile,
const unsigned int nbTilesX, const unsigned int nbTilesX,
const unsigned int nbTilesY, const unsigned int nbTilesY,
std::unordered_map<long unsigned int, std::unordered_map<std::size_t,
std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap, std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap,
const unsigned int imageWidth); const unsigned int imageWidth,
bool merging = false);
template<class TSegmenter> template<class TSegmenter>
void InsertNodesFromTile(typename TSegmenter::GraphType& graph, void InsertNodesFromTile(typename TSegmenter::GraphType& graph,
......
...@@ -25,7 +25,7 @@ typename TSegmenter::ImageType::Pointer ReadImageRegion( ...@@ -25,7 +25,7 @@ typename TSegmenter::ImageType::Pointer ReadImageRegion(
} }
template<class TSegmenter> template<class TSegmenter>
typename TSegmenter::LabelImageType::Pointer typename TSegmenter::GraphType
MergeAllGraphsAndAchieveSegmentation( MergeAllGraphsAndAchieveSegmentation(
const typename TSegmenter::ParamType& params, const typename TSegmenter::ParamType& params,
const float& threshold, const float& threshold,
...@@ -63,13 +63,13 @@ MergeAllGraphsAndAchieveSegmentation( ...@@ -63,13 +63,13 @@ MergeAllGraphsAndAchieveSegmentation(
{ {
std::cout << "Cleaning nodes of tile " << (row*nbTilesX + col) << " / " << (nbTilesX*nbTilesY) << std::endl; std::cout << "Cleaning nodes of tile " << (row*nbTilesX + col) << " / " << (nbTilesX*nbTilesY) << std::endl;
std::unordered_map<long unsigned int, std::unordered_map<std::size_t,
std::vector<typename TSegmenter::NodePointerType> > borderPixelMap; std::vector<typename TSegmenter::NodePointerType> > borderPixelMap;
std::cout << "\tBuildBorderPixelMap..." << std::endl; std::cout << "\tBuildBorderPixelMap..." << std::endl;
BuildBorderPixelMap<TSegmenter>(segmenter.m_Graph, tiles[row*nbTilesX + col], row, col, BuildBorderPixelMap<TSegmenter>(segmenter.m_Graph, tiles[row*nbTilesX + col], row, col,
nbTilesX, nbTilesY, borderPixelMap, imageWidth); nbTilesX, nbTilesY, borderPixelMap, imageWidth, true);
std::cout << "\tRemoveDuplicatedNodes..." << std::endl; std::cout << "\tRemoveDuplicatedNodes..." << std::endl;
...@@ -91,69 +91,42 @@ MergeAllGraphsAndAchieveSegmentation( ...@@ -91,69 +91,42 @@ MergeAllGraphsAndAchieveSegmentation(
segmenter.SetThreshold(threshold); segmenter.SetThreshold(threshold);
segmenter.SetDoFastSegmentation(false); // was true segmenter.SetDoFastSegmentation(false); // was true
segmenter.SetNumberOfIterations(numberOfIterations); segmenter.SetNumberOfIterations(numberOfIterations);
grm::GraphOperations<TSegmenter>::PerfomAllIterationsWithLMBFAndConstThreshold(segmenter); grm::GraphOperations<TSegmenter>::PerfomAllIterationsWithLMBFAndConstThreshold(segmenter);
// // Write output graph to the output graph directory // patch raf (sort using node id directly --> seems ok)
// WriteGraph<TSegmenter>(segmenter.m_Graph, tmpDir, 0, 0); // Sort the nodes top-->down and left-->right
/*
// Generate the label image std::sort(segmenter.m_Graph.m_Nodes.begin(), segmenter.m_Graph.m_Nodes.end(),
typename TSegmenter::LabelImageType::IndexType index; [imageWidth](const auto & a, const auto & b) -> bool
index.Fill(0); {
typename TSegmenter::LabelImageType::SizeType size; lp::CellLists borderPixelsA, borderPixelsB;
size[0] = imageWidth; lp::ContourOperations::GenerateBorderCells(borderPixelsA, a->m_Contour, a->m_Id, imageWidth);
size[1] = imageHeight; lp::ContourOperations::GenerateBorderCells(borderPixelsB, b->m_Contour, b->m_Id, imageWidth);
typename TSegmenter::LabelImageType::RegionType region(index, size);
const typename TSegmenter::LabelImageType::InternalPixelType noDataLabel = 0; // patch raf (were unsigned int)
typename TSegmenter::LabelImageType::Pointer labelImage = TSegmenter::LabelImageType::New(); std::size_t offA = 0;
labelImage->SetRegions(region); std::size_t offB = 0;
labelImage->Allocate(); // end patch
labelImage->FillBuffer(noDataLabel); for (auto& pix: borderPixelsA)
if (pix>offA)
using LabelImageIterator = itk::ImageRegionIterator<typename TSegmenter::LabelImageType>; offA=pix;
LabelImageIterator it(labelImage, labelImage->GetLargestPossibleRegion());
for (auto& pix: borderPixelsB)
// Start at 1 (value 0 can be used for invalid pixels) if (pix>offB)
unsigned int label = 1; offB=pix;
for(auto& node : segmenter.m_Graph.m_Nodes)
{ return offA > offB;
lp::CellLists borderPixels; });
lp::ContourOperations::GenerateBorderCells(borderPixels, node->m_Contour, node->m_Id, imageWidth); */
std::sort(segmenter.m_Graph.m_Nodes.begin(), segmenter.m_Graph.m_Nodes.end(),
for (auto& pix: borderPixels) [](const auto & a, const auto & b) -> bool
{ {
index[0] = pix % imageWidth; return a->m_Id < b->m_Id;
index[1] = pix / imageWidth; });
labelImage->SetPixel(index, label); // end patch
}
++label; return segmenter.m_Graph;
} }
// Re-order nodes labels (left->right to top->bottom)
vnl_vector<typename TSegmenter::LabelImageType::InternalPixelType> lut(label,noDataLabel);
label = 1;
for(it.GoToBegin();!it.IsAtEnd(); ++it)
{
unsigned int inputLabel = it.Get();
if (lut[ inputLabel ] == noDataLabel && inputLabel != noDataLabel)
{
lut[ inputLabel ] = label;
label++;
}
}
// Apply LUT
for(it.GoToBegin();!it.IsAtEnd(); ++it)
it.Set(lut[it.Get()]);
// Fill holes
typedef itk::GrayscaleFillholeImageFilter<typename TSegmenter::LabelImageType,
typename TSegmenter::LabelImageType> FillholeFilterType;
typename FillholeFilterType::Pointer fillFilter = FillholeFilterType::New();
fillFilter->SetInput(labelImage);
fillFilter->Update();
return fillFilter->GetOutput();}
template<class TSegmenter> template<class TSegmenter>
long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamType& params, long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamType& params,
...@@ -198,7 +171,7 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy ...@@ -198,7 +171,7 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy
row, col, nbTilesX, nbTilesY); row, col, nbTilesX, nbTilesY);
std::cout << "\tBuild border pixel map..." << std::endl; std::cout << "\tBuild border pixel map..." << std::endl;
std::unordered_map<long unsigned int, std::vector<typename TSegmenter::NodePointerType> > borderPixelMap; std::unordered_map<std::size_t, std::vector<typename TSegmenter::NodePointerType> > borderPixelMap;
BuildBorderPixelMap<TSegmenter>(segmenter.m_Graph, currentTile, row, col, BuildBorderPixelMap<TSegmenter>(segmenter.m_Graph, currentTile, row, col,
nbTilesX, nbTilesY, borderPixelMap, imageWidth); nbTilesX, nbTilesY, borderPixelMap, imageWidth);
...@@ -366,7 +339,7 @@ void RemoveUselessNodes(ProcessingTile& tile, ...@@ -366,7 +339,7 @@ void RemoveUselessNodes(ProcessingTile& tile,
} }
template<class TSegmenter> template<class TSegmenter>
void UpdateNeighborsOfNoneDuplicatedNodes(std::unordered_map<long unsigned int, void UpdateNeighborsOfNoneDuplicatedNodes(std::unordered_map<std::size_t,
std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap, std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap,
const unsigned int imageWidth, const unsigned int imageWidth,
const unsigned int imageHeight) const unsigned int imageHeight)
...@@ -376,7 +349,7 @@ void UpdateNeighborsOfNoneDuplicatedNodes(std::unordered_map<long unsigned int, ...@@ -376,7 +349,7 @@ void UpdateNeighborsOfNoneDuplicatedNodes(std::unordered_map<long unsigned int,
for(auto& pn : borderPixelMap) for(auto& pn : borderPixelMap)
{ {
long int neighborhood[4]; NeighIDType neighborhood[4];
grm::FOURNeighborhood(neighborhood, pn.first, imageWidth, imageHeight); grm::FOURNeighborhood(neighborhood, pn.first, imageWidth, imageHeight);
for(short j = 0; j < 4; ++j) for(short j = 0; j < 4; ++j)
...@@ -404,7 +377,7 @@ void UpdateNeighborsOfNoneDuplicatedNodes(std::unordered_map<long unsigned int, ...@@ -404,7 +377,7 @@ void UpdateNeighborsOfNoneDuplicatedNodes(std::unordered_map<long unsigned int,
{ {
if(borderPixelMap.find(pix) != borderPixelMap.end()) if(borderPixelMap.find(pix) != borderPixelMap.end())
{ {
long int pixNeighborhood[4];