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

nomsg

parent 738ca16a
Branches
Tags
No related merge requests found
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkMeanImageFunction.h,v $
Language: C++
Date: $Date: 2003/09/10 14:29:15 $
Version: $Revision: 1.7 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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.
=========================================================================*/
#ifndef _otbComplexMomentImageFunction_h
#define _otbComplexMomentImageFunction_h
#include "itkImageFunction.h"
#include "itkNumericTraits.h"
#include <complex>
#include <cmath>
namespace otb
{
/**
* \class ComplexMomentImageFunction
* \brief Calculate the complex moment value in the full image.
*
* Calculate the complex moment value over an image.
* The implemented equation is:
*
* \f$ C_{p,q}=\int\int_{} (x+iy)^{p} \cdot (x-iy)^{q} \cdot f(x,y) \cdot
dx \cdot dy \f$
*
* With:
* + \f$(x,y)$f\ pixel localization;
* + \f$ f(x,y) $f\ the pixel value over the \f$(x,y)$f\ coordinate.
*
* This class is templated over the input image type and the
* coordinate representation type (e.g. float or double).
*
* \ingroup ImageFunctions
*/
template <class TInputImage, class TCoordRep = float >
class ITK_EXPORT ComplexMomentImageFunction :
public itk::ImageFunction< TInputImage,
std::complex<float>,
TCoordRep >
{
public:
/** Standard class typedefs. */
typedef ComplexMomentImageFunction Self;
typedef itk::ImageFunction<TInputImage,std::complex<float>, TCoordRep> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Run-time type information (and related methods). */
itkTypeMacro(MeanImageFunction, itk::ImageFunction);
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** InputImageType typedef support. */
typedef TInputImage InputImageType;
/** OutputType typdef support. */
typedef typename Superclass::OutputType OutputType;
/** Index typedef support. */
typedef typename Superclass::IndexType IndexType;
/** Dimension of the underlying image. */
itkStaticConstMacro(ImageDimension, unsigned int,
InputImageType::ImageDimension);
typedef std::complex<float> ComplexType;
/** Evaluate the function */
virtual ComplexType Evaluate( );
itkSetMacro(p, unsigned int);
itkGetConstReferenceMacro(p, unsigned int);
itkSetMacro(q, unsigned int);
itkGetConstReferenceMacro(q, unsigned int);
protected:
ComplexMomentImageFunction();
~ComplexMomentImageFunction(){};
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
ComplexMomentImageFunction( const Self& ); //purposely not implemented
void operator=( const Self& ); //purposely not implemented
// unsigned int m_NeighborhoodRadius;
unsigned int m_p;
unsigned int m_q;
};
} // namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbComplexMomentImageFunction.txx"
#endif
#endif
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkMeanImageFunction.txx,v $
Language: C++
Date: $Date: 2004/12/12 22:07:24 $
Version: $Revision: 1.12 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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.
=========================================================================*/
#ifndef _otbComplexMomentImageFunction_txx
#define _otbComplexMomentImageFunction_txx
#include "otbComplexMomentImageFunction.h"
#include "itkNumericTraits.h"
#include "itkConstNeighborhoodIterator.h"
namespace otb
{
/**
* Constructor
*/
template <class TInputImage, class TCoordRep = float >
ComplexMomentImageFunction<TInputImage>
::ComplexMomentImageFunction()
{
m_p = 0;
m_q = 0;
}
/**
*
*/
template <class TInputImage, class TCoordRep = float >
void
ComplexMomentImageFunction<TInputImage,TCoordRep>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
this->Superclass::PrintSelf(os,indent);
os << indent << " p indice value: " << m_p << std::endl;
os << indent << " q indice value: " << m_q << std::endl;
}
/**
*
*/
template <class TInputImage, class TCoordRep = float >
typename ComplexMomentImageFunction<TInputImage,TCoordRep>
::RealType
ComplexMomentImageFunction<TInputImage,TCoordRep>
::Evaluate()
{
ComplexType Sum;
ComplexType valA;
ComplexType valB;
typename InputImageType::IndexType IndexValue;
Sum = NumericTraits<ComplexType>::Zero;
if( !this->GetInputImage() )
{
return ( NumericTraits<ComplexType>::max() );
}
ConstNeighborhoodIterator<InputImageType>
it(this->GetInputImage(), this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
it.GoToBegin();
while (!it.IsAtEnd())
{
IndexValue = is.GetIndex();
valA = ( complex(IndexValue[0], IndexValue[1]) ) ^ (m_p) ;
valB = ( complex(IndexValue[0],-IndexValue[1]) ) ^ (m_q) ;
sum += valA * valB * static_cast<complex>( it.Get() );
}
return ( sum );
}
} // namespace otb
#endif
......@@ -116,6 +116,8 @@ public:
typedef typename IntImageType::Pointer IntImagePointer;
typedef typename IntImageType::ConstPointer IntImageConstPointer;
typedef typename IntImageType::IndexType IntImageIndexType;
typedef typename IntImageType::PixelType IntImagePixelType;
typedef itk::Image<float,2> RealImageType;
......@@ -162,8 +164,8 @@ protected:
itkSetMacro(MinArea, int);
itkGetConstReferenceMacro(MinArea, int);
char Is_local_min(RealImagePointer ou, int x, int y, char b8Connected);
char Is_local_max(RealImagePointer ou, int x, int y, char b8Connected);
char Is_local_min(int x, int y, char b8Connected);
char Is_local_max(int x, int y, char b8Connected);
void Levelize(PointPlaneListType tabPoints,int iNbPoints, float newGray);
unsigned char Configuration(int x,int y);
ShapeType* NewShape(int iCurrentArea, float currentGrayLevel, char bOfInferiorType,ShapeType* pChild);
......@@ -172,15 +174,13 @@ protected:
ConnectionListType* tabConnections,ShapeType* pSmallestShape);
void NewConnection(PointPlaneType* pPoint,float level,ConnectionListType* tabConnections);
int NEIGHBOR_NOT_STORED(int x,int y);
void Store_4neighbors(int x,int y,NeighborhoodType* pNeighborhood);
void Store_8neighbors(int x,int y,NeighborhoodType* pNeighborhood);
char AddIsoLevel(PointPlaneListType tabPointsInShape,int* pCurrentArea,
float currentGrayLevel,NeighborhoodType* pNeighborhood,
void Store_4neighbors(int x,int y);
void Store_8neighbors(int x,int y);
char AddIsoLevel(int* pCurrentArea, float currentGrayLevel,
char* p8Connected,char* pIgnoreHoles);
void FindTerminalBranch(int x,int y, char b8Connected,
NeighborhoodType* pNeighborhood,
ConnectionListType* tabConnections);
void Scan(NeighborhoodType* pNeighborhood,ConnectionListType* tabConnections);
ConnectionListType* tabConnections);
virtual void Scan(ConnectionListType* tabConnections);
private:
......@@ -198,7 +198,7 @@ private:
int m_Exploration;
IntImagePointer m_VisitedPixels;
RealImagePointer m_PixelOutput;
NeighborhoodType* m_Neighborhood;
NeighborhoodType m_Neighborhood;
ConnectionListType* m_Connections;
ShapeTreePointer m_GlobalTree;
PointPlaneListType m_PointsInShape;
......
This diff is collapsed.
......@@ -84,6 +84,7 @@ const void TreeNeighborhood::SWAP(int k,int l)
m_tabPoints[0] = m_tabPoints[k];
m_tabPoints[k] = m_tabPoints[l];
m_tabPoints[l] = m_tabPoints[0];
// m_tabPoints[k].swap(m_tabPoints[l]);
}
const int TreeNeighborhood::ORDER_MAX2(int k,int l)
......@@ -174,8 +175,19 @@ void TreeNeighborhood::Add(int x, int y,float value)
return;
/* 2) Add the point in the heap and update it */
m_NbPoints++;
m_tabPoints[m_NbPoints].x = x;
m_tabPoints[m_NbPoints].x = y;
// m_tabPoints.resize(m_NbPoints+1);
// PointType PointToInsert;
// PointToInsert.x = x;
// PointToInsert.y = y;
// PointToInsert.value = value ;
// m_tabPoints.push_back(PointToInsert);
// std::cout<< "m_NbPoints" << m_NbPoints << std::endl;
// assert(m_NbPoints <=m_Width*m_Height);
m_tabPoints[m_NbPoints].x = x;
m_tabPoints[m_NbPoints].y = y;
m_tabPoints[m_NbPoints].value = value;
this->FixUp(); /* Update the heap of neighbors */
......@@ -192,6 +204,7 @@ void TreeNeighborhood::Remove()
if(m_type == INVALID)
return;
m_NbPoints--;
valueTop = m_tabPoints[m_NbPoints--].value;
if(m_NbPoints == 0)
return;
......
......@@ -69,6 +69,10 @@ ADD_TEST(feTuTestFLST ${FEATUREEXTRACTION_TESTS}
otbTestFlst
${INPUTDATA}/TeteAToto.png
${TEMP}/feFLST.png)
ADD_TEST(feTuComplexMomentImage ${FEATUREEXTRACTION_TESTS}
otbComplexMomentImage
${INPUTDATA}/TeteAToto.png 1 1)
#ADD_TEST(tvFEPatrick2 ${FEATUREEXTRACTION_TESTS}
# --compare-image ${TOL} ${BASELINE}/otbExtractROI_cthead1_26_97_209_100.png
......@@ -88,6 +92,7 @@ otbFlstTest.cxx
otbDrawPathList.cxx
otbDrawPath.cxx
otbDrawPathAlign.cxx
otbComplexMomentImage.cxx
)
......
/*=========================================================================
Programme : OTB (ORFEO ToolBox)
Auteurs : CS - P.Imbo
Language : C++
Date : 10 mars 2006
Version :
Role :
$Id: $
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "itkExceptionObject.h"
#include "itkImage.h"
#include "otbImageFileReader.h"
#include "otbComplexMomentImageFunction.h"
int otbComplexMomentImage( int argc, char ** argv )
{
try
{
const char * inputFilename = argv[1];
unsigned int p((unsigned int)::atoi(argv[2]));
unsigned int q((unsigned int)::atoi(argv[3]));
typedef unsigned char InputPixelType;
const unsigned int Dimension = 2;
typedef itk::Image< InputPixelType, Dimension > InputImageType;
typedef otb::ImageFileReader< InputImageType > ReaderType;
typedef otb::ComplexMomentImageFunction<InputImageType> CMType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( inputFilename );
InputImageType::ConstPointer image = reader->GetOutput();
}
catch( itk::ExceptionObject & err )
{
std::cout << "Exception itk::ExceptionObject levee !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cout << "Exception levee inconnue !" << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
......@@ -17,5 +17,6 @@ REGISTER_TEST(otbDrawPathList);
REGISTER_TEST(otbDrawPathListTracerLignes);
REGISTER_TEST(otbDrawPathDessinCarre);
REGISTER_TEST(otbDrawPathAlign);
REGISTER_TEST(otbComplexMomentImage);
}
......@@ -32,7 +32,6 @@ int otbFlstTest( int argc, char ** argv )
{
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment