Commit 83f981c5 authored by Jialin Wang's avatar Jialin Wang
Browse files

ENH: Create a "custom" option for feature extraction

parent 95a5b5e1
Pipeline #11510 failed with stages
......@@ -169,25 +169,50 @@ private:
SetParameterDescription("texture.simple",
"This group of parameters defines "
"the 8 local Haralick texture feature output image. The image channels are: "
"Energy, Entropy, Correlation, Inverse Difference Moment, Inertia, Cluster "
"Shade, Cluster Prominence and Haralick Correlation");
"(0)Energy, (1)Entropy, (2)Correlation, (3)Inverse Difference Moment, (4)Inertia, (5)Cluster "
"Shade, (6)Cluster Prominence and (7)Haralick Correlation");
AddChoice("texture.advanced", "Advanced Texture Features");
SetParameterDescription("texture.advanced",
"This group of parameters defines "
"the 10 advanced texture feature output image. The image channels are: Mean, "
"Variance, Dissimilarity, Sum Average, Sum Variance, Sum Entropy, Difference "
"of Entropies, Difference of Variances, IC1 and IC2");
"the 10 advanced texture feature output image. The image channels are: (0)Mean, "
"(1)Variance, (2)Dissimilarity, (3)Sum Average, (4)Sum Variance, (5)Sum Entropy, (6)Difference "
"of Entropies, (7)Difference of Variances, (8)IC1 and (9)IC2");
AddChoice("texture.higher", "Higher Order Texture Features");
SetParameterDescription("texture.higher",
"This group of parameters defines the "
"11 higher order texture feature output image. The image channels are: "
"Short Run Emphasis, Long Run Emphasis, Grey-Level Nonuniformity, "
"Run Length Nonuniformity, Run Percentage, Low Grey-Level Run Emphasis, "
"High Grey-Level Run Emphasis, Short Run Low Grey-Level Emphasis, "
"Short Run High Grey-Level Emphasis, Long Run Low Grey-Level Emphasis and "
"Long Run High Grey-Level Emphasis");
"(0)Short Run Emphasis, (1)Long Run Emphasis, (2)Grey-Level Nonuniformity, "
"(3)Run Length Nonuniformity, (4)Run Percentage, (5)Low Grey-Level Run Emphasis, "
"(6)High Grey-Level Run Emphasis, (7)Short Run Low Grey-Level Emphasis, "
"(8)Short Run High Grey-Level Emphasis, (9)Long Run Low Grey-Level Emphasis and "
"(10)Long Run High Grey-Level Emphasis");
AddChoice("texture.custom", "Custom Texture Features");
SetParameterDescription("texture.custom",
"This group of parameters defines the "
"3 mini texture feature output image. The image channels are ommited.");
AddParameter(ParameterType_Group, "features", "Texture feature parameters");
SetParameterDescription("features",
"This group of feature parameters allows one to define "
"custom texture selection.");
AddParameter(ParameterType_StringList, "features.simple", "Selected simple features");
SetParameterDescription("features.simple",
"Selected simple features list for custom textures. "
"Refer to 'texture.simple' for details.");
MandatoryOff("features.simple");
AddParameter(ParameterType_StringList, "features.advanced", "Selected advanced features");
SetParameterDescription("features.advanced",
"Selected advanced features list for custom textures. "
"Refer to 'texture.advanced' for details.");
MandatoryOff("features.advanced");
AddParameter(ParameterType_StringList, "features.higher", "Selected higher features");
SetParameterDescription("features.higher",
"Selected higher features list for custom textures. "
"Refer to 'texture.higher' for details.");
MandatoryOff("features.higher");
AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription("out", "Output image containing the selected texture features.");
......@@ -271,6 +296,9 @@ private:
m_HigImageList = ImageListType::New();
m_HigConcatener = ImageListToVectorImageFilterType::New();
m_CusImageList = ImageListType::New();
m_CusConcatener = ImageListToVectorImageFilterType::New();
if (texType == "simple")
{
m_HarTexFilter->SetInput(const_cast<FloatImageType*>(m_ClampFilter->GetOutput()));
......@@ -341,6 +369,176 @@ private:
m_HigConcatener->SetInput(m_HigImageList);
SetParameterOutputImage("out", m_HigConcatener->GetOutput());
}
if (texType == "custom")
{
m_HarTexFilter->SetInput(const_cast<FloatImageType*>(m_ClampFilter->GetOutput()));
m_HarTexFilter->SetRadius(radius);
m_HarTexFilter->SetOffset(offset);
m_HarTexFilter->SetInputImageMinimum(GetParameterFloat("parameters.min"));
m_HarTexFilter->SetInputImageMaximum(GetParameterFloat("parameters.max"));
m_HarTexFilter->SetNumberOfBinsPerAxis(GetParameterInt("parameters.nbbin"));
m_HarTexFilter->SetSubsampleFactor(stepping);
m_HarTexFilter->SetSubsampleOffset(stepOffset);
m_HarTexFilter->UpdateOutputInformation();
m_AdvTexFilter->SetInput(const_cast<FloatImageType*>(m_ClampFilter->GetOutput()));
m_AdvTexFilter->SetRadius(radius);
m_AdvTexFilter->SetOffset(offset);
m_AdvTexFilter->SetInputImageMinimum(GetParameterFloat("parameters.min"));
m_AdvTexFilter->SetInputImageMaximum(GetParameterFloat("parameters.max"));
m_AdvTexFilter->SetNumberOfBinsPerAxis(GetParameterInt("parameters.nbbin"));
m_AdvTexFilter->SetSubsampleFactor(stepping);
m_AdvTexFilter->SetSubsampleOffset(stepOffset);
m_HigTexFilter->SetInput(const_cast<FloatImageType*>(m_ClampFilter->GetOutput()));
m_HigTexFilter->SetRadius(radius);
m_HigTexFilter->SetOffset(offset);
m_HigTexFilter->SetInputImageMinimum(GetParameterFloat("parameters.min"));
m_HigTexFilter->SetInputImageMaximum(GetParameterFloat("parameters.max"));
m_HigTexFilter->SetNumberOfBinsPerAxis(GetParameterInt("parameters.nbbin"));
m_HigTexFilter->SetSubsampleFactor(stepping);
m_HigTexFilter->SetSubsampleOffset(stepOffset);
enum HarFeatures {
Energy, Entropy, Correlation, InverseDifferenceMoment,
Inertia, ClusterShade, ClusterProminence, HaralickCorrelation
};
enum AdvFeatures {
Mean, Variance, Dissimilarity, SumAverage,
SumVariance, DifferenceEntropy, DifferenceVariace, IC1,
IC2
};
enum HigFeature {
ShortRunEmphasis, LongRunEmphasis, GreyLevelNonuniformity, RunLengthNonuniformity,
LowGreyLevelRunEmphasis, HighGreyLevelRunEmphasis, ShortRunLowGreyLevelEmphasis, ShortRunHighGreyLevelEmphasis,
LongRunLowGreyLevelEmphasis, LongRunHighGreyLevelEmphasis
};
std::vector<unsigned int> HarParams, AdvParams, HigParams;
std::vector<std::string> HarParamsStr = GetParameterStringList("features.simple");
std::vector<std::string> AdvParamsStr = GetParameterStringList("features.advanced");
std::vector<std::string> HigParamsStr = GetParameterStringList("features.higher");
for (unsigned int i = 0; i < HarParamsStr.size(); i++)
{
unsigned int paramInt = boost::lexical_cast<unsigned int>(HarParamsStr[i]);
HarParams.push_back(paramInt);
}
for (unsigned int i = 0; i < AdvParamsStr.size(); i++)
{
unsigned int paramInt = boost::lexical_cast<unsigned int>(AdvParamsStr[i]);
AdvParams.push_back(paramInt);
}
for (unsigned int i = 0; i < HigParamsStr.size(); i++)
{
unsigned int paramInt = boost::lexical_cast<unsigned int>(HigParamsStr[i]);
HigParams.push_back(paramInt);
}
for (unsigned int i = 0; i < HarParams.size(); i++)
{
switch (HarParams[i])
{
case Energy:
m_CusImageList->PushBack(m_HarTexFilter->GetEnergyOutput());
break;
case Entropy:
m_CusImageList->PushBack(m_HarTexFilter->GetEntropyOutput());
break;
case Correlation:
m_CusImageList->PushBack(m_HarTexFilter->GetCorrelationOutput());
break;
case InverseDifferenceMoment:
m_CusImageList->PushBack(m_HarTexFilter->GetInverseDifferenceMomentOutput());
break;
case Inertia:
m_CusImageList->PushBack(m_HarTexFilter->GetInertiaOutput());
break;
case ClusterShade:
m_CusImageList->PushBack(m_HarTexFilter->GetClusterShadeOutput());
break;
case ClusterProminence:
m_CusImageList->PushBack(m_HarTexFilter->GetClusterProminenceOutput());
break;
case HaralickCorrelation:
m_CusImageList->PushBack(m_HarTexFilter->GetHaralickCorrelationOutput());
break;
default:
break;
}
}
for (unsigned int i = 0; i < AdvParams.size(); i++)
{
switch (AdvParams[i])
{
case Mean:
m_CusImageList->PushBack(m_AdvTexFilter->GetMeanOutput());
break;
case Variance:
m_CusImageList->PushBack(m_AdvTexFilter->GetVarianceOutput());
break;
case Dissimilarity:
m_CusImageList->PushBack(m_AdvTexFilter->GetDissimilarityOutput());
break;
case SumAverage:
m_CusImageList->PushBack(m_AdvTexFilter->GetSumAverageOutput());
break;
case SumVariance:
m_CusImageList->PushBack(m_AdvTexFilter->GetSumVarianceOutput());
break;
case DifferenceEntropy:
m_CusImageList->PushBack(m_AdvTexFilter->GetDifferenceEntropyOutput());
break;
case DifferenceVariace:
m_CusImageList->PushBack(m_AdvTexFilter->GetDifferenceVarianceOutput());
break;
case IC1:
m_CusImageList->PushBack(m_AdvTexFilter->GetIC1Output());
break;
case IC2:
m_CusImageList->PushBack(m_AdvTexFilter->GetIC2Output());
break;
default:
break;
}
}
for (unsigned int i = 0; i < HigParams.size(); i++)
{
switch (HigParams[i])
{
case ShortRunEmphasis:
m_CusImageList->PushBack(m_HigTexFilter->GetShortRunEmphasisOutput());
break;
case LongRunEmphasis:
m_CusImageList->PushBack(m_HigTexFilter->GetLongRunEmphasisOutput());
break;
case GreyLevelNonuniformity:
m_CusImageList->PushBack(m_HigTexFilter->GetGreyLevelNonuniformityOutput());
break;
case RunLengthNonuniformity:
m_CusImageList->PushBack(m_HigTexFilter->GetRunLengthNonuniformityOutput());
break;
case LowGreyLevelRunEmphasis:
m_CusImageList->PushBack(m_HigTexFilter->GetLowGreyLevelRunEmphasisOutput());
break;
case HighGreyLevelRunEmphasis:
m_CusImageList->PushBack(m_HigTexFilter->GetHighGreyLevelRunEmphasisOutput());
break;
case ShortRunLowGreyLevelEmphasis:
m_CusImageList->PushBack(m_HigTexFilter->GetShortRunLowGreyLevelEmphasisOutput());
break;
case ShortRunHighGreyLevelEmphasis:
m_CusImageList->PushBack(m_HigTexFilter->GetShortRunHighGreyLevelEmphasisOutput());
break;
case LongRunLowGreyLevelEmphasis:
m_CusImageList->PushBack(m_HigTexFilter->GetLongRunLowGreyLevelEmphasisOutput());
break;
case LongRunHighGreyLevelEmphasis:
m_CusImageList->PushBack(m_HigTexFilter->GetLongRunHighGreyLevelEmphasisOutput());
break;
default:
break;
}
}
m_CusConcatener->SetInput(m_CusImageList);
SetParameterOutputImage("out", m_CusConcatener->GetOutput());
}
}
ExtractorFilterType::Pointer m_ExtractorFilter;
ClampFilterType::Pointer m_ClampFilter;
......@@ -354,6 +552,8 @@ private:
HigTexturesFilterType::Pointer m_HigTexFilter;
ImageListType::Pointer m_HigImageList;
ImageListToVectorImageFilterType::Pointer m_HigConcatener;
ImageListType::Pointer m_CusImageList;
ImageListToVectorImageFilterType::Pointer m_CusConcatener;
};
}
}
......
Supports Markdown
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