Commit 6371eb51 authored by Thomas Feuvrier's avatar Thomas Feuvrier
Browse files

Fusion de la branche (branche-1.0) r1124:HEAD dans le trunk.

parent 52abf31e
......@@ -49,7 +49,7 @@ ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" MATCHES "^1\\.8$")
# OTB version number. An even minor number corresponds to releases.
SET(OTB_VERSION_MAJOR "1")
SET(OTB_VERSION_MINOR "0")
SET(OTB_VERSION_PATCH "1")
SET(OTB_VERSION_PATCH "2")
# Version string should not include patch level. The major.minor is
# enough to distinguish available features of the toolkit.
......@@ -273,8 +273,8 @@ IF(WIN32)
ENDIF(WIN32)
OPTION(BUILD_EXAMPLES "Generer les exemples." ON)
OPTION(BUILD_TESTING "Generer les tests." ON)
OPTION(BUILD_EXAMPLES "Generer les exemples." OFF)
OPTION(BUILD_TESTING "Generer les tests." OFF)
#-----------------------------------------------------------------------------
# Dispatch the build into the proper subdirectories.
......
......@@ -18,10 +18,11 @@
#include "otbSystem.h"
#include <string.h> // strdup
#include <ctype.h> //toupper, tolower
#if (defined(WIN32) || defined(WIN32CE)) && !defined(__CYGWIN__) && !defined(__MINGW32__)
#if (defined(WIN32) || defined(WIN32CE)) && !defined(__CYGWIN__)
/*=====================================================================
WIN32 / MSVC++ implementation
*====================================================================*/
......@@ -104,7 +105,31 @@ System::GetShortFileName( const std::string& filename )
return( shortFileName );
}
#if (defined(WIN32) || defined(WIN32CE)) && !defined(__CYGWIN__)
// Set to upper a string
std::string System::SetToUpper( const std::string& str )
{
std::string lString(str);
for(int i=0 ; i<lString.size() ; i++)
{
lString[i]=toupper(lString[i]);
}
return(lString);
}
// Set to lower a string
std::string System::SetToLower( const std::string& str )
{
std::string lString(str);
for(int i=0 ; i<lString.size() ; i++)
{
lString[i]=tolower(lString[i]);
}
return(lString);
}
#if (defined(WIN32) || defined(WIN32CE)) && !defined(__CYGWIN__) && !defined(__MINGW32__)
/*=====================================================================
WIN32 / MSVC++ implementation
......
......@@ -38,7 +38,7 @@ namespace otb
/** \class System
* \brief System operations.
*
* System operations, filename manipulations, etc.
* System operations, filename or strings manipulations, etc.
*
*/
class ITK_EXPORT System
......@@ -60,6 +60,10 @@ public:
static std::string GetPathName( const std::string& filename );
/** Get the short filename of the file name */
static std::string GetShortFileName( const std::string& filename );
/** Set to upper a string */
static std::string SetToUpper( const std::string& str );
/** Set to upper a string */
static std::string SetToLower( const std::string& str );
/** Get list of file find in a directory */
static std::vector<std::string> Readdir(std::string pszPath);
......
......@@ -67,9 +67,10 @@ public:
itkGetConstReferenceMacro(SigmaI, double);
itkSetMacro(Alpha,double);
itkGetConstReferenceMacro(Alpha, double);
itkSetMacro(Threshold,InputPixelType);
itkGetConstReferenceMacro(Threshold, InputPixelType);
itkSetMacro(LowerThreshold,InputPixelType);
itkGetConstReferenceMacro(LowerThreshold, InputPixelType);
itkSetMacro(UpperThreshold,InputPixelType);
itkGetConstReferenceMacro(UpperThreshold, InputPixelType);
protected:
HarrisImageToPointSetFilter();
......@@ -83,7 +84,8 @@ private:
HarrisImageToPointSetFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
InputPixelType m_Threshold;
InputPixelType m_LowerThreshold;
InputPixelType m_UpperThreshold;
double m_SigmaD;
double m_SigmaI;
double m_Alpha;
......
......@@ -34,7 +34,9 @@ HarrisImageToPointSetFilter<TInputImage, TOutputPointSet>
m_SigmaD = 1.0;
m_SigmaI = 1.0;
m_Alpha = 1.0;
m_Threshold = itk::NumericTraits<InputPixelType>::max();
m_LowerThreshold = itk::NumericTraits<InputPixelType>::NonpositiveMin();
m_UpperThreshold = itk::NumericTraits<InputPixelType>::max();
m_HarrisFilter = HarrisImageFilterType::New();
m_ThresholdFilter = ThresholdImageToPointSetType::New();
......@@ -54,7 +56,8 @@ HarrisImageToPointSetFilter<TInputImage, TOutputPointSet>
m_HarrisFilter->SetAlpha( m_Alpha );
m_ThresholdFilter->SetInput(0,m_HarrisFilter->GetOutput() );
m_ThresholdFilter->SetThreshold(m_Threshold );
m_ThresholdFilter->SetLowerThreshold(m_LowerThreshold);
m_ThresholdFilter->SetUpperThreshold(m_UpperThreshold);
m_ThresholdFilter->SetOutput(pointList );
m_ThresholdFilter->Update();
......@@ -74,7 +77,8 @@ HarrisImageToPointSetFilter<TInputImage, TOutputPointSet>
os << indent << "Sigma_D : " << this->m_SigmaD << std::endl;
os << indent << "Sigma_I : " << this->m_SigmaI << std::endl;
os << indent << "Alpha : " << this->m_Alpha << std::endl;
os << indent << "Threshold : " << this->m_Threshold << std::endl;
os << indent << "LowerThreshold : " << this->m_LowerThreshold << std::endl;
os << indent << "UpperThreshold : " << this->m_UpperThreshold << std::endl;
}
......
......@@ -123,7 +123,7 @@ protected:
virtual void GenerateOutputInformation(){}; // do nothing
virtual void GenerateData();
virtual std::vector<double> tab(int n,double p,double m);
virtual void AngleCalculate( const InputImageType* InputImageIn,RealImageTypePointer AngleImage);
virtual void AngleCalculate( const InputImageType* InputImageIn);
SizeType m_Size;
double m_Spacing[InputImageDimension];
......@@ -142,6 +142,8 @@ private:
double m_MinGradNorm; /// Minimum gradient norm to define a direction, default 2.
double m_Eps; /// -log10(max. number of false alarms), default 0
std::vector<float> m_seglist;
RealImageType * m_AngleImage; //Angle image use by GenerateData and AngleCalculate methods
};
} // end namespace otb
......
......@@ -222,7 +222,7 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath>
template <class TInputImage, class TOutputPath>
void
ImageToPathListAlignFilter<TInputImage,TOutputPath>
::AngleCalculate(const InputImageType* InputImage, RealImageTypePointer AngleImage)
::AngleCalculate(const InputImageType* InputImage)
{
float threshold;
int n,p,x,y;
......@@ -238,10 +238,10 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath>
IndexOut[1] = 0;
// region.SetIndex(InputImage->GetLargestPossibleRegion().GetIndex());
region.SetIndex(IndexOut);
AngleImage->SetRegions( region );
AngleImage->SetOrigin(InputImage->GetOrigin());
AngleImage->SetSpacing(InputImage->GetSpacing());
AngleImage->Allocate();
m_AngleImage->SetRegions( region );
m_AngleImage->SetOrigin(InputImage->GetOrigin());
m_AngleImage->SetSpacing(InputImage->GetSpacing());
m_AngleImage->Allocate();
n = Taille[0];
p = Taille[1];
......@@ -255,13 +255,13 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath>
idx[0] = (n-1) ;
idx[1] = x ;
// indice = (n-1)*p +x
AngleImage->SetPixel(idx,static_cast<RealType>(-1000.0));
m_AngleImage->SetPixel(idx,static_cast<RealType>(-1000.0));
}
for (y=0;y<n;y++){
idx[0] = y;
idx[1] = p-1;
// indice = p*y+p-1
AngleImage->SetPixel(idx,static_cast<RealType>(-1000.0));
m_AngleImage->SetPixel(idx,static_cast<RealType>(-1000.0));
}
typename InputImageType::IndexType adr;
......@@ -304,12 +304,11 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath>
norm = gx*gx + gy*gy;
if (norm <=threshold)
AngleImage->SetPixel(adr,static_cast<RealType>(-1000.0));
else AngleImage->SetPixel(adr,static_cast<RealType>(atan2(gx,-gy)));
m_AngleImage->SetPixel(adr,static_cast<RealType>(-1000.0));
else m_AngleImage->SetPixel(adr,static_cast<RealType>(atan2(gx,-gy)));
}
}
template <class TInputImage, class TOutputPath>
void
ImageToPathListAlignFilter<TInputImage,TOutputPath>
......@@ -355,8 +354,9 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath>
n = (int)ceil(hypot((double)nx,(double)ny))+1;
/*** compute angle map of u ***/
RealImageTypePointer AngleImage = RealImageType::New();
this->AngleCalculate( InputImage,AngleImage);
RealImageTypePointer lAngleImagePointer = RealImageType::New();
m_AngleImage = static_cast<RealImageType*>(lAngleImagePointer.GetPointer());
this->AngleCalculate( InputImage );
/*** compute P(k,l) ***/
test = tab(n,1.0/(double)(m_NbGradDirection),(double)(nx*ny)*(double)(nx*ny));
......@@ -430,7 +430,7 @@ ImageToPathListAlignFilter<TInputImage,TOutputPath>
assert( indexAngle[0] >= 0 );
assert( indexAngle[1] >= 0 );
error = static_cast<float>( AngleImage->GetPixel(indexAngle) );
error = static_cast<float>( m_AngleImage->GetPixel(indexAngle) );
if (error>-100.0) {
error -= theta;
while (error<=-M_PI) error += 2.0*M_PI;
......
......@@ -41,12 +41,10 @@ public:
TInputImage::ImageDimension);
typedef TInputImage InputImageType;
//typedef TOutputPointSet OutputPointSetType;
typedef ThresholdImageToPointSetFilter Self;
typedef ImageToPointSetFilter< InputImageType, TOutputPointSet> Superclass;
typedef typename Superclass::OutputPointSetType OutputPointSetType;
typedef typename Superclass::OutputPointSetType OutputPointSetType;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
......@@ -64,8 +62,10 @@ public:
typedef typename Superclass::OutputPointSetPointer OutputPointSetPointer;
typedef typename Superclass::OutputPointSetType::PixelType OutputPointSetPixelType;
itkSetMacro(Threshold,InputPixelType);
itkGetConstReferenceMacro(Threshold, InputPixelType);
itkSetMacro(LowerThreshold,InputPixelType);
itkGetConstReferenceMacro(LowerThreshold, InputPixelType);
itkSetMacro(UpperThreshold,InputPixelType);
itkGetConstReferenceMacro(UpperThreshold, InputPixelType);
protected:
ThresholdImageToPointSetFilter();
......@@ -79,7 +79,8 @@ private:
ThresholdImageToPointSetFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
InputPixelType m_Threshold;
InputPixelType m_LowerThreshold;
InputPixelType m_UpperThreshold;
};
} // end namespace otb
......
......@@ -29,7 +29,8 @@ template <class TInputImage, class TOutputPointSet>
ThresholdImageToPointSetFilter<TInputImage, TOutputPointSet>
::ThresholdImageToPointSetFilter()
{
m_Threshold = itk::NumericTraits<InputPixelType>::max();
m_LowerThreshold = itk::NumericTraits<InputPixelType>::NonpositiveMin();
m_UpperThreshold = itk::NumericTraits<InputPixelType>::max();
}
......@@ -45,29 +46,24 @@ ThresholdImageToPointSetFilter<TInputImage, TOutputPointSet>
typename OutputPointSetType::PointType position;
outputPtr->Initialize();
typedef itk::ImageRegionConstIterator<TInputImage> InputIterator;
InputIterator inIt(inputPtr, inputPtr->GetRequestedRegion() );
// walk the regions, threshold each pixel
while( !inIt.IsAtEnd() )
{
const InputPixelType value = inIt.Get();
const IndexType index = inIt.GetIndex();
if (value >= m_Threshold)
if ((value >= m_LowerThreshold) && (value <= m_UpperThreshold))
{
position[0] = index[0];
position[1] = index[1];
outputPtr->SetPoint(pointId,position);
// OutputPointSetPixelType outValue;
// outValue = itk::NumericTraits<OutputPointSetPixelType>(value);
// outputPtr->SetPointData(pointId, outValue );
pointId++;
}
......@@ -84,7 +80,8 @@ ThresholdImageToPointSetFilter<TInputImage, TOutputPointSet>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf( os, indent );
os << indent << "Threshold : " << m_Threshold << std::endl;
os << indent << "LowerThreshold : " << m_LowerThreshold << std::endl;
os << indent << "UpperThreshold : " << m_UpperThreshold << std::endl;
}
......
This diff is collapsed.
/*=========================================================================
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.
=========================================================================*/
#ifndef __otbBSQImageIO_h
#define __otbBSQImageIO_h
#include "itkImageIOBase.h"
#include <fstream>
#include <string>
#include <vector>
namespace otb
{
/** \class BSQImageIO
*
* \brief ImageIO object for reading (not writing) BSQ format images
*
* The streaming read is implemented.
*
* \ingroup IOFilters
*
*/
class ITK_EXPORT BSQImageIO : public itk::ImageIOBase
{
public:
/** Standard class typedefs. */
typedef BSQImageIO Self;
typedef itk::ImageIOBase Superclass;
typedef itk::SmartPointer<Self> Pointer;
/** Byte order typedef */
typedef Superclass::ByteOrder ByteOrder;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(BSQImageIO, itk::ImageIOBase);
/*-------- This part of the interface deals with reading data. ------ */
/** Determine the file type. Returns true if this ImageIO can read the
* file specified. */
virtual bool CanReadFile(const char*);
/** Determine the file type. Returns true if the ImageIO can stream read the specified file */
virtual bool CanStreamRead(){ return true; };
/** Set the spacing and dimention information for the set filename. */
virtual void ReadImageInformation();
/** Reads the data from disk into the memory buffer provided. */
virtual void Read(void* buffer);
/** Reads 3D data from multiple files assuming one slice per file. */
virtual void ReadVolume(void* buffer);
/*-------- This part of the interfaces deals with writing data. ----- */
/** Determine the file type. Returns true if this ImageIO can read the
* file specified. */
virtual bool CanWriteFile(const char*);
/** Determine the file type. Returns true if the ImageIO can stream write the specified file */
virtual bool CanStreamWrite() { return true; };
/** Writes the spacing and dimentions of the image.
* Assumes SetFileName has been called with a valid file name. */
virtual void WriteImageInformation();
/** Writes the data to disk from the memory buffer provided. Make sure
* that the IORegion has been set properly. */
virtual void Write(const void* buffer);
void SampleImage(void* buffer,int XBegin, int YBegin, int SizeXRead, int SizeYRead, int XSample, int YSample);
protected:
/** Construtor.*/
BSQImageIO();
/** Destructor.*/
~BSQImageIO();
bool OpenOneraDataFileForReading(const char* filename);
bool OpenOneraHeaderFileForReading(const char* filename);
void InternalReadImageInformation();
bool OpenOneraDataFileForWriting(const char* filename);
bool OpenOneraHeaderFileForWriting(const char* filename);
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
BSQImageIO(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
/** Internal method to read header informations */
bool InternalReadHeaderInformation(const std::string & file_name, std::fstream & file, const bool reportError);
#define otbSwappFileOrderToSystemOrderMacro(StrongType, buffer, buffer_size) \
{ \
typedef itk::ByteSwapper< StrongType > InternalByteSwapperType; \
if ( m_ByteOrder != m_FileByteOrder ) \
{ \
if ( m_ByteOrder == LittleEndian ) \
{ \
InternalByteSwapperType::SwapRangeFromSystemToBigEndian( (StrongType *)buffer, buffer_size ); \
} \
else if ( m_ByteOrder == BigEndian ) \
{ \
InternalByteSwapperType::SwapRangeFromSystemToLittleEndian((StrongType *)buffer, buffer_size ); \
} \
} \
}
#define otbSwappFileToSystemMacro(StrongType, WeakType, buffer, buffer_size) \
else if ( this->GetComponentType() == WeakType ) \
{ \
otbSwappFileOrderToSystemOrderMacro( StrongType, buffer, buffer_size )\
}
#define otbSetTypeBsqMacro(WeakType, CAI_VALUE) \
else if ( this->GetComponentType() == WeakType ) \
{ \
m_TypeBsq = CAI_VALUE; \
}
bool m_FlagWriteImageInformation;
itk::ImageIOBase::ByteOrder m_FileByteOrder;
std::fstream m_HeaderFile;
std::string m_TypeBsq;
std::vector< std::string > m_ChannelsFileName;
// std::vector< std::fstream > m_ChannelsFile;
std::fstream * m_ChannelsFile;
//std::fstream file;
// char* value;
};
} // end namespace otb
#endif // __otbBSQImageIO_h
/*=========================================================================
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 "otbBSQImageIOFactory.h"
#include "itkCreateObjectFunction.h"
#include "otbBSQImageIO.h"
#include "itkVersion.h"
namespace otb
{
BSQImageIOFactory::BSQImageIOFactory()
{
this->RegisterOverride("itkImageIOBase",
"otbBSQImageIO",
"BSQ Image IO",
1,
itk::CreateObjectFunction<BSQImageIO>::New());
}
BSQImageIOFactory::~BSQImageIOFactory()
{
}
const char*
BSQImageIOFactory::GetITKSourceVersion(void) const
{
return ITK_SOURCE_VERSION;
}
const char*
BSQImageIOFactory::GetDescription() const
{
return "BSQ ImageIO Factory, permettant le chargement d'image au format BSQ dans l'OTB";
}
} // end namespace otb
/*=========================================================================
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.
=========================================================================*/
#ifndef __otbBSQImageIOFactory_h
#define __otbBSQImageIOFactory_h
#include "itkObjectFactoryBase.h"
#include "itkImageIOBase.h"
namespace otb
{
/** \class BSQImageIOFactory
* \brief Creation d'un instance d'un objet BSQImageIO utilisant les object factory.
*/
class ITK_EXPORT BSQImageIOFactory : public itk::ObjectFactoryBase
{
public:
/** Standard class typedefs. */
typedef BSQImageIOFactory Self;
typedef itk::ObjectFactoryBase Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Class methods used to interface with the registered factories. */
virtual const char* GetITKSourceVersion(void) const;
virtual const char* GetDescription(void) const;
/** Method for class instantiation. */
itkFactorylessNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(BSQImageIOFactory, itk::ObjectFactoryBase);
/** Register one factory of this type */
static void RegisterOneFactory(void)
{
BSQImageIOFactory::Pointer BSQFactory = BSQImageIOFactory::New();
itk::ObjectFactoryBase::RegisterFactory(BSQFactory);
}
protected:
BSQImageIOFactory();
~BSQImageIOFactory();
private:
BSQImageIOFactory(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
} // end namespace otb
#endif
......@@ -26,7 +26,8 @@
#include "otbONERAImageIOFactory.h"
#include "otbMSTARImageIOFactory.h"
#include "otbGDALImageIOFactory.h"
#include "otbLUMImageIOFactory.h"
#include "otbBSQImageIOFactory.h"
namespace otb
{
......@@ -52,6 +53,10 @@ ImageIOFactory::RegisterBuiltInFactories()
itk::MutexLockHolder<itk::SimpleMutexLock> mutexHolder( mutex );