Commit 202a195f authored by Charles Peyrega's avatar Charles Peyrega

ENH: Majority Voting: multiple majority labels are set either to...

ENH: Majority Voting: multiple majority labels are set either to UnDefinedValue or to their original value (by default)
parent ffeea88a
......@@ -20,6 +20,7 @@
#include "otbWrapperApplicationFactory.h"
// Majority Voting filter includes
#include "itkBinaryBallStructuringElement.h"
#include "otbNeighborhoodMajorityVotingImageFilter.h"
......@@ -43,12 +44,22 @@ namespace otb
itkTypeMacro(ClassificationRegularisationMajorityVoting, otb::Application);
typedef UInt8ImageType LabelImageType;
typedef unsigned char InputLabelPixelType;
typedef UInt8ImageType InputLabelImageType;
typedef UInt8ImageType OutputLabelImageType;
typedef otb::NeighborhoodMajorityVotingImageFilter<LabelImageType> NeighborhoodMajorityVotingFilterType;
typedef NeighborhoodMajorityVotingFilterType::RadiusType RadiusType;
//SE TYPE
typedef itk::Neighborhood<InputLabelPixelType, 2> StructuringType;
typedef StructuringType::RadiusType RadiusType;
//BINARY BALL SE TYPE
typedef itk::BinaryBallStructuringElement<InputLabelPixelType, 2> BallStructuringType;
//NEIGHBORHOOD MAJORITY FILTER TYPE
typedef otb::NeighborhoodMajorityVotingImageFilter<InputLabelImageType, OutputLabelImageType, StructuringType> NeighborhoodMajorityVotingFilterType;
......@@ -57,10 +68,10 @@ namespace otb
{
SetName("ClassificationRegularisationMajorityVoting");
SetDescription("Filters an input labeled image using Majority Voting in a Ball shaped specified neighbordhood.");
SetDescription("Filters the input labeled image using Majority Voting in a Ball shaped neighbordhood.");
SetDocName("Regularisation of a labeled image by Majority Voting");
SetDocLongDescription("This application filters an input labeled image using Majority Voting in a specified neighbordhood. Majority Voting takes the more representative value of all the pixels identified by the Ball shaped structuring element and then sets the center pixel to this label value.\n-NoDataValue is the value of the not classified pixels of the Input image.\n-UnDefinedValue is the value of the output label for input pixels with NoDataValue AND for pixels for which the Majority Voting does not return a unique label.");
SetDocLimitations("Both input and output images must be unsigned char (8 bits) labeled images.");
SetDocLongDescription("This application filters the input labeled image using Majority Voting in a Ball shaped neighbordhood. Majority Voting takes the more representative value of all the pixels identified by the Ball shaped structuring element and then sets the center pixel to this majority label value.\n-'NoDataValue' is the label of the NOT classified pixels of the input image. These input pixels keep their 'NoDataValue' label in the output image.\n-If the 'UnDefinedValue if multiple majority labels' option is chosen, then 'UnDefinedValue' is the label of the output pixels, for which there are NOT unique majority labels. Otherwise, these output label pixels keep their Original values in the input image.");
SetDocLimitations("The input image must be a single band labeled image. Both radii along Ox and Oy must have a minimum value equal to 1.");
SetDocAuthors("OTB-Team");
SetDocSeeAlso("Documentation of the ClassificationRegularisationMajorityVoting application.");
......@@ -70,7 +81,7 @@ namespace otb
/** GROUP IO CLASSIFICATION */
AddParameter(ParameterType_Group,"io","Input and output images for Majority Voting regularization");
AddParameter(ParameterType_Group,"io","Input and output images");
SetParameterDescription("io","This group of parameters allows to set input and output images for Majority Voting regularisation.");
AddParameter(ParameterType_InputImage, "io.in", "Input Image to REGULARIZE");
......@@ -81,19 +92,21 @@ namespace otb
SetParameterOutputImagePixelType( "io.out", ImagePixelType_uint8);
AddParameter(ParameterType_Group,"ip","Input parameters for Majority Voting regularization");
AddParameter(ParameterType_Group,"ip","Input parameters");
SetParameterDescription("ip","This group of parameters allows to set input parameters for Majority Voting regularisation.");
AddParameter(ParameterType_Int, "ip.radiusx", "Size of the neighborhood along Ox");
AddParameter(ParameterType_Int, "ip.radiusx", "Radius along Ox");
SetDefaultParameterInt("ip.radiusx", 1.0);
AddParameter(ParameterType_Int, "ip.radiusy", "Size of the neighborhood along Oy");
AddParameter(ParameterType_Int, "ip.radiusy", "Radius along Oy");
SetDefaultParameterInt("ip.radiusy", 1.0);
AddParameter(ParameterType_Empty, "ip.suvbool", "UnDefinedValue if multiple majority labels");
AddParameter(ParameterType_Int, "ip.nodatavalue", "Value of the NoDataValue input label");
SetDefaultParameterInt("ip.nodatavalue", 0.0);
AddParameter(ParameterType_Int, "ip.undefinedvalue", "Value of the UndeFinedValue output label");
AddParameter(ParameterType_Int, "ip.undefinedvalue", "Value of the UnDefinedValue output label");
SetDefaultParameterInt("ip.undefinedvalue", 0.0);
AddRAMParameter();
......@@ -103,8 +116,8 @@ namespace otb
SetDocExampleParameterValue("io.out", "QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5.tif");
SetDocExampleParameterValue("ip.radiusx", "2");
SetDocExampleParameterValue("ip.radiusy", "5");
SetDocExampleParameterValue("ip.nodatavalue", "128");
SetDocExampleParameterValue("ip.undefinedvalue", "10");
SetDocExampleParameterValue("ip.nodatavalue", "10");
SetDocExampleParameterValue("ip.undefinedvalue", "7");
}
......@@ -123,21 +136,35 @@ namespace otb
// Load input image to CLASSIFY
UInt8ImageType::Pointer inImage = GetParameterUInt8Image("io.in");
// NEIGHBORHOOD MAJORITY FILTER
// NEIGHBORHOOD MAJORITY FILTER SETTINGS
RadiusType rad;
rad[0] = GetParameterInt("ip.radiusx");
rad[1] = GetParameterInt("ip.radiusy");
m_NeighMajVotingFilter->SetInput(inImage);
m_NeighMajVotingFilter->SetRadiusNeighborhood(rad);
BallStructuringType seBall;
seBall.SetRadius(rad);
seBall.CreateStructuringElement();
m_NeighMajVotingFilter->SetKernel(seBall);
m_NeighMajVotingFilter->SetInput(inImage);
m_NeighMajVotingFilter->SetNoDataValue(GetParameterInt("ip.nodatavalue"));
m_NeighMajVotingFilter->SetUndefinedValue(GetParameterInt("ip.undefinedvalue"));
// Set to UnDefinedValue if NOT unique Majority Voting
if (IsParameterEnabled("ip.suvbool")) {
m_NeighMajVotingFilter->SetKeepOriginalLabelBool(false);
}
// Keep original label value if NOT unique Majority Voting
else {
m_NeighMajVotingFilter->SetKeepOriginalLabelBool(true);
}
/** REGULARIZATION OF CLASSIFICATION */
SetParameterOutputImage<UInt8ImageType>("io.out", m_NeighMajVotingFilter->GetOutput());
SetParameterOutputImage<OutputLabelImageType>("io.out", m_NeighMajVotingFilter->GetOutput());
}//END DoExecute()
//NEIGHBORHOOD MAJORITY FILTER
NeighborhoodMajorityVotingFilterType::Pointer m_NeighMajVotingFilter;
}; //END class ClassificationRegularisationMajorityVoting
......
......@@ -24,7 +24,6 @@
#include "itkConfigure.h"
#include "itkMorphologyImageFilter.h"
#include "itkBinaryBallStructuringElement.h"
namespace otb {
......@@ -49,47 +48,30 @@ namespace otb {
* \sa MorphologyImageFilter, GrayscaleFunctionDilateImageFilter, BinaryDilateImageFilter
* \ingroup ImageEnhancement MathematicalMorphologyImageFilters
*/
/*
template<class TInputImage, class TOutputImage, class TKernel>
template<class TInputImage, class TOutputImage=TInputImage, class TKernel=typename itk::Neighborhood<typename TInputImage::PixelType, TInputImage::ImageDimension> >
class ITK_EXPORT NeighborhoodMajorityVotingImageFilter :
public itk::MorphologyImageFilter<TInputImage, TOutputImage, TKernel>
{*/
template<class TInputImage>
class ITK_EXPORT NeighborhoodMajorityVotingImageFilter :
public itk::MorphologyImageFilter<
TInputImage,
TInputImage,
itk::BinaryBallStructuringElement< typename TInputImage::PixelType, TInputImage::ImageDimension >
>
{
public:
/** Standard class typedefs. */
typedef NeighborhoodMajorityVotingImageFilter Self;
//typedef itk::MorphologyImageFilter<TInputImage, TOutputImage, TKernel> Superclass;
typedef itk::MorphologyImageFilter<
TInputImage,
TInputImage,
itk::BinaryBallStructuringElement< typename TInputImage::PixelType, TInputImage::ImageDimension >
> Superclass;
typedef itk::MorphologyImageFilter<TInputImage, TOutputImage, TKernel>
Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Standard New method. */
itkNewMacro(Self);
/** Runtime information support. */
itkTypeMacro(NeighborhoodMajorityVotingImageFilter,
itk::MorphologyImageFilter);
itk::MorphologyImageFilter);
/** Declaration of pixel type. */
typedef typename Superclass::PixelType PixelType;
/** Kernel (structuring element) definition. */
typedef typename itk::BinaryBallStructuringElement< typename TInputImage::PixelType, TInputImage::ImageDimension > BallStructuringType;
/** Kernel (structuring element) iterator. */
typedef typename Superclass::KernelIteratorType KernelIteratorType;
......@@ -100,28 +82,30 @@ public:
/** Kernel typedef. */
typedef typename Superclass::KernelType KernelType;
/** Radius typedef. */
typedef typename Superclass::RadiusType RadiusType;
/** Default boundary condition type */
typedef typename Superclass::DefaultBoundaryConditionType DefaultBoundaryConditionType;
/** ImageDimension constant */
/** ImageDimension constants */
itkStaticConstMacro(InputImageDimension, unsigned int,
TInputImage::ImageDimension);
/** NeighborhoodDimension constant */
itkStaticConstMacro(OutputImageDimension, unsigned int,
TOutputImage::ImageDimension);
itkStaticConstMacro(KernelDimension, unsigned int,
BallStructuringType::NeighborhoodDimension);
TKernel::NeighborhoodDimension);
/** Type of the pixels in the Kernel. */
typedef typename BallStructuringType::PixelType KernelPixelType;
typedef typename TKernel::PixelType KernelPixelType;
#ifdef ITK_USE_CONCEPT_CHECKING
/** Begin concept checking */
itkConceptMacro(SameDimensionCheck,
itkConceptMacro(InputConvertibleToOutputCheck,
(itk::Concept::Convertible<PixelType, typename TOutputImage::PixelType>));
itkConceptMacro(SameDimensionCheck1,
(itk::Concept::SameDimension<InputImageDimension, OutputImageDimension>));
itkConceptMacro(SameDimensionCheck2,
(itk::Concept::SameDimension<InputImageDimension, KernelDimension>));
itkConceptMacro(InputGreaterThanComparableCheck,
(itk::Concept::GreaterThanComparable<PixelType>));
......@@ -131,6 +115,8 @@ public:
#endif
//Creates a SetNoDataValue method
virtual void SetNoDataValue(const PixelType _arg)
{
......@@ -148,25 +134,10 @@ public:
//Creates a SetUndefinedValue method
itkSetMacro(UndefinedValue, PixelType);
//Creates a SetKeepOriginalLabelBool method
itkSetMacro(KeepOriginalLabelBool, bool);
//Creates a SetRadiusNeighborhood method
/** Set kernel (structuring element). */
virtual void SetRadiusNeighborhood(const RadiusType _arg)
{
itkDebugMacro("setting RadiusNeighborhood to " << _arg);
if (this->m_RadiusNeighborhood != _arg)
{
this->m_RadiusNeighborhood = _arg;
//Kernel Setting
BallStructuringType seBall;
seBall.SetRadius(m_RadiusNeighborhood);
seBall.CreateStructuringElement();
this->SetKernel(seBall);
this->Modified();
}
}
protected:
......@@ -183,7 +154,8 @@ protected:
const KernelIteratorType kernelBegin,
const KernelIteratorType kernelEnd);
private:
NeighborhoodMajorityVotingImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
......@@ -193,7 +165,7 @@ private:
PixelType m_NoDataValue;
PixelType m_UndefinedValue;
RadiusType m_RadiusNeighborhood;
bool m_KeepOriginalLabelBool;
}; // end of class
......
......@@ -23,28 +23,26 @@
// gets integrated into the main directories.
#include "itkConfigure.h"
#include "otbNeighborhoodMajorityVotingImageFilter.h"
namespace otb {
template<class TInputImage>
NeighborhoodMajorityVotingImageFilter<TInputImage>::NeighborhoodMajorityVotingImageFilter()
{
template<class TInputImage, class TOutputImage, class TKernel>
NeighborhoodMajorityVotingImageFilter<TInputImage, TOutputImage, TKernel>::NeighborhoodMajorityVotingImageFilter() {
this->SetNoDataValue(itk::NumericTraits<PixelType>::NonpositiveMin());
this->SetUndefinedValue(itk::NumericTraits<PixelType>::NonpositiveMin());
RadiusType radInit;
radInit[0] = 1;
radInit[1] = 1;
this->SetRadiusNeighborhood(radInit);
m_KeepOriginalLabelBool = true;
}
template<class TInputImage>
typename NeighborhoodMajorityVotingImageFilter<TInputImage>::PixelType
NeighborhoodMajorityVotingImageFilter<TInputImage>::Evaluate(const NeighborhoodIteratorType &nit,
const KernelIteratorType kernelBegin,
const KernelIteratorType kernelEnd) {
template<class TInputImage, class TOutputImage, class TKernel>
typename NeighborhoodMajorityVotingImageFilter<TInputImage, TOutputImage,
TKernel>::PixelType NeighborhoodMajorityVotingImageFilter<TInputImage,
TOutputImage, TKernel>::Evaluate(const NeighborhoodIteratorType &nit,
const KernelIteratorType kernelBegin,
const KernelIteratorType kernelEnd) {
/*
KernelIteratorType kernelBegin_ = this->GetKernel().Begin();
......@@ -93,16 +91,21 @@ typename NeighborhoodMajorityVotingImageFilter<TInputImage>::PixelType
//If the majorityLabel is NOT unique in the neighborhood
for (histoIt = histoNeigh.begin(); histoIt != histoNeigh.end(); ++histoIt) {
if ( (histoIt->second == majorityFreq) && (histoIt->first != majorityLabel) ) {
majorityLabel = m_UndefinedValue;
break;
if(m_KeepOriginalLabelBool == true) {
majorityLabel = centerPixel;
}
else {
majorityLabel = m_UndefinedValue;
}
break;
}
}
}
}//END if (centerPixel != m_NoDataValue)
//If centerPixel == m_NoDataValue
//If (centerPixel == m_NoDataValue)
else{
majorityLabel = m_UndefinedValue;
majorityLabel = m_NoDataValue;
}
return majorityLabel;
......
......@@ -423,12 +423,13 @@ OTB_TEST_APPLICATION(NAME apTvComputeConfusionMatrixR
OTB_TEST_APPLICATION(NAME apTvClassificationRegMajorityVoting
APP ClassificationRegularisationMajorityVoting
OPTIONS -io.in ${INPUTDATA}/Classification/QB_1_ortho_4Cls_N_Classified_OTB.tif
-io.out ${TEMP}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5_APP.tif
-io.out ${TEMP}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5_nodv10_undv7_APP.tif
-ip.suvbool true
-ip.radiusx 2
-ip.radiusy 5
-ip.nodatavalue 128
-ip.undefinedvalue 10
-ip.nodatavalue 10
-ip.undefinedvalue 7
VALID --compare-image ${NOTOL}
${BASELINE}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5.tif
${TEMP}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5_APP.tif
${BASELINE}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5_nodv10_undv7.tif
${TEMP}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5_nodv10_undv7_APP.tif
)
......@@ -322,6 +322,7 @@ ADD_TEST(leTvSVMImageClassificationFilterWithNeighborhoodMajorityVoting ${LEARNI
otbNeighborhoodMajorityVotingImageFilterTest
${TEMP}/leSVMImageClassificationFilterOutput.tif
${TEMP}/leSVMImageClassificationWithNMVFilterOutput.tif
false
)
SET_TESTS_PROPERTIES(leTvSVMImageClassificationFilterWithNeighborhoodMajorityVoting PROPERTIES DEPENDS leTvSVMImageClassificationFilter)
......@@ -648,15 +649,16 @@ otbNeighborhoodMajorityVotingImageFilterNew)
ADD_TEST(leTvNeighborhoodMajorityVotingImageFilterTest ${LEARNING_TESTS5}
--compare-image ${NOTOL}
${BASELINE}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5.tif
${TEMP}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5.tif
${BASELINE}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5_nodv10_undv7.tif
${TEMP}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5_nodv10_undv7.tif
otbNeighborhoodMajorityVotingImageFilterTest
${INPUTDATA}/Classification/QB_1_ortho_4Cls_N_Classified_OTB.tif
${TEMP}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5.tif
${TEMP}/QB_1_ortho_4Cls_N_Classified_OTB_NMV_x2_y5_nodv10_undv7.tif
false #KeepOriginalLabelBool
2 #xRadius
5 #yRadius
128 #NoDataValue
10 #UndefinedValue
10 #NoDataValue
7 #UndefinedValue
)
......
......@@ -15,9 +15,6 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkMacro.h"
#include "otbImage.h"
#include <iostream>
......@@ -26,16 +23,32 @@
int otbNeighborhoodMajorityVotingImageFilterNew(int argc, char* argv[])
{
typedef unsigned char LabelPixelType;
typedef unsigned char InputLabelPixelType; //8 bits
typedef unsigned short OutputLabelPixelType; //16 bits
const unsigned int Dimension = 2;
typedef otb::Image<LabelPixelType, Dimension> LabelImageType;
typedef otb::Image<InputLabelPixelType, Dimension> InputLabelImageType;
typedef otb::Image<OutputLabelPixelType, Dimension> OutputLabelImageType;
//SE TYPE
typedef itk::Neighborhood<InputLabelPixelType, Dimension> StructuringType;
//NEIGHBORHOOD MAJORITY FILTER TYPES
typedef otb::NeighborhoodMajorityVotingImageFilter<InputLabelImageType, OutputLabelImageType, StructuringType> NeighborhoodMajorityVotingFilter3ArgsType;
typedef otb::NeighborhoodMajorityVotingImageFilter<InputLabelImageType, OutputLabelImageType> NeighborhoodMajorityVotingFilter2ArgsType;
typedef otb::NeighborhoodMajorityVotingImageFilter<InputLabelImageType> NeighborhoodMajorityVotingFilter1ArgType;
typedef otb::NeighborhoodMajorityVotingImageFilter<LabelImageType> NeighborhoodMajorityVotingFilterType;
NeighborhoodMajorityVotingFilterType::Pointer NeighMajVotingFilter = NeighborhoodMajorityVotingFilterType::New();
//NEIGHBORHOOD MAJORITY FILTERS
NeighborhoodMajorityVotingFilter3ArgsType::Pointer NeighMajVotingFilter3Args = NeighborhoodMajorityVotingFilter3ArgsType::New();
NeighborhoodMajorityVotingFilter2ArgsType::Pointer NeighMajVotingFilter2Args = NeighborhoodMajorityVotingFilter2ArgsType::New();
NeighborhoodMajorityVotingFilter1ArgType::Pointer NeighMajVotingFilter1Arg = NeighborhoodMajorityVotingFilter1ArgType::New();
std::cout << NeighMajVotingFilter << std::endl;
std::cout << NeighMajVotingFilter3Args << std::endl;
std::cout << std::endl;
std::cout << NeighMajVotingFilter2Args << std::endl;
std::cout << std::endl;
std::cout << NeighMajVotingFilter1Arg << std::endl;
return EXIT_SUCCESS;
}
......@@ -23,59 +23,86 @@
#include <otbImageFileReader.h>
#include "otbImageFileWriter.h"
#include "itkBinaryBallStructuringElement.h"
#include "otbNeighborhoodMajorityVotingImageFilter.h"
#include "itkTimeProbe.h"
int otbNeighborhoodMajorityVotingImageFilterTest(int argc, char* argv[]) {
typedef unsigned char LabelPixelType;
const unsigned int Dimension = 2;
typedef otb::Image<LabelPixelType, Dimension> LabelImageType;
typedef otb::ImageFileReader<LabelImageType> ReaderType;
typedef otb::ImageFileWriter<LabelImageType> WriterType;
typedef otb::NeighborhoodMajorityVotingImageFilter<LabelImageType> NeighborhoodMajorityVotingFilterType;
typedef NeighborhoodMajorityVotingFilterType::RadiusType RadiusType;
const char * inputFileName = argv[1];
const char * outputFileName = argv[2];
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFileName);
//NEIGHBORHOOD MAJORITY FILTER
NeighborhoodMajorityVotingFilterType::Pointer NeighMajVotingFilter;
NeighMajVotingFilter = NeighborhoodMajorityVotingFilterType::New();
NeighMajVotingFilter->SetInput(reader->GetOutput());
if(argc >= 4)
{
RadiusType rad;
rad[0] = atoi(argv[3]);
rad[1] = atoi(argv[4]);
NeighMajVotingFilter->SetRadiusNeighborhood(rad);
if(argc >= 5)
{
NeighMajVotingFilter->SetNoDataValue(atoi(argv[5]));
if(argc >= 6)
{
NeighMajVotingFilter->SetUndefinedValue(atoi(argv[6]));
}
}
}
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outputFileName);
writer->SetInput(NeighMajVotingFilter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
int otbNeighborhoodMajorityVotingImageFilterTest(int argc, char* argv[])
{
typedef unsigned char InputLabelPixelType; //8 bits
typedef unsigned char OutputLabelPixelType; //8 bits
const unsigned int Dimension = 2;
typedef otb::Image<InputLabelPixelType, Dimension> InputLabelImageType;
typedef otb::Image<OutputLabelPixelType, Dimension> OutputLabelImageType;
typedef otb::ImageFileReader<InputLabelImageType> ReaderType;
typedef otb::ImageFileWriter<OutputLabelImageType> WriterType;
//SE TYPE
typedef itk::Neighborhood<InputLabelPixelType, Dimension> StructuringType;
typedef StructuringType::RadiusType RadiusType;
//BINARY BALL SE TYPE
typedef itk::BinaryBallStructuringElement<InputLabelPixelType, Dimension> BallStructuringType;
//NEIGHBORHOOD MAJORITY FILTER TYPE
typedef otb::NeighborhoodMajorityVotingImageFilter<InputLabelImageType, OutputLabelImageType, StructuringType> NeighborhoodMajorityVotingFilterType;
const char * inputFileName = argv[1];
const char * outputFileName = argv[2];
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFileName);
//NEIGHBORHOOD MAJORITY FILTER
NeighborhoodMajorityVotingFilterType::Pointer NeighMajVotingFilter;
NeighMajVotingFilter = NeighborhoodMajorityVotingFilterType::New();
NeighMajVotingFilter->SetInput(reader->GetOutput());
BallStructuringType seBall;
RadiusType rad;
if (argc >= 3) {
std::string KeepOriginalLabelBoolStr = argv[3];
if (KeepOriginalLabelBoolStr.compare("true") == 0) {
NeighMajVotingFilter->SetKeepOriginalLabelBool(true);
}
else {
NeighMajVotingFilter->SetKeepOriginalLabelBool(false);
}
if (argc >= 5) {
rad[0] = atoi(argv[4]);
rad[1] = atoi(argv[5]);
if (argc >= 6) {
NeighMajVotingFilter->SetNoDataValue(atoi(argv[6]));
if (argc >= 7) {
NeighMajVotingFilter->SetUndefinedValue(atoi(argv[7]));
}
}
}
else {
rad[0] = 1;
rad[1] = 1;
}
}
seBall.SetRadius(rad);
seBall.CreateStructuringElement();
NeighMajVotingFilter->SetKernel(seBall);
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outputFileName);
writer->SetInput(NeighMajVotingFilter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
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