Commit 26dea959 authored by Emmanuel Christophe's avatar Emmanuel Christophe

ENH: move hill shading modulation functor in class

parent 3121db56
......@@ -24,6 +24,33 @@ namespace otb
{
namespace Functor
{
/** \class HillShadeModulationFunctor
* \brief Modulate an image with hill shading
*
* Take an image (RGB) as input and the result of the hillshading
* (another image with the value between 0 and 1) and modulate
* the first image by the value of the hill shading.
*
* \ingroup Functor
* \example BasicFilters/HillShadingExample.cxx
*/
template< class TInput1, class TInput2=TInput1, class TOutput=TInput1>
class HillShadeModulationFunctor
{
public:
HillShadeModulationFunctor() {}
~HillShadeModulationFunctor() {}
inline TOutput operator()( const TInput1 & A, const TInput2 & B) const
{
TOutput out;
out.SetRed(A.GetRed() * B);
out.SetGreen(A.GetGreen() * B);
out.SetBlue(A.GetBlue() * B);
return out;
}
};
/** \class HillShadingFunctor
* \brief Unary neighborhood functor to compute the lambertian of a surface
*
......@@ -32,14 +59,15 @@ namespace Functor
* representation of relief. The output is a value between 0 and 1.
*
* \ingroup Functor
* \example BasicFilters/HillShadingExample.cxx
*/
template <class TNeighIter, class TInputImage, class TOutput>
class HillShadingFunctor
{
public:
typedef HillShadingFunctor Self;
typedef TNeighIter IteratorType;
typedef HillShadingFunctor Self;
typedef TNeighIter IteratorType;
typedef typename IteratorType::PixelType PixelType;
HillShadingFunctor(): m_AzimuthLight(30.0/180.0*CONST_PI), m_ElevationLight(45.0/180.0*CONST_PI),
......
......@@ -61,28 +61,6 @@
#include "itkBinaryFunctorImageFilter.h"
#include "otbWorldFile.h"
namespace otb {
namespace Functor {
template< class TInput1, class TInput2=TInput1, class TOutput=TInput1>
class MultRGB
{
public:
MultRGB() {}
~MultRGB() {}
inline TOutput operator()( const TInput1 & A, const TInput2 & B) const
{
TOutput out;
out.SetRed(A.GetRed() * B);
out.SetGreen(A.GetGreen() * B);
out.SetBlue(A.GetBlue() * B);
return out;
}
};
}
}
int main(int argc, char * argv[])
{
......@@ -195,7 +173,7 @@ int main(int argc, char * argv[])
typedef itk::BinaryFunctorImageFilter<RGBImageType, ImageType, RGBImageType,
otb::Functor::MultRGB<RGBPixelType, PixelType, RGBPixelType> > MultiplyFilterType;
otb::Functor::HillShadeModulationFunctor<RGBPixelType, PixelType, RGBPixelType> > MultiplyFilterType;
MultiplyFilterType::Pointer multiply = MultiplyFilterType::New();
multiply->SetInput1(colormapper->GetOutput());
......
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