En raison d'une défaillance matérielle, les jobs d'intégration continue peuvent échouer sans raison évidente sur les runners partagés. Les disques incriminés devraient être changés en fin de semaine. Merci de votre compréhension.

Commit 07554cbf authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

FIX: fixed some 64-bit type related problems for large images under Windows

parent 3c558d44
......@@ -88,6 +88,7 @@ void Controller<TSegmenter>::RunSegmentation()
// Run first partial segmentation
boost::timer t; t.restart();
auto accumulatedMemory = RunFirstPartialSegmentation<TSegmenter>(
m_InputImage,
m_SpecificParameters,
......
......@@ -98,7 +98,8 @@ void BuildBorderPixelMap(typename TSegmenter::GraphType& graph,
const unsigned int nbTilesY,
std::unordered_map<std::size_t,
std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap,
const unsigned int imageWidth);
const unsigned int imageWidth,
bool merging = false);
template<class TSegmenter>
void InsertNodesFromTile(typename TSegmenter::GraphType& graph,
......
......@@ -69,7 +69,7 @@ MergeAllGraphsAndAchieveSegmentation(
std::cout << "\tBuildBorderPixelMap..." << std::endl;
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;
......@@ -93,7 +93,9 @@ MergeAllGraphsAndAchieveSegmentation(
segmenter.SetNumberOfIterations(numberOfIterations);
grm::GraphOperations<TSegmenter>::PerfomAllIterationsWithLMBFAndConstThreshold(segmenter);
// patch raf (sort using node id directly --> seems ok)
// Sort the nodes top-->down and left-->right
/*
std::sort(segmenter.m_Graph.m_Nodes.begin(), segmenter.m_Graph.m_Nodes.end(),
[imageWidth](const auto & a, const auto & b) -> bool
{
......@@ -101,8 +103,10 @@ MergeAllGraphsAndAchieveSegmentation(
lp::ContourOperations::GenerateBorderCells(borderPixelsA, a->m_Contour, a->m_Id, imageWidth);
lp::ContourOperations::GenerateBorderCells(borderPixelsB, b->m_Contour, b->m_Id, imageWidth);
unsigned int offA = 0;
unsigned int offB = 0;
// patch raf (were unsigned int)
std::size_t offA = 0;
std::size_t offB = 0;
// end patch
for (auto& pix: borderPixelsA)
if (pix>offA)
offA=pix;
......@@ -113,6 +117,13 @@ MergeAllGraphsAndAchieveSegmentation(
return offA > offB;
});
*/
std::sort(segmenter.m_Graph.m_Nodes.begin(), segmenter.m_Graph.m_Nodes.end(),
[](const auto & a, const auto & b) -> bool
{
return a->m_Id < b->m_Id;
});
// end patch
return segmenter.m_Graph;
}
......@@ -466,7 +477,8 @@ void BuildBorderPixelMap(typename TSegmenter::GraphType& graph,
const unsigned int nbTilesY,
std::unordered_map<std::size_t,
std::vector<typename TSegmenter::NodePointerType> >& borderPixelMap,
const unsigned int imageWidth)
const unsigned int imageWidth,
bool merging)
{
unsigned int rowPixel, colPixel;
unsigned int rowMin = (tile.rows[0] > 0) ? tile.rows[0] - 1 : tile.rows[0];
......@@ -483,6 +495,15 @@ void BuildBorderPixelMap(typename TSegmenter::GraphType& graph,
{
continue;
}
// patch raf (exclude nodes all outside tiles - on merging stage only)
else if(merging && (node->m_Bbox.m_UX > tile.columns[1] ||
node->m_Bbox.m_UY > tile.rows[1] ||
node->m_Bbox.m_UX + node->m_Bbox.m_W - 1 < tile.columns[0] ||
node->m_Bbox.m_UY + node->m_Bbox.m_H - 1 < tile.rows[0]))
{
continue;
}
// end patch
else
{
lp::CellLists borderPixels;
......@@ -618,9 +639,11 @@ long long unsigned int RunFirstPartialSegmentation(
std::cout << "--- Running fist partial segmentation...\nNumber of neighbor layers " << numberOfNeighborLayers << std::endl;
for(unsigned int row = 0; row < nbTilesY; ++row)
//for(unsigned int row = 0; row < nbTilesY; ++row)
for(unsigned int row = 24; row < 25; ++row)
{
for(unsigned int col = 0; col < nbTilesX; col++)
//for(unsigned int col = 0; col < nbTilesX; col++)
for(unsigned int col = 30; col < 31; col++)
{
#ifdef OTB_USE_MPI
if (MyTurn(row*nbTilesX + col))
......@@ -991,7 +1014,7 @@ void RescaleGraph(typename TSegmenter::GraphType& graph,
// Start pixel index of the node (in the image)
rowNodeImg = rowTile * tileHeight + rowNodeTile - tile.margin[0];
colNodeImg = colTile * tileWidth + colNodeTile - tile.margin[3];
node->m_Id = rowNodeImg * imageWidth + colNodeImg;
node->m_Id = (std::size_t)rowNodeImg * (std::size_t)imageWidth + (std::size_t)colNodeImg;
// Change also its bounding box
node->m_Bbox.m_UX = colTile * tileWidth + node->m_Bbox.m_UX - tile.margin[3];
......
......@@ -131,9 +131,17 @@ StreamingGraphToImageFilter<TGraph, TLabelImage>
for (auto& pix: borderPixels)
{
index[0] = pix % m_OutputSize[0];
index[1] = pix / m_OutputSize[0];
// patch raf (catch exception if position of pixel to set is not correct)
try {
index[0] = (unsigned int)(pix % (std::size_t)(m_OutputSize[0]));
index[1] = (unsigned int)(pix / (std::size_t)(m_OutputSize[0]));
labelImage->SetPixel(index, res.second);
} catch (std::exception e) {
std::cout << "Pixel ID: " << pix << std::endl;
std::cout << "Derived index: " << index[0] << "," << index[1] << std::endl;
std::cout << "Node position in list: " << res.second << std::endl;
}
// end patch
}
}
itkDebugMacro( << "Burning boundaries ok ");
......
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