Skip to content
Snippets Groups Projects
Commit 5c8d3de6 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH: STYLE and cleaning

parent f0c007f7
No related branches found
No related tags found
No related merge requests found
......@@ -51,18 +51,18 @@ public:
itkNewMacro(Self);
itkTypeMacro(MultiResolutionPyramid, otb::Application);
/** Image and filters typedef */
typedef otb::Image<float> SingleImageType;
typedef itk::DiscreteGaussianImageFilter<SingleImageType,
SingleImageType> SmoothingImageFilterType;
typedef otb::Image<float> SingleImageType;
typedef itk::DiscreteGaussianImageFilter<SingleImageType,
SingleImageType> SmoothingImageFilterType;
typedef otb::PerBandVectorImageFilter<FloatVectorImageType,
typedef otb::PerBandVectorImageFilter<FloatVectorImageType,
FloatVectorImageType,
SmoothingImageFilterType> SmoothingVectorImageFilterType;
SmoothingImageFilterType> SmoothingVectorImageFilterType;
typedef itk::ShrinkImageFilter<FloatVectorImageType,
FloatVectorImageType> ShrinkFilterType;
typedef itk::ShrinkImageFilter<FloatVectorImageType,
FloatVectorImageType> ShrinkFilterType;
private:
MultiResolutionPyramid()
......@@ -73,20 +73,6 @@ private:
void DoCreateParameters()
{
// descriptor->SetName("Multi-resolution pyramid tool");
// descriptor->SetDescription("Build a multi-resolution pyramid of the image.");
// descriptor->AddInputImage();
// descriptor->AddOption("NumberOfLevels","Number of levels in the pyramid (default is 1)","level", 1, false, ApplicationDescriptor::Integer);
// descriptor->AddOption("ShrinkFactor","Subsampling factor (default is 2)","sfactor", 1, false, ApplicationDescriptor::Integer);
// descriptor->AddOption("VarianceFactor","Before subsampling, image
// is smoothed with a gaussian kernel of variance
// VarianceFactor*ShrinkFactor.
//Higher values will result in more blur, lower in more aliasing (default is 0.6)","vfactor", 1, false, ApplicationDescriptor::Real);
// descriptor->AddOption("FastScheme","If used, this option allows to speed-up computation by iteratively subsampling previous level of pyramid instead of processing the full input image each time. Please note that this may result in extra blur or extra aliasing.","fast", 0, false, ApplicationDescriptor::Integer);
// descriptor->AddOption("OutputPrefixAndExtextension","prefix for the output files, and extension","out", 2, true, ApplicationDescriptor::String);
// descriptor->AddOption("AvailableMemory","Set the maximum of available memory for the pipeline execution in mega bytes (optional, 256 by default)","ram", 1, false, otb::ApplicationDescriptor::Integer);
AddParameter(ParameterType_InputImage, "in", "Input Image");
AddParameter(ParameterType_OutputImage, "out", "Output Image");
......@@ -95,27 +81,27 @@ private:
AddParameter(ParameterType_Int, "level", "Number Of Levels");
SetParameterInt("level", 1);
SetParameterDescription( "level", "Number of levels in the pyramid (default is 1)");
AddParameter(ParameterType_Int, "sfactor", "Subsampling factor");
SetParameterInt("sfactor", 2);
AddParameter(ParameterType_Float, "vfactor", "Subsampling factor");
SetParameterFloat("vfactor", 0.6);
// Boolean Fast scheme
// Available memory
// MandatoryOff("outmin");
// MandatoryOff("outmax");
// Boolean Fast scheme (remains)
// descriptor->AddOption("FastScheme","If used, this option allows
// to speed-up computation by iteratively
// subsampling previous level of pyramid instead of processing the
// full input
//image each time. Please note that this may result in extra blur
// or extra aliasing.","fast",
//0, false, ApplicationDescriptor::Integer);
}
void DoUpdateParameters()
{
// Nothing to do here for the parameters : all are independent
// Reinitialize the internal process used
}
......@@ -129,14 +115,13 @@ private:
unsigned int nbLevels = GetParameterInt("level");
unsigned int shrinkFactor = GetParameterInt("sfactor");
double varianceFactor = GetParameterFloat("vfactor");
//bool fastScheme = parseResult->IsOptionPresent("FastScheme");
bool fastScheme = false;
// Get the input image
FloatVectorImageType::Pointer inImage = GetParameterImage("in");
// Get the Initial Output Image FileName
Parameter* param = GetParameterByKey("out");
std::string path, fname, ext;
......@@ -157,7 +142,7 @@ private:
while(currentLevel <= nbLevels)
{
otbAppLogDEBUG( << "Processing level " << currentLevel << " with shrink factor "<<currentFactor);
m_SmoothingFilter->SetInput(inImage);
// According to
......@@ -169,14 +154,13 @@ private:
m_ShrinkFilter->SetInput(m_SmoothingFilter->GetOutput());
m_ShrinkFilter->SetShrinkFactors(currentFactor);
if(!fastScheme)
{
currentFactor*=shrinkFactor;
}
// Get the Output Parameter to change the current image filename
Parameter* param = GetParameterByKey("out");
Parameter* param = GetParameterByKey("out");
if (dynamic_cast<OutputImageParameter*>(param))
{
OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param);
......@@ -184,7 +168,7 @@ private:
// build the current image filename
std::ostringstream oss;
oss <<path<<"/"<<fname<<"_"<<currentLevel<<ext;
// writer label
std::ostringstream osswriter;
osswriter<< "writer "<< currentLevel;
......@@ -200,7 +184,7 @@ private:
}
++currentLevel;
}
// Disable the output Image parameter to avoid writing
// the last image (Application::ExecuteAndWriteOutput method)
GetParameterByKey("out")->SetActive(false);
......@@ -213,3 +197,4 @@ private:
}
OTB_APPLICATION_EXPORT(otb::Wrapper::MultiResolutionPyramid)
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