Skip to content
Snippets Groups Projects
Commit 1cdeca05 authored by Aurélien Bricier's avatar Aurélien Bricier
Browse files

ENH: added the LocalStatisticsExtraction application ans associated tests

parent dcd2b240
No related branches found
No related tags found
No related merge requests found
......@@ -26,4 +26,8 @@ OTB_CREATE_APPLICATION(NAME BinaryMorphologicalOperation
OTB_CREATE_APPLICATION(NAME GrayScaleMorphologicalOperation
SOURCES otbGrayScaleMorphologicalOperation.cxx
LINK_LIBRARIES OTBIO;OTBCommon;OTBBasicFilters)
OTB_CREATE_APPLICATION(NAME LocalStatisticExtraction
SOURCES otbLocalStatisticExtraction.cxx
LINK_LIBRARIES OTBIO;OTBCommon;OTBBasicFilters;OTBFeatureExtraction)
\ No newline at end of file
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"
#include "otbRadiometricMomentsImageFilter.h"
#include "otbMultiToMonoChannelExtractROI.h"
#include "itkTimeProbe.h"
namespace otb
{
namespace Wrapper
{
class LocalStatisticExtraction : public Application
{
public:
/** Standard class typedefs. */
typedef LocalStatisticExtraction Self;
typedef Application Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType,FloatVectorImageType::InternalPixelType>
ExtractorFilterType;
typedef RadiometricMomentsImageFilter<FloatImageType, FloatVectorImageType>
FilterType;
/** Standard macro */
itkNewMacro(Self);
itkTypeMacro(LocalStatisticExtraction, otb::Application);
private:
void DoInit()
{
SetName("LocalStatisticExtraction");
SetDescription("Computes local statistics on every pixel of the input image selected channel");
// Documentation
SetDocName("Local Statistic Extraction");
SetDocLongDescription("This application computes local Statistics on a mono band image");
SetDocLimitations("None");
SetDocAuthors("OTB-Team");
SetDocSeeAlso("otbRadiometricMomentsImageFunction class");
AddDocTag("Statistics");
AddDocTag(Tags::FeatureExtraction);
AddParameter(ParameterType_InputImage, "in", "Input Image");
SetParameterDescription("in", "The input image to compute the features on.");
AddParameter(ParameterType_Int, "channel", "Selected Channel");
SetParameterDescription("channel", "The selected channel index");
SetDefaultParameterInt("channel", 1);
SetMinimumParameterIntValue("channel", 1);
AddRAMParameter();
AddParameter(ParameterType_Int, "radius", "Neighborhood radius");
SetParameterDescription("radius", "The computational window radius.");
SetMinimumParameterIntValue("radius",1);
SetDefaultParameterInt("radius",3);
AddParameter(ParameterType_OutputImage, "out", "Feature Output Image");
SetParameterDescription("out", "Output image containing the local statistic features.");
// Doc example parameter settings
SetDocExampleParameterValue("in", "qb_RoadExtract.tif");
SetDocExampleParameterValue("channel", "1");
SetDocExampleParameterValue("parameters.spethre", "50.0");
SetDocExampleParameterValue("parameters.spathre", "100");
SetDocExampleParameterValue("out", "Statistics.tif");
}
void DoUpdateParameters()
{
// Nothing to do here : all parameters are independent
}
void DoExecute()
{
FloatVectorImageType::Pointer inImage = GetParameterImage("in");
inImage->UpdateOutputInformation();
if( GetParameterInt("channel") > inImage->GetNumberOfComponentsPerPixel() )
{
otbAppLogCRITICAL("Selected band is not available...");
return;
}
m_ExtractorFilter = ExtractorFilterType::New();
m_ExtractorFilter->SetInput(inImage);
m_ExtractorFilter->SetStartX(inImage->GetLargestPossibleRegion().GetIndex(0));
m_ExtractorFilter->SetStartY(inImage->GetLargestPossibleRegion().GetIndex(1));
m_ExtractorFilter->SetSizeX(inImage->GetLargestPossibleRegion().GetSize(0));
m_ExtractorFilter->SetSizeY(inImage->GetLargestPossibleRegion().GetSize(1));
m_ExtractorFilter->SetChannel(GetParameterInt("channel"));
m_ExtractorFilter->UpdateOutputInformation();
m_Filter = FilterType::New();
m_Filter->SetInput(m_ExtractorFilter->GetOutput());
m_Filter->SetRadius(GetParameterInt("radius"));
m_Filter->UpdateOutputInformation();
SetParameterOutputImage("out", m_Filter->GetOutput());
}
ExtractorFilterType::Pointer m_ExtractorFilter;
FilterType::Pointer m_Filter;
};
}
}
OTB_APPLICATION_EXPORT(otb::Wrapper::LocalStatisticExtraction)
......@@ -90,5 +90,15 @@ OTB_TEST_APPLICATION(NAME apTvFEGrayScaleMorphologicalOperation
-out ${TEMP}/apTvFEGrayScaleMorphologicalOperation.tif
VALID --compare-image ${NOTOL}
${BASELINE}/apTvFEGrayScaleMorphologicalOperation.tif
${TEMP}/apTvFEGrayScaleMorphologicalOperation.tif)
${TEMP}/apTvFEGrayScaleMorphologicalOperation.tif)
OTB_TEST_APPLICATION(NAME apTvFELocalStatisticExtraction
APP LocalStatisticExtraction
OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
-channel 1
-radius 3
-out ${TEMP}/apTvFELocalStatisticExtraction.tif
VALID --compare-image ${NOTOL}
${BASELINE}/feTvRadiometricMomentsImageFilter.tif
${TEMP}/apTvFELocalStatisticExtraction.tif)
\ No newline at end of file
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