Commit 4c60ed8c authored by Cédric Traizet's avatar Cédric Traizet
Browse files

ENH : modern c++ in for loops

parent a23fbf38
......@@ -128,20 +128,19 @@ private:
// Convert Map to Unordered map
auto labelPopulationMap = labelStatsFilter->GetLabelPopulationMap();
auto labelPopulationMap = labelStatsFilter->GetLabelPopulationMap();
std::unordered_map< unsigned int,double> labelPopulation;
for (population : labelPopulationMap)
for (auto population : labelPopulationMap)
{
labelPopulation[population.first]=population.second;
}
auto meanValueMap = labelStatsFilter->GetMeanValueMap();
auto meanValueMap = labelStatsFilter->GetMeanValueMap();
std::unordered_map< unsigned int, itk::VariableLengthVector<double> > meanValues;
for (mean : meanValueMap)
for (const auto & mean : meanValueMap)
{
meanValues[mean.first] = mean.second;
}
// Compute the LUT from the original label image to the merged output label image.
auto regionMergingFilter = LabelImageSmallRegionMergingFilterType::New();
regionMergingFilter->SetInput( labelIn );
......@@ -156,15 +155,14 @@ private:
// Relabelling using the LUT
auto changeLabelFilter = ChangeLabelImageFilterType::New();
changeLabelFilter->SetInput(labelIn);
auto LUT = regionMergingFilter->GetLUT();
for(unsigned int i = 0; i<LUT.size(); ++i)
{
if(i!=LUT[i])
{
changeLabelFilter->SetChange(i,LUT[i]);
}
}
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();
......
......@@ -81,7 +81,7 @@ public:
typedef std::unordered_map<InputLabelType , RealVectorPixelType > LabelStatisticType;
typedef std::unordered_map<InputLabelType , double> LabelPopulationType;
typedef std::unordered_map<InputLabelType , InputLabelType> LUTType;
typedef std::unordered_map<InputLabelType , InputLabelType> LUTType;
/** Set/Get size of segments to be merged */
itkGetMacro(Size , unsigned int);
......@@ -93,7 +93,7 @@ public:
m_LabelPopulation = labelPopulation;
// Initialize m_CorrespondingMap to the identity (i.e. m[label] = label)
for (label : m_LabelPopulation)
for (auto label : m_LabelPopulation)
{
m_LUT[label.first] = label.first;
}
......
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