Skip to content
Snippets Groups Projects
Commit 48655bfa authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

MRG

parent 0d844fcb
No related branches found
No related tags found
No related merge requests found
Showing
with 99 additions and 43 deletions
......@@ -159,7 +159,7 @@ UnaryFunctorNeighborhoodWithOffsetImageFilter<TInputImage, TOutputImage, TFuncti
while ( ! outputIt.IsAtEnd() )
{
outputIt.Set( m_FunctorList[threadId]( neighInputOffIt ) );
outputIt.Set( m_FunctorList[threadId]( neighInputOffIt.GetNeighborhood() ) );
++neighInputOffIt;
++outputIt;
......
......@@ -22,6 +22,9 @@
#include "itkMacro.h"
#include "itkNumericTraits.h"
#include "itkNeighborhood.h"
#include "itkOffset.h"
#include "itkSize.h"
#include "itkVariableLengthVector.h"
namespace otb
......@@ -41,7 +44,7 @@ namespace Functor
* \ingroup Statistics
*/
template <class TIterInput, class TOutput>
template <class TScalarInputPixelType, class TScalarOutputPixelType>
class TextureFunctorBase
{
public:
......@@ -62,14 +65,17 @@ public:
};
virtual ~TextureFunctorBase() {};
typedef TIterInput IterType;
typedef TOutput OutputType;
typedef typename IterType::OffsetType OffsetType;
typedef typename IterType::RadiusType RadiusType;
typedef typename OutputType::ValueType OutputPixelType;
typedef typename IterType::InternalPixelType InternalPixelType;
typedef typename IterType::ImageType ImageType;
typedef itk::Neighborhood<InternalPixelType, ::itk::GetImageDimension<ImageType>::ImageDimension> NeighborhoodType;
typedef TScalarInputPixelType InputScalarType;
typedef TScalarOutputPixelType OutputScalarType;
typedef itk::VariableLengthVector<InputScalarType> InputVectorType;
typedef itk::VariableLengthVector<OutputScalarType> OutputVectorType;
typedef itk::Offset<> OffsetType;
typedef itk::Size<> RadiusType;
//typedef typename OutputType::ValueType OutputPixelType;
//typedef typename IterType::InternalPixelType InternalPixelType;
//typedef typename IterType::ImageType ImageType;
typedef itk::Neighborhood<InputScalarType, 2> NeighborhoodType;
typedef itk::Neighborhood<InputVectorType, 2> NeighborhoodVectorType;
typedef std::vector<double> DoubleVectorType;
typedef std::vector<int> IntVectorType;
typedef std::vector<IntVectorType> IntVectorVectorType;
......@@ -164,21 +170,64 @@ public:
m_OffsetBinLength = scottCoef*binLengthOff;
}
inline TOutput operator()(const IterType &itOff)
inline OutputScalarType operator()(const NeighborhoodType &neigh)
{
RadiusType radiusOff = neigh.GetRadius();
//OutputScalarType outPix;
//outPix.SetSize( neigh.GetCenterPixel().GetSize() );
//outPix.Fill(0);
OffsetType offset;
offset.Fill(0);
// Compute the neighborhood radius from the neigh+offset iterator to extract the neighborhood area from the iterator
RadiusType radius;
radius[0] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[0] - 1) ) - static_cast<double>( vcl_abs(m_Offset[0])) );
radius[1] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[1] - 1) ) - static_cast<double>( vcl_abs(m_Offset[1])) );
NeighborhoodType inNeigh;
inNeigh.SetRadius(radius);
NeighborhoodType offNeigh;
offNeigh.SetRadius(radiusOff);
// Extract the neighborhood area
for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ )
{
offset[0] = l;
for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++)
{
offset[1] = k;
inNeigh[offset] = neigh[offset];//neigh.GetPixel(offset);
}
}
// Extract the offset area
offset.Fill(0);
for ( int l = -static_cast<int>(radiusOff[0]); l <= static_cast<int>(radiusOff[0]); l++ )
{
offset[0] = l;
for ( int k = -static_cast<int>(radiusOff[1]); k <= static_cast<int>(radiusOff[1]); k++)
{
offset[1] = k;
offNeigh[offset] = neigh[offset];//neigh.GetPixel(offset);
}
}
OutputScalarType outPix = static_cast<OutputScalarType>( this->ComputeOverSingleChannel(inNeigh, offNeigh) );
return outPix;
}
inline OutputVectorType operator()(const NeighborhoodVectorType &neigh)
{
RadiusType radiusOff = itOff.GetRadius();
OutputType outPix;
outPix.SetSize( itOff.GetCenterPixel().GetSize() );
RadiusType radiusOff = neigh.GetRadius();
OutputVectorType outPix;
outPix.SetSize( neigh.GetCenterValue/*Pixel*/().GetSize() );
outPix.Fill(0);
OffsetType offset;
offset.Fill(0);
// Compute the neighborhood radius from the neigh+offset iterator to extract the neighborhood area from the iterator
RadiusType radius;
radius[0] = static_cast<unsigned int>( 0.5*( static_cast<double>(itOff.GetSize()[0] - 1) ) - static_cast<double>( vcl_abs(m_Offset[0])) );
radius[1] = static_cast<unsigned int>( 0.5*( static_cast<double>(itOff.GetSize()[1] - 1) ) - static_cast<double>( vcl_abs(m_Offset[1])) );
radius[0] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[0] - 1) ) - static_cast<double>( vcl_abs(m_Offset[0])) );
radius[1] = static_cast<unsigned int>( 0.5*( static_cast<double>(neigh.GetSize()[1] - 1) ) - static_cast<double>( vcl_abs(m_Offset[1])) );
// For each channel
for ( unsigned int i=0; i<itOff.GetCenterPixel().GetSize(); i++ )
for ( unsigned int i=0; i<neigh.GetCenterValue/*Pixel*/().GetSize(); i++ )
{
NeighborhoodType inNeigh;
inNeigh.SetRadius(radius);
......@@ -191,7 +240,7 @@ public:
for ( int k = -static_cast<int>(radius[1]); k <= static_cast<int>(radius[1]); k++)
{
offset[1] = k;
inNeigh[offset] = itOff.GetPixel(offset)[i];
inNeigh[offset] = neigh[offset][i];//neigh.GetPixel(offset)[i];
}
}
// Extract the offset area
......@@ -202,10 +251,10 @@ public:
for ( int k = -static_cast<int>(radiusOff[1]); k <= static_cast<int>(radiusOff[1]); k++)
{
offset[1] = k;
offNeigh[offset] = itOff.GetPixel(offset)[i];
offNeigh[offset] = neigh[offset][i];
}
}
outPix[i] = static_cast<OutputPixelType>( this->ComputeOverSingleChannel(inNeigh, offNeigh) );
outPix[i] = static_cast<OutputScalarType>( this->ComputeOverSingleChannel(inNeigh, offNeigh) );
}
return outPix;
}
......
......@@ -80,7 +80,8 @@ TextureImageFunction<TInputImage, TFunctor, TCoordRep>
FunctorType funct;
funct.SetOffset(m_Offset);
return static_cast<RealType>(funct.ComputeOverSingleChannel( it.GetNeighborhood(), itOff.GetNeighborhood()) );
//return static_cast<RealType>(funct.ComputeOverSingleChannel( it.GetNeighborhood(), itOff.GetNeighborhood()) );
return static_cast<RealType>(funct( it.GetNeighborhood() ));
}
......
......@@ -24,7 +24,7 @@
int otbPanTexTextureImageFilter(int argc, char * argv[])
{
{/*
const unsigned int Dimension =2;
typedef double PixelType;
typedef otb::VectorImage<PixelType,Dimension> ImageType;
......@@ -43,6 +43,6 @@ int otbPanTexTextureImageFilter(int argc, char * argv[])
writer->SetInput( panTex->GetOutput() );
writer->Update();
*/
return EXIT_SUCCESS;
}
......@@ -22,6 +22,7 @@
int otbPanTexTextureImageFilterNew(int argc, char * argv[])
{
/*
const unsigned int Dimension =2;
typedef double PixelType;
typedef otb::VectorImage<PixelType,Dimension> ImageType;
......@@ -29,7 +30,7 @@ int otbPanTexTextureImageFilterNew(int argc, char * argv[])
// Instantiating object
PanTexType::Pointer object = PanTexType::New();
*/
return EXIT_SUCCESS;
}
......@@ -25,6 +25,7 @@
int otbPanTexTextureImageFunctionFilter(int argc, char * argv[])
{
/*
const unsigned int Dimension =2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
......@@ -43,6 +44,6 @@ int otbPanTexTextureImageFunctionFilter(int argc, char * argv[])
writer->SetInput( panTex->GetOutput() );
writer->Update();
*/
return EXIT_SUCCESS;
}
......@@ -22,6 +22,7 @@
int otbPanTexTextureImageFunctionFilterNew(int argc, char * argv[])
{
/*
const unsigned int Dimension =2;
typedef double PixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
......@@ -29,7 +30,7 @@ int otbPanTexTextureImageFunctionFilterNew(int argc, char * argv[])
// Instantiating object
PanTexType::Pointer object = PanTexType::New();
*/
return EXIT_SUCCESS;
}
......@@ -70,12 +70,13 @@ int otbTextureFunctor(int argc, char * argv[])
typedef otb::VectorImage<InputPixelType,Dimension> ImageType;
typedef ImageType::PixelType PixelType;
typedef itk::ConstNeighborhoodIterator<ImageType> IteratorType;
/*
if(strArgv == "ENJ")
{
typedef otb::Functor::EnergyTextureFunctor<IteratorType, PixelType> FunctorType;
typedef otb::Functor::EnergyTextureFunctor<InputPixelType, InputPixelType> FunctorType;
return( generic_TextureFunctor<ImageType, ImageType, FunctorType>(argc,argv) );
}
else if ( strArgv == "ENT" )
{
typedef otb::Functor::EntropyTextureFunctor<IteratorType, PixelType> FunctorType;
......@@ -156,10 +157,12 @@ int otbTextureFunctor(int argc, char * argv[])
typedef otb::Functor::MeanTextureFunctor<IteratorType, PixelType> FunctorType;
return( generic_TextureFunctor<ImageType, ImageType, FunctorType>(argc,argv) );
}
else
{
return EXIT_FAILURE;
}
*/
return EXIT_SUCCESS;
}
......@@ -25,28 +25,28 @@
#include "otbTextureFunctorBase.h"
template <class TIterInput, class TOutput>
template <class TScalarInput, class TScalarOutput>
class ITK_EXPORT TextureFunctorTest :
public otb::Functor::TextureFunctorBase<TIterInput, TOutput>
public otb::Functor::TextureFunctorBase<TScalarInput, TScalarOutput>
{
public:
TextureFunctorTest()
{};
~TextureFunctorTest(){};
typedef TIterInput IterType;
typedef TOutput OutputType;
typedef typename IterType::OffsetType OffsetType;
typedef typename IterType::RadiusType RadiusType;
typedef typename IterType::InternalPixelType InternalPixelType;
typedef typename IterType::ImageType ImageType;
typedef itk::Neighborhood<InternalPixelType,::itk::GetImageDimension<ImageType>::ImageDimension> NeighborhoodType;
//typedef TScalarInputT IterType;
//typedef TScalarOutput OutputType;
//typedef typename IterType::OffsetType OffsetType;
///typedef typename IterType::RadiusType RadiusType;
//typedef typename IterType::InternalPixelType InternalPixelType;
//typedef typename IterType::ImageType ImageType;
typedef itk::Neighborhood<TScalarInput, 2> NeighborhoodType;
virtual double ComputeOverSingleChannel(const NeighborhoodType &neigh, const NeighborhoodType &neighOff)
{
double out = neigh.GetCenterValue();
return out;
return out;
}
};
......@@ -65,7 +65,7 @@ int otbTextureFunctorBase(int argc, char * argv[])
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef itk::ConstNeighborhoodIterator<ImageType> IterType;;
typedef TextureFunctorTest<IterType, PixelType> FunctorType;
typedef TextureFunctorTest<InputPixelType, InputPixelType> FunctorType;
typedef otb::UnaryFunctorNeighborhoodWithOffsetImageFilter<ImageType, ImageType, FunctorType> UnaryFunctorNeighborhoodImageFilterType;
// Instantiating object
......
......@@ -83,10 +83,10 @@ int otbTextureImageFunction(int argc, char * argv[])
typedef itk::VariableLengthVector<double> VectorType;
typedef itk::ConstNeighborhoodIterator<ImageType> IteratorType;
/*
if(strArgv == "ENJ")
{
typedef otb::Functor::EnergyTextureFunctor<IteratorType, VectorType> FunctorType;
typedef otb::Functor::EnergyTextureFunctor<InputPixelType, InputPixelType> FunctorType;
return( generic_TextureImageFunction<ImageType, ImageType, FunctorType>(argc,argv) );
}
else if ( strArgv == "ENT" )
......@@ -173,6 +173,6 @@ int otbTextureImageFunction(int argc, char * argv[])
{
return EXIT_FAILURE;
}
*/
return EXIT_SUCCESS;
}
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