25 #ifndef __TERRALIB_RP_INTERNAL_TIEPOINTSLOCATOR_H
26 #define __TERRALIB_RP_INTERNAL_TIEPOINTSLOCATOR_H
30 #include "../raster/Raster.h"
31 #include "../raster/Interpolator.h"
32 #include "../geometry/GeometricTransformation.h"
33 #include "../geometry/GTParameters.h"
34 #include "../sam/rtree.h"
35 #include "../common/progress/TaskProgress.h"
42 #include <boost/thread.hpp>
43 #include <boost/shared_ptr.hpp>
171 void reset() throw( te::rp::Exception );
177 AbstractParameters* clone() const;
199 void reset() throw( te::rp::Exception );
205 AbstractParameters* clone() const;
213 bool execute( AlgorithmOutputParameters& outputParams ) throw( te::rp::Exception );
216 void reset() throw( te::rp::Exception );
221 bool isInitialized() const;
258 : m_x( 0 ), m_y( 0 ), m_feature1( 0 ), m_feature2( 0 ),
275 const InterestPointT&
operator=(
const InterestPointT& other )
314 m_point1( point1 ), m_point2( point2 ),
315 m_feature( feature ) {};
490 const double raster1XRescFact,
491 const double raster1YRescFact,
492 const double raster2XRescFact,
493 const double raster2YRescFact,
496 std::vector< double >& tiePointsWeights )
497 throw( te::rp::Exception );
523 const double raster1XRescFact,
524 const double raster1YRescFact,
525 const double raster2XRescFact,
526 const double raster2YRescFact,
529 std::vector< double >& tiePointsWeights )
530 throw( te::rp::Exception );
565 static bool loadRasterData(
567 const std::vector< unsigned int >& rasterBands,
569 const unsigned int maskRasterBand,
570 const unsigned int rasterTargetAreaLineStart,
571 const unsigned int rasterTargetAreaColStart,
572 const unsigned int rasterTargetAreaWidth,
573 const unsigned int rasterTargetAreaHeight,
574 const double rescaleFactorX,
575 const double rescaleFactorY,
577 const unsigned char maxMemPercentUsage,
578 std::vector< boost::shared_ptr< FloatsMatrix > >& loadedRasterData,
600 static bool locateMoravecInterestPoints(
603 const unsigned int moravecWindowWidth,
604 const unsigned int maxInterestPoints,
605 const unsigned int enableMultiThread,
606 InterestPointsSetT& interestPoints );
625 bool locateSurfInterestPoints(
628 InterestPointsSetT& interestPoints )
const;
651 template<
typename BufferElementT >
653 const unsigned int& bufferLinesNumber )
656 assert( bufferLinesNumber );
658 unsigned int idx = 0;
659 BufferElementT* auxLinePtr = bufferPtr[ 0 ];
660 const unsigned int lastLineIdx = bufferLinesNumber - 1;
662 for( idx = 0 ; idx < lastLineIdx ; ++idx )
664 bufferPtr[ idx ] = bufferPtr[ idx + 1 ];
667 bufferPtr[ lastLineIdx ] = auxLinePtr;
679 template<
typename BufferElementT >
681 const unsigned int& bufferLinesNumber,
const unsigned int&
684 BufferElementT* linePtr = 0;
685 unsigned int col = 0;
686 for(
unsigned int line = 0 ; line < bufferLinesNumber ; ++line )
688 linePtr = bufferPtr[ line ];
689 for( col = 0 ; col < bufferColsNumber ; ++col )
705 static void createTifFromMatrix(
706 const DoublesMatrix& rasterData,
707 const InterestPointsSetT& interestPoints,
708 const std::string& tifFileName );
721 static bool applyGaussianFilter(
722 const DoublesMatrix& inputData,
723 DoublesMatrix& outputData,
724 const unsigned int iterationsNumber );
737 static bool applyMeanFilter(
738 const FloatsMatrix& inputData,
739 FloatsMatrix& outputData,
740 const unsigned int iterationsNumber );
753 static bool createIntegralImage(
754 const FloatsMatrix& inputData,
755 FloatsMatrix& outputData );
772 static bool generateCorrelationFeatures(
773 const InterestPointsSetT& interestPoints,
774 const unsigned int correlationWindowWidth,
775 const FloatsMatrix& rasterData,
776 FloatsMatrix& features,
777 InterestPointsSetT& validInteresPoints );
792 static bool generateSurfFeatures(
793 const InterestPointsSetT& interestPoints,
794 const FloatsMatrix& integralRasterData,
795 InterestPointsSetT& validInterestPoints,
796 FloatsMatrix& features );
807 static void features2Tiff(
808 const DoublesMatrix& features,
809 const InterestPointsSetT& interestPoints,
810 const std::string& fileNameBeginning );
833 static bool executeMatchingByCorrelation(
834 const FloatsMatrix& featuresSet1,
835 const FloatsMatrix& featuresSet2,
836 const InterestPointsSetT& interestPointsSet1,
837 const InterestPointsSetT& interestPointsSet2,
838 const unsigned int maxPt1ToPt2PixelDistance,
839 const unsigned int enableMultiThread,
840 const double minAllowedAbsCorrelation,
841 MatchedInterestPointsSetT& matchedPoints );
848 static void executeMatchingByCorrelationThreadEntry(
849 ExecuteMatchingByCorrelationThreadEntryParams* paramsPtr);
872 static bool executeMatchingByEuclideanDist(
873 const FloatsMatrix& featuresSet1,
874 const FloatsMatrix& featuresSet2,
875 const InterestPointsSetT& interestPointsSet1,
876 const InterestPointsSetT& interestPointsSet2,
877 const unsigned int maxPt1ToPt2PixelDistance,
878 const double maxEuclideanDist,
879 const unsigned int enableMultiThread,
880 MatchedInterestPointsSetT& matchedPoints );
888 static void executeMatchingByEuclideanDistThreadEntry(
889 ExecuteMatchingByEuclideanDistThreadEntryParams* paramsPtr);
896 template <
typename ElementT >
899 std::cout << std::endl;
901 for(
unsigned int line = 0 ; line < matrix.
getLinesNumber() ; ++line )
903 std::cout << std::endl <<
"[";
908 std::cout << matrix( line, col );
914 std::cout << std::endl;
926 static void printBuffer(
double** buffer,
const unsigned int nLines,
927 const unsigned int nCols );
942 template<
typename BufferType >
944 const unsigned int& upperLeftX,
const unsigned int& upperLeftY,
945 const unsigned int& lowerRightX,
const unsigned int& lowerRightY )
947 return buffer[ lowerRightY ][ lowerRightX ]
948 - ( ( upperLeftY ) ? buffer[ upperLeftY - 1 ][ lowerRightX ] : 0 )
949 - ( ( upperLeftX ) ? buffer[ lowerRightY ][ upperLeftX - 1 ] : 0 )
950 + ( ( ( upperLeftX != 0 ) && ( upperLeftY != 0 ) ) ? buffer[ upperLeftY - 1 ][ upperLeftX - 1 ] : 0 );
967 const unsigned int& centerX,
const unsigned int& centerY,
968 const unsigned int& lobeWidth,
const unsigned int& lobeRadius )
973 ( centerX + 1 - lobeWidth ),
974 ( centerY - lobeWidth - lobeRadius ),
975 ( centerX + lobeWidth - 1 ),
976 ( centerY + lobeWidth + lobeRadius ) )
980 ( centerX + 1 - lobeWidth ),
981 ( centerY - lobeRadius ),
982 ( centerX + lobeWidth - 1 ),
983 ( centerY + lobeRadius ) ) );
1000 const unsigned int& centerX,
const unsigned int& centerY,
1001 const unsigned int& lobeWidth,
const unsigned int& lobeRadius )
1006 ( centerX - lobeWidth - lobeRadius ),
1007 ( centerY + 1 - lobeWidth ),
1008 ( centerX + lobeWidth + lobeRadius ),
1009 ( centerY + lobeWidth - 1 ) )
1013 ( centerX - lobeRadius ),
1014 ( centerY + 1 - lobeWidth ),
1015 ( centerX + lobeRadius ),
1016 ( centerY + lobeWidth - 1 ) );
1031 const unsigned int& centerX,
const unsigned int& centerY,
1032 const unsigned int& lobeWidth )
1038 ( centerX - lobeWidth ),
1039 ( centerY - lobeWidth ),
1048 ( centerX + lobeWidth ),
1049 ( centerY + lobeWidth ) )
1055 ( centerY - lobeWidth ),
1056 ( centerX + lobeWidth ),
1062 ( centerX - lobeWidth ),
1065 ( centerY + lobeWidth ) );
1079 template<
typename BufferType >
1081 const unsigned int& centerX,
const unsigned int& centerY,
1082 const unsigned int& radius )
1088 ( centerY - radius ),
1089 ( centerX + radius ),
1090 ( centerY + radius ) )
1094 ( centerX - radius ),
1095 ( centerY - radius ),
1097 ( centerY + radius ) );
1111 template<
typename BufferType >
1113 const unsigned int& centerX,
const unsigned int& centerY,
1114 const unsigned int& radius )
1119 ( centerX - radius ),
1120 ( centerY - radius ),
1121 ( centerX + radius ),
1126 ( centerX - radius ),
1128 ( centerX + radius ),
1129 ( centerY + radius ) );
1139 return (
unsigned int)std::pow( 2.0, (
double)(octaveIndex + 1) );
1149 return 3 + ( 3 * getSurfOctaveFilterStepSize( octaveIndex ) );
1160 const unsigned int& scaleIndex )
1162 return getSurfOctaveBaseFilterSize( octaveIndex ) +
1163 ( 3 * ( getSurfOctaveFilterStepSize( octaveIndex ) * scaleIndex ) );
~MoravecLocatorThreadParams()
static float getSurfDxyDerivative(float **bufferPtr, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &lobeWidth)
Return a SURF box filter Dxy derivative centered over the given position from the given integral imag...
The parameters passed to the matchCorrelationEuclideanThreadEntry method.
static unsigned int getSurfOctaveFilterStepSize(const unsigned int &octaveIndex)
Return the surf octave filter step size (width).
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
The generated tie-pionts (te::gm::GTParameters::TiePoint::first are raster 1 line/column indexes...
unsigned int m_x
Point X coord.
static unsigned int getSurfOctaveBaseFilterSize(const unsigned int &octaveIndex)
Return the surf octave base filter size (width).
ExecuteMatchingByEuclideanDistThreadEntryParams()
boost::mutex * m_syncMutexPtr
ExecuteMatchingByCorrelationThreadEntryParams()
~MatchedInterestPointsT()
float m_feature
Matched interest feature.
InterestPointT(const InterestPointT &other)
boost::mutex * m_rastaDataAccessMutexPtr
A pointer to a valid mutex to controle raster data access.
unsigned int m_y
Point Y coord.
~ExecuteMatchingByEuclideanDistThreadEntryParams()
std::multiset< InterestPointT > InterestPointsSetT
std::list< InterestPointT > InterestPointsListT
unsigned int m_maxPt1ToPt2Distance
Zero (disabled) or the maximum distance between a point from set 1 to a point from set 1 (points beyo...
InterestPointT const * m_interestPointsSet1Ptr
This class can be used to inform the progress of a task.
InterestPointT m_point2
Interest point 2.
Raster Processing algorithm output parameters base interface.
boost::mutex * m_interestPointsAccessMutexPtr
A pointer to a valid mutex to control the output interest points container access.
static void zeroFillBuffer(BufferElementT **bufferPtr, const unsigned int &bufferLinesNumber, const unsigned int &bufferColsNumber)
Fill a buffer with zeroes.
unsigned int m_maxRasterLinesBlockMaxSize
The maximum lines number of each raster block to process.
InterestPointT const * m_interestPointsSet2Ptr
unsigned int m_maxInterestPointsPerRasterLinesBlock
The maximum number of points to find for each raster lines block.
unsigned int m_octavesNumber
The number of octaves to generate (minimum:1).
unsigned int m_scalesNumber
Thread return value pointer.
bool operator<(const InterestPointT &other) const
boost::mutex * m_rastaDataAccessMutexPtr
A pointer to a valid mutex to controle raster data access.
SurfLocatorThreadParams()
InterestPointT m_point1
Interest point 1.
static float getSurfDyyDerivative(float **bufferPtr, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &lobeWidth, const unsigned int &lobeRadius)
Return a SURF box filter Dxx derivative centered over the given position from the given integral imag...
static void printMatrix(const te::rp::Matrix< ElementT > &matrix)
Print the given matrix to std::out.
Raster Processing algorithm base interface.
unsigned int * m_nextRasterLinesBlockToProcessValuePtr
A pointer to a valid counter to control the blocks processing sequence.
MatchedInterestPointsT(const MatchedInterestPointsT &other)
TiePointsLocator::InputParameters m_inputParameters
TiePointsLocator input execution parameters.
InterestPointT const * m_interestPointsSet2Ptr
std::auto_ptr< te::gm::GeometricTransformation > m_transformationPtr
The generated geometric transformation with the base mininum required tie-points set ( depending on t...
const MatchedInterestPointsT & operator=(const MatchedInterestPointsT &other)
An abstract class for raster data strucutures.
unsigned int m_maxPt1ToPt2Distance
Zero (disabled) or the maximum distance between a point from set 1 to a point from set 1 (points beyo...
std::multiset< MatchedInterestPointsT > MatchedInterestPointsSetT
unsigned int getColumnsNumber() const
The number of current matrix columns.
static float getIntegralBoxSum(BufferType &buffer, const unsigned int &upperLeftX, const unsigned int &upperLeftY, const unsigned int &lowerRightX, const unsigned int &lowerRightY)
Return a sum of all pixels inside a box over the given integral image buffer.
MatchedInterestPointsT(const InterestPointT &point1, const InterestPointT &point2, const float &feature)
static unsigned int getSurfFilterSize(const unsigned int &octaveIndex, const unsigned int &scaleIndex)
Return the surf octave filter size (width).
unsigned int * m_nextRasterLinesBlockToProcessValuePtr
A pointer to a valid counter to control the blocks processing sequence.
The parameters passed to the executeMatchingByEuclideanDistThreadEntry method.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
InterestPointsSetT * m_interestPointsPtr
A pointer to a valid interest points container.
FloatsMatrix const * m_featuresSet1Ptr
Raster Processing algorithm base interface class.
~ExecuteMatchingByCorrelationThreadEntryParams()
unsigned int m_maxInterestPointsPerRasterLinesBlock
The maximum number of points to find for each raster lines block for each scale.
unsigned int * m_nextFeatureIdx1ToProcessPtr
TiePointsLocator output parameters.
boost::mutex * m_syncMutexPtr
float m_feature3
Interest point feature 3 value.
boost::mutex * m_interestPointsAccessMutexPtr
A pointer to a valid mutex to control the output interest points container access.
bool m_isInitialized
Tells if this instance is initialized.
float m_feature2
Interest point feature 2 value.
Method
Allowed interpolation methods.
bool operator<(const MatchedInterestPointsT &other) const
InterestPointsSetT * m_interestPointsPtr
A pointer to a valid interest points container.
UCharsMatrix const * m_maskRasterDataPtr
The loaded mask raster data pointer (or zero if no mask is avaliable).
float m_feature1
Interest point feature 1 value.
A generic template matrix.
unsigned int m_moravecWindowWidth
Thread return value pointer.
FloatsMatrix * m_corrMatrixPtr
FloatsMatrix const * m_featuresSet2Ptr
FloatsMatrix const * m_rasterDataPtr
The loaded raster data.
UCharsMatrix const * m_maskRasterDataPtr
The loaded mask raster data pointer (or zero if no mask is avaliable).
unsigned int m_maxRasterLinesBlockMaxSize
The maximum lines number of each raster block to process.
FloatsMatrix const * m_featuresSet2Ptr
static void roolUpBuffer(BufferElementT **bufferPtr, const unsigned int &bufferLinesNumber)
RoolUp a buffer of lines.
FloatsMatrix * m_distMatrixPtr
InterestPointT const * m_interestPointsSet1Ptr
unsigned int getLinesNumber() const
The number of current matrix lines.
FloatsMatrix const * m_featuresSet1Ptr
~SurfLocatorThreadParams()
static float getSurfDxxDerivative(float **bufferPtr, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &lobeWidth, const unsigned int &lobeRadius)
Return a SURF box filter Dyy derivative centered over the given position from the given integral imag...
FloatsMatrix const * m_integralRasterDataPtr
The integral image raster data.
static float getHaarXVectorIntensity(BufferType &buffer, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &radius)
Return a Haar X intesity vector for the window centered at the given point.
const InterestPointT & operator=(const InterestPointT &other)
The parameters passed to the surfLocatorThreadEntry method.
static float getHaarYVectorIntensity(BufferType &buffer, const unsigned int ¢erX, const unsigned int ¢erY, const unsigned int &radius)
Return a Haar Y intesity vector for the window centered at the given point.
MoravecLocatorThreadParams()
unsigned int * m_nextFeatureIdx1ToProcessPtr
The parameters passed to the moravecLocatorThreadEntry method.