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 3d7065ae authored by remicres's avatar remicres
Browse files

FIX: FIXED THE FUG (issue was graph-->image process on LSGRM final graph)

parent d1d34cb0
......@@ -5,6 +5,7 @@
#include "grmGraphOperations.h"
#include "otbVectorImage.h"
#include "otbMultiChannelExtractROI.h"
#include "itkGrayscaleFillholeImageFilter.h"
namespace lsgrm
{
......
......@@ -94,27 +94,45 @@ MergeAllGraphsAndAchieveSegmentation(
// // Write output graph to the output graph directory
// WriteGraph<TSegmenter>(segmenter.m_Graph, tmpDir, 0, 0);
// Convert graph to label image
typename TSegmenter::LabelImageType::Pointer labelImage = segmenter.GetLabeledClusteredOutput();
// Generate the label image
typename TSegmenter::LabelImageType::IndexType index;
index.Fill(0);
typename TSegmenter::LabelImageType::SizeType size;
size[0] = imageWidth;
size[1] = imageHeight;
typename TSegmenter::LabelImageType::RegionType region(index, size);
const typename TSegmenter::LabelImageType::InternalPixelType noDataLabel = 0;
typename TSegmenter::LabelImageType::Pointer labelImage = TSegmenter::LabelImageType::New();
labelImage->SetRegions(region);
labelImage->Allocate();
labelImage->FillBuffer(noDataLabel);
// Re-order nodes labels (left->right to top->bottom)
using LabelImageIterator = itk::ImageRegionIterator<typename TSegmenter::LabelImageType>;
LabelImageIterator it(labelImage, labelImage->GetLargestPossibleRegion());
const typename TSegmenter::LabelImageType::InternalPixelType noDataLabel = 0;
typename TSegmenter::LabelImageType::InternalPixelType label;
// Get the maximum label value
for(it.GoToBegin();!it.IsAtEnd(); ++it)
if (it.Get() > label)
label = it.Get();
// Start at 1 (value 0 can be used for invalid pixels)
unsigned int label = 1;
for(auto& node : segmenter.m_Graph.m_Nodes)
{
lp::CellLists borderPixels;
lp::ContourOperations::GenerateBorderCells(borderPixels, node->m_Contour, node->m_Id, imageWidth);
for (auto& pix: borderPixels)
{
index[0] = pix % imageWidth;
index[1] = pix / imageWidth;
labelImage->SetPixel(index, label);
}
++label;
}
// Compute LUT
// 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)
if (lut[ inputLabel ] == noDataLabel && inputLabel != noDataLabel)
{
lut[ inputLabel ] = label;
label++;
......@@ -125,8 +143,14 @@ MergeAllGraphsAndAchieveSegmentation(
for(it.GoToBegin();!it.IsAtEnd(); ++it)
it.Set(lut[it.Get()]);
return labelImage;
}
// 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>
long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamType& params,
......
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