Skip to content
Snippets Groups Projects
Commit 7a2fb50d authored by Patrick Imbo's avatar Patrick Imbo
Browse files

BUG: missing SetFunction for otbFunctionWithNeighborhoodToImageFilter

parent ffcb3940
No related branches found
No related tags found
No related merge requests found
...@@ -81,13 +81,28 @@ public: ...@@ -81,13 +81,28 @@ public:
typedef typename FunctionType::OutputType FunctionValueType; typedef typename FunctionType::OutputType FunctionValueType;
typedef typename FunctionType::InputType FunctionPositionType; typedef typename FunctionType::InputType FunctionPositionType;
itkGetObjectMacro(Function, FunctionType); // itkGetObjectMacro(Function, FunctionType);
/** Set the internal spatial function. */
void SetFunction(FunctionPointerType function)
{
m_Function = function;
this->Modified();
}
FunctionPointerType GetFunction()
{
return m_Function;
}
/** Image dimensions */ /** Image dimensions */
itkStaticConstMacro(InputImageDimension, unsigned int, itkStaticConstMacro(InputImageDimension, unsigned int,
TInputImage::ImageDimension); TInputImage::ImageDimension);
itkStaticConstMacro(OutputImageDimension, unsigned int, itkStaticConstMacro(OutputImageDimension, unsigned int,
TOutputImage::ImageDimension); TOutputImage::ImageDimension);
/** Accessors */ /** Accessors */
itkGetMacro(Radius, InputImageSizeType); itkGetMacro(Radius, InputImageSizeType);
void SetRadius(InputImageSizeType& rad) void SetRadius(InputImageSizeType& rad)
......
/*=========================================================================
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 "itkExceptionObject.h"
#include "otbImage.h"
#include "otbFunctionWithNeighborhoodToImageFilter.h"
#include "itkVarianceImageFunction.h"
#include "otbImageFileReader.h"
#include "otbStreamingImageFileWriter.h"
int otbFunctionWithNeighborhoodToImageFilter(int argc, char * argv[])
{
const unsigned int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType, Dimension> InputImageType;
typedef otb::Image<PixelType, Dimension> OutputImageType;
typedef otb::ImageFileReader<InputImageType> ReaderType;
typedef otb::StreamingImageFileWriter<OutputImageType> WriterType;
typedef itk::VarianceImageFunction<InputImageType> FunctionType;
typedef otb::FunctionWithNeighborhoodToImageFilter<InputImageType, OutputImageType, FunctionType> FilterType;
// Instantiating object
FilterType::Pointer filter = FilterType::New();
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName(argv[1]);
writer->SetFileName(argv[2]);
filter->SetInput(reader->GetOutput());
FunctionType::Pointer function = FunctionType::New();
function->SetNeighborhoodRadius(atoi(argv[3]));
function->SetInputImage(reader->GetOutput());
filter->SetFunction(function);
writer->SetInput(filter->GetOutput());
writer->SetNumberOfStreamDivisions(2);
writer->Update();
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment