From b280bac3cf0b2cfbfc486ec6ca3461fa653e2c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <cedric.traizet@c-s.fr> Date: Wed, 12 Sep 2018 16:57:26 +0200 Subject: [PATCH] ENH : added progress reporting --- .../app/otbSmallRegionsMerging.cxx | 2 ++ .../otbLabelImageSmallRegionMergingFilter.hxx | 19 ++++++------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Modules/Applications/AppSegmentation/app/otbSmallRegionsMerging.cxx b/Modules/Applications/AppSegmentation/app/otbSmallRegionsMerging.cxx index 009ffdbb5a..11cac23c4e 100644 --- a/Modules/Applications/AppSegmentation/app/otbSmallRegionsMerging.cxx +++ b/Modules/Applications/AppSegmentation/app/otbSmallRegionsMerging.cxx @@ -165,6 +165,8 @@ private: regionMergingFilter->SetLabelStatistic( meanValues ); regionMergingFilter->SetMinSize( minSize); + + AddProcess(regionMergingFilter, "Computing LUT ..."); regionMergingFilter->Update(); //Relabelling diff --git a/Modules/Segmentation/Conversion/include/otbLabelImageSmallRegionMergingFilter.hxx b/Modules/Segmentation/Conversion/include/otbLabelImageSmallRegionMergingFilter.hxx index 88df1b3179..b4397c2e97 100644 --- a/Modules/Segmentation/Conversion/include/otbLabelImageSmallRegionMergingFilter.hxx +++ b/Modules/Segmentation/Conversion/include/otbLabelImageSmallRegionMergingFilter.hxx @@ -77,7 +77,6 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage > InputLabelType closestNeighbour = label; for (auto neighbour : neighbours.second) { - auto statsLabel = m_LabelStatistic[ label ]; auto statsNeighbour = m_LabelStatistic[ neighbour ]; assert( statsLabel.Size() == statsNeighbour.Size() ); @@ -93,17 +92,9 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage > } } - auto curLabelLUT = label; - auto adjLabelLUT = closestNeighbour; - while(m_LUT[curLabelLUT] != curLabelLUT) - { - curLabelLUT = m_LUT[curLabelLUT]; - } - while(m_LUT[adjLabelLUT] != adjLabelLUT) - { - adjLabelLUT = m_LUT[adjLabelLUT]; - } - + auto curLabelLUT = FindCorrespondingLabel(label); + auto adjLabelLUT = FindCorrespondingLabel(closestNeighbour); + if(curLabelLUT < adjLabelLUT) { m_LUT[adjLabelLUT] = curLabelLUT; @@ -122,7 +113,7 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage > { can = m_LUT[can]; } - m_LUT[label] = can; + m_LUT[label] = can; } @@ -267,6 +258,7 @@ void LabelImageSmallRegionMergingFilter< TInputLabelImage > ::GenerateData() { + this->SetProgress(0.0); auto labelImage = this->GetInput(); m_SmallRegionMergingFilter->GetFilter()->SetInput( labelImage ); m_SmallRegionMergingFilter->GetStreamer()->SetAutomaticTiledStreaming(); @@ -274,6 +266,7 @@ LabelImageSmallRegionMergingFilter< TInputLabelImage > { m_SmallRegionMergingFilter->GetFilter()->SetSize( size) ; m_SmallRegionMergingFilter->Update(); + this->UpdateProgress(static_cast<double>(size+1)/m_MinSize); } } -- GitLab