#ifndef __LSGRM_GRAPH_OPERATIONS_H #define __LSGRM_GRAPH_OPERATIONS_H #include "lsgrmHeader.h" #include "grmGraphOperations.h" #include "otbVectorImage.h" #include "otbMultiChannelExtractROI.h" namespace lsgrm { 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) long int margin[4]; // Is there a margin at top, left, bottom or right otb::VectorImage::RegionType region; // The image region // Temporary files std::string nodeFileName; std::string edgeFileName; std::string nodeMarginFileName; std::string edgeMarginFileName; }; // Read an image region template typename TSegmenter::ImageType::Pointer ReadImageRegion( typename TSegmenter::ImageType * inputPtr, typename TSegmenter::ImageType::RegionType region); template typename TSegmenter::GraphType MergeAllGraphsAndAchieveSegmentation( const typename TSegmenter::ParamType& params, const float& threshold, std::vector& tiles, const unsigned int nbTilesX, const unsigned int nbTilesY, const unsigned int imageWidth, const unsigned int imageHeight, const unsigned int imageBands, unsigned int numberOfIterations); template long long unsigned int RunFirstPartialSegmentation( typename TSegmenter::ImageType * inputPtr, const typename TSegmenter::ParamType& params, const float& threshold, const unsigned int niter, const unsigned int niter2, std::vector& tiles, const unsigned int nbTilesX, const unsigned int nbTilesY, const unsigned int tileWidth, const unsigned int tileHeight, bool& isFusion); template long long unsigned int RunPartialSegmentation( const typename TSegmenter::ParamType& params, const float& threshold, const unsigned int niter, std::vector& tiles, const unsigned int nbTilesX, const unsigned int nbTilesY, const unsigned int imageWidth, const unsigned int imageHeight, const unsigned int imageBands, bool& isFusion); template void RemoveUselessNodes(ProcessingTile& tile, typename TSegmenter::GraphType& graph, const unsigned int imageWidth, const unsigned int numberOfLayers); template void UpdateNeighborsOfNoneDuplicatedNodes(std::unordered_map >& borderPixelMap, const unsigned int imageWidth, const unsigned int imageHeight); template void RemoveDuplicatedNodes(std::unordered_map >& borderPixelMap, typename TSegmenter::GraphType& graph, const unsigned int imageWidth); template void BuildBorderPixelMap(typename TSegmenter::GraphType& graph, ProcessingTile& tile, const unsigned int rowTile, const unsigned int colTile, const unsigned int nbTilesX, const unsigned int nbTilesY, std::unordered_map >& borderPixelMap, const unsigned int imageWidth); template void InsertNodesFromTile(typename TSegmenter::GraphType& graph, ProcessingTile& tile, bool margin = true); template void AddStabilityMargin(typename TSegmenter::GraphType& graph, std::vector& tiles, const unsigned int row, const unsigned int col, const unsigned int nbTilesX, const unsigned int nbTilesY); template void WriteStabilityMargin(std::unordered_map< typename TSegmenter::NodePointerType, unsigned int>& stabilityMargin, const std::string& nodesPath, const std::string& edgesPath); template void ExtractStabilityMargin(std::unordered_map& nodeMap, const unsigned int pmax); template void ExploreDFS(typename TSegmenter::NodePointerType s, const unsigned int p, std::unordered_map& Cb, const unsigned int pmax); template void DetectBorderNodes(typename TSegmenter::GraphType& graph, ProcessingTile& tile, std::unordered_map& borderNodeMaps, const unsigned int imageWidth, const unsigned int imageHeight); template void ReadGraph(TSegmenter& segmenter, const std::string& nodesPath, const std::string& edgesPath); template void ReadGraph(typename TSegmenter::GraphType& graph, const std::string& nodesPath, const std::string& edgesPath); template void WriteGraph(typename TSegmenter::GraphType& graph, const std::string& nodesFile, const std::string& edgesFile); template void RemoveUnstableSegments(typename TSegmenter::GraphType& graph, ProcessingTile& tile, const unsigned int imageWidth); template void RemoveEdgeToUnstableNode(typename TSegmenter::NodePointerType nodePtr); template void RescaleGraph(typename TSegmenter::GraphType& graph, ProcessingTile& tile, const unsigned int rowTile, const unsigned int colTile, const unsigned int tileWidth, const unsigned int tileHeight, const unsigned int imageWidth); } #include "lsgrmGraphOperations.txx" #endif