Skip to content
Snippets Groups Projects
Commit 55b70141 authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Adding segmentation image index support

parent 0f0619e5
No related branches found
No related tags found
No related merge requests found
......@@ -78,10 +78,22 @@ public:
typedef std::map<EdgePairType,RCC8ValueType> EdgeMapType;
typedef std::vector<EdgeMapType> EdgeMapVectorType;
typedef std::vector<unsigned int> SegmentationRangesType;
/** Toogle optimisation flag */
itkBooleanMacro(Optimisation);
itkSetMacro(Optimisation,bool);
void SetSegmentationRanges(SegmentationRangesType ranges)
{
m_SegmentationRanges = ranges;
}
const SegmentationRangesType& GetSegmentationRanges() const
{
return m_SegmentationRanges;
}
/**
* Get the number of occurences of the given value
* \return The value.
......@@ -147,6 +159,8 @@ private:
unsigned int m_Accumulator[8];
EdgeMapVectorType m_EdgesPerThread;
/** This array stores the indices corresponding to each segmentation */
SegmentationRangesType m_SegmentationRanges;
};
} // End namespace otb
......
......@@ -201,6 +201,29 @@ PolygonListToRCC8GraphFilter<TPolygonList, TOutputGraph>
VertexPointerType vertex = VertexType::New();
// Set its properties
vertex->SetPath(it.Get());
// look for the appropriate segmentation index
unsigned int segIndex = 1;
while(segIndex < m_SegmentationRanges.size() && nbVertices<m_SegmentationRanges[segIndex-1] || nbVertices >= m_SegmentationRanges[segIndex])
{
segIndex++;
}
// while(candidateSegIndex+1< m_SegmentationRanges.size() && !found)
// {
// std::cout<<"Range: "<<m_SegmentationRanges[candidateSegIndex]<<", "<<m_SegmentationRanges[candidateSegIndex+1]<<std::endl;
// if(nbVertices>=m_SegmentationRanges[candidateSegIndex] && nbVertices<m_SegmentationRanges[candidateSegIndex+1])
// {
// segIndex = candidateSegIndex;
// found = true;
// std::cout<<"Found: "<<segIndex<<std::endl;
// }
// ++candidateSegIndex;
// }
vertex->SetSegmentationLevel(segIndex-1);
// Put it in the graph
graph->SetVertex(nbVertices,vertex);
otbMsgDevMacro(<<"Adding vertex: " <<nbVertices);
......
......@@ -52,10 +52,15 @@ int otbPolygonListToRCC8GraphFilter(int argc, char* argv[])
typedef otb::SimplifyPathListFilter<PolygonType> SimplifyPathFilterType;
PolygonListType::Pointer regions = PolygonListType::New();
RCC8GraphFilterType::SegmentationRangesType ranges;
// Reading input images
for(int cpt=1;cpt<=nbImages;++cpt)
{
ranges.push_back(regions->Size());
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[2+cpt]);
reader->Update();
......@@ -88,6 +93,7 @@ int otbPolygonListToRCC8GraphFilter(int argc, char* argv[])
RCC8GraphFilterType::Pointer filter = RCC8GraphFilterType::New();
filter->SetInput(simplifier->GetOutput());
filter->SetSegmentationRanges(ranges);
GraphWriterType::Pointer writer = GraphWriterType::New();
writer->SetInput(filter->GetOutput());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment