Skip to content
Snippets Groups Projects
Commit 6ccc60ae authored by Cédric Traizet's avatar Cédric Traizet
Browse files

ENH : code modernization

parent 4c60ed8c
No related branches found
No related tags found
No related merge requests found
......@@ -157,12 +157,14 @@ private:
changeLabelFilter->SetInput(labelIn);
const auto & LUT = regionMergingFilter->GetLUT();
for (auto label : LUT)
{
if (label.first != label.second)
{
changeLabelFilter->SetChange(label.first, label.second);
}
}
SetParameterOutputImage("out", changeLabelFilter->GetOutput());
RegisterPipeline();
clock_t toc = clock();
......
......@@ -123,12 +123,12 @@ public:
return m_LUT;
}
virtual void Reset(void);
virtual void Synthetize(void);
virtual void Reset(void) override;
virtual void Synthetize(void) override;
protected:
/** The input requested region should be padded by a radius of 1 to use the neigbourhood iterator*/
void GenerateInputRequestedRegion();
void GenerateInputRequestedRegion() override;
/** Threaded Generate Data : find the neighbours of each segments of size m_Size for each tile and store them in
* an accumulator */
......@@ -248,7 +248,7 @@ protected:
~LabelImageSmallRegionMergingFilter() override = default;
/** Generate Data method (Update LabelImageSmallRegionMergingFilterType recursively) */
void GenerateData();
void GenerateData() override;
private:
LabelImageSmallRegionMergingFilter(const Self &) = delete;
......
......@@ -99,27 +99,20 @@ PersistentLabelImageSmallRegionMergingFilter< TInputLabelImage >
}
// Update the LUT
for(InputLabelType label = 0; label < m_LUT.size(); ++label)
for (auto & label : m_LUT)
{
InputLabelType can = label;
while(m_LUT[can] != can)
{
can = m_LUT[can];
}
m_LUT[label] = can;
label.second = FindCorrespondingLabel( label.first );
}
// Update Statistics
for(InputLabelType label = 0; label < m_LUT.size(); ++label)
// Update statistics
for (auto label : m_LUT)
{
InputLabelType correspondingLabel = m_LUT[label];
if((m_LabelPopulation[label]!=0) && (correspondingLabel != label))
if((m_LabelPopulation[label.first]!=0) && (label.second != label.first))
{
m_LabelStatistic[ correspondingLabel ] = (m_LabelStatistic[correspondingLabel]*m_LabelPopulation[correspondingLabel] +
m_LabelStatistic[label]*m_LabelPopulation[label] ) / (m_LabelPopulation[label]+m_LabelPopulation[correspondingLabel]);
m_LabelPopulation[ correspondingLabel ] += m_LabelPopulation[ label ] ;
m_LabelPopulation[ label ] = 0;
m_LabelStatistic[ label.second ] = (m_LabelStatistic[label.second]*m_LabelPopulation[label.second] +
m_LabelStatistic[label.first]*m_LabelPopulation[label.first] ) / (m_LabelPopulation[label.first]+m_LabelPopulation[label.second]);
m_LabelPopulation[ label.second ] += m_LabelPopulation[ label.first ] ;
m_LabelPopulation[ label.first ] = 0;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment