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>
170 void reset() throw( te::rp::Exception );
176 AbstractParameters* clone() const;
198 void reset() throw( te::rp::Exception );
204 AbstractParameters* clone() const;
212 bool execute( AlgorithmOutputParameters& outputParams ) throw( te::rp::Exception );
215 void reset() throw( te::rp::Exception );
220 bool isInitialized() const;
257 : m_x( 0 ), m_y( 0 ), m_feature1( 0 ), m_feature2( 0 ),
274 const InterestPointT&
operator=(
const InterestPointT& other )
313 m_point1( point1 ), m_point2( point2 ),
314 m_feature( feature ) {};
489 const double raster1XRescFact,
490 const double raster1YRescFact,
491 const double raster2XRescFact,
492 const double raster2YRescFact,
495 std::vector< double >& tiePointsWeights )
496 throw( te::rp::Exception );
522 const double raster1XRescFact,
523 const double raster1YRescFact,
524 const double raster2XRescFact,
525 const double raster2YRescFact,
528 std::vector< double >& tiePointsWeights )
529 throw( te::rp::Exception );
564 static bool loadRasterData(
566 const std::vector< unsigned int >& rasterBands,
568 const unsigned int maskRasterBand,
569 const unsigned int rasterTargetAreaLineStart,
570 const unsigned int rasterTargetAreaColStart,
571 const unsigned int rasterTargetAreaWidth,
572 const unsigned int rasterTargetAreaHeight,
573 const double rescaleFactorX,
574 const double rescaleFactorY,
576 const unsigned char maxMemPercentUsage,
577 std::vector< boost::shared_ptr< FloatsMatrix > >& loadedRasterData,
599 static bool locateMoravecInterestPoints(
602 const unsigned int moravecWindowWidth,
603 const unsigned int maxInterestPoints,
604 const unsigned int enableMultiThread,
605 InterestPointsSetT& interestPoints );
624 bool locateSurfInterestPoints(
627 InterestPointsSetT& interestPoints )
const;
650 template<
typename BufferElementT >
652 const unsigned int& bufferLinesNumber )
655 assert( bufferLinesNumber );
657 unsigned int idx = 0;
658 BufferElementT* auxLinePtr = bufferPtr[ 0 ];
659 const unsigned int lastLineIdx = bufferLinesNumber - 1;
661 for( idx = 0 ; idx < lastLineIdx ; ++idx )
663 bufferPtr[ idx ] = bufferPtr[ idx + 1 ];
666 bufferPtr[ lastLineIdx ] = auxLinePtr;
678 template<
typename BufferElementT >
680 const unsigned int& bufferLinesNumber,
const unsigned int&
683 BufferElementT* linePtr = 0;
684 unsigned int col = 0;
685 for(
unsigned int line = 0 ; line < bufferLinesNumber ; ++line )
687 linePtr = bufferPtr[ line ];
688 for( col = 0 ; col < bufferColsNumber ; ++col )
704 static void createTifFromMatrix(
705 const DoublesMatrix& rasterData,
706 const InterestPointsSetT& interestPoints,
707 const std::string& tifFileName );
720 static bool applyGaussianFilter(
721 const DoublesMatrix& inputData,
722 DoublesMatrix& outputData,
723 const unsigned int iterationsNumber );
736 static bool applyMeanFilter(
737 const FloatsMatrix& inputData,
738 FloatsMatrix& outputData,
739 const unsigned int iterationsNumber );
752 static bool createIntegralImage(
753 const FloatsMatrix& inputData,
754 FloatsMatrix& outputData );
771 static bool generateCorrelationFeatures(
772 const InterestPointsSetT& interestPoints,
773 const unsigned int correlationWindowWidth,
774 const FloatsMatrix& rasterData,
775 FloatsMatrix& features,
776 InterestPointsSetT& validInteresPoints );
791 static bool generateSurfFeatures(
792 const InterestPointsSetT& interestPoints,
793 const FloatsMatrix& integralRasterData,
794 InterestPointsSetT& validInterestPoints,
795 FloatsMatrix& features );
806 static void features2Tiff(
807 const DoublesMatrix& features,
808 const InterestPointsSetT& interestPoints,
809 const std::string& fileNameBeginning );
832 static bool executeMatchingByCorrelation(
833 const FloatsMatrix& featuresSet1,
834 const FloatsMatrix& featuresSet2,
835 const InterestPointsSetT& interestPointsSet1,
836 const InterestPointsSetT& interestPointsSet2,
837 const unsigned int maxPt1ToPt2PixelDistance,
838 const unsigned int enableMultiThread,
839 const double minAllowedAbsCorrelation,
840 MatchedInterestPointsSetT& matchedPoints );
847 static void executeMatchingByCorrelationThreadEntry(
848 ExecuteMatchingByCorrelationThreadEntryParams* paramsPtr);
871 static bool executeMatchingByEuclideanDist(
872 const FloatsMatrix& featuresSet1,
873 const FloatsMatrix& featuresSet2,
874 const InterestPointsSetT& interestPointsSet1,
875 const InterestPointsSetT& interestPointsSet2,
876 const unsigned int maxPt1ToPt2PixelDistance,
877 const double maxEuclideanDist,
878 const unsigned int enableMultiThread,
879 MatchedInterestPointsSetT& matchedPoints );
887 static void executeMatchingByEuclideanDistThreadEntry(
888 ExecuteMatchingByEuclideanDistThreadEntryParams* paramsPtr);
895 template <
typename ElementT >
898 std::cout << std::endl;
900 for(
unsigned int line = 0 ; line < matrix.
getLinesNumber() ; ++line )
902 std::cout << std::endl <<
"[";
907 std::cout << matrix( line, col );
913 std::cout << std::endl;
925 static void printBuffer(
double** buffer,
const unsigned int nLines,
926 const unsigned int nCols );
941 template<
typename BufferType >
943 const unsigned int& upperLeftX,
const unsigned int& upperLeftY,
944 const unsigned int& lowerRightX,
const unsigned int& lowerRightY )
946 return buffer[ lowerRightY ][ lowerRightX ]
947 - ( ( upperLeftY ) ? buffer[ upperLeftY - 1 ][ lowerRightX ] : 0 )
948 - ( ( upperLeftX ) ? buffer[ lowerRightY ][ upperLeftX - 1 ] : 0 )
949 + ( ( ( upperLeftX != 0 ) && ( upperLeftY != 0 ) ) ? buffer[ upperLeftY - 1 ][ upperLeftX - 1 ] : 0 );
966 const unsigned int& centerX,
const unsigned int& centerY,
967 const unsigned int& lobeWidth,
const unsigned int& lobeRadius )
972 ( centerX + 1 - lobeWidth ),
973 ( centerY - lobeWidth - lobeRadius ),
974 ( centerX + lobeWidth - 1 ),
975 ( centerY + lobeWidth + lobeRadius ) )
979 ( centerX + 1 - lobeWidth ),
980 ( centerY - lobeRadius ),
981 ( centerX + lobeWidth - 1 ),
982 ( centerY + lobeRadius ) ) );
999 const unsigned int& centerX,
const unsigned int& centerY,
1000 const unsigned int& lobeWidth,
const unsigned int& lobeRadius )
1005 ( centerX - lobeWidth - lobeRadius ),
1006 ( centerY + 1 - lobeWidth ),
1007 ( centerX + lobeWidth + lobeRadius ),
1008 ( centerY + lobeWidth - 1 ) )
1012 ( centerX - lobeRadius ),
1013 ( centerY + 1 - lobeWidth ),
1014 ( centerX + lobeRadius ),
1015 ( centerY + lobeWidth - 1 ) );
1030 const unsigned int& centerX,
const unsigned int& centerY,
1031 const unsigned int& lobeWidth )
1037 ( centerX - lobeWidth ),
1038 ( centerY - lobeWidth ),
1047 ( centerX + lobeWidth ),
1048 ( centerY + lobeWidth ) )
1054 ( centerY - lobeWidth ),
1055 ( centerX + lobeWidth ),
1061 ( centerX - lobeWidth ),
1064 ( centerY + lobeWidth ) );
1078 template<
typename BufferType >
1080 const unsigned int& centerX,
const unsigned int& centerY,
1081 const unsigned int& radius )
1087 ( centerY - radius ),
1088 ( centerX + radius ),
1089 ( centerY + radius ) )
1093 ( centerX - radius ),
1094 ( centerY - radius ),
1096 ( centerY + radius ) );
1110 template<
typename BufferType >
1112 const unsigned int& centerX,
const unsigned int& centerY,
1113 const unsigned int& radius )
1118 ( centerX - radius ),
1119 ( centerY - radius ),
1120 ( centerX + radius ),
1125 ( centerX - radius ),
1127 ( centerX + radius ),
1128 ( centerY + radius ) );
1138 return (
unsigned int)std::pow( 2.0, (
double)(octaveIndex + 1) );
1148 return 3 + ( 3 * getSurfOctaveFilterStepSize( octaveIndex ) );
1159 const unsigned int& scaleIndex )
1161 return getSurfOctaveBaseFilterSize( octaveIndex ) +
1162 ( 3 * ( getSurfOctaveFilterStepSize( octaveIndex ) * scaleIndex ) );
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...
boost::mutex * m_interestPointsAccessMutexPtr
A pointer to a valid mutex to control the output interest points container access.
double m_moravecMinAbsCorrelation
The minimum acceptable absolute correlation value when matching features (when applicable), default:0.5, valid range: [0,1].
unsigned int m_moravecGaussianFilterIterations
The number of noise Gaussin iterations, when applicable (used to remove image noise, zero will disable the Gaussian Filter, default:1).
~SurfLocatorThreadParams()
unsigned int m_moravecCorrelationWindowWidth
The correlation window width used to correlate points between the images (minimum 3...
unsigned int m_maxInterestPointsPerRasterLinesBlock
The maximum number of points to find for each raster lines block.
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
unsigned int m_y
Point Y coord.
std::list< InterestPointT > InterestPointsListT
~ExecuteMatchingByEuclideanDistThreadEntryParams()
bool m_enableProgress
Enable/Disable the progress interface (default:false).
static unsigned int getSurfFilterSize(const unsigned int &octaveIndex, const unsigned int &scaleIndex)
Return the surf octave filter 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_maxInterestPointsPerRasterLinesBlock
The maximum number of points to find for each raster lines block for each scale.
static unsigned int getSurfOctaveFilterStepSize(const unsigned int &octaveIndex)
Return the surf octave filter step size (width).
FloatsMatrix const * m_featuresSet2Ptr
InterestPointT const * m_interestPointsSet1Ptr
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.
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_featuresSet1Ptr
InterestPointsSetT * m_interestPointsPtr
A pointer to a valid interest points container.
te::rst::Raster const * m_inMaskRaster2Ptr
Optional one band input mask raster 2 (tie-points will not be generated inside mask image areas marke...
boost::mutex * m_rastaDataAccessMutexPtr
A pointer to a valid mutex to controle raster data access.
unsigned int m_moravecWindowWidth
The Moravec window width used to locate canditate tie-points (minimum 3, default: 5 )...
Raster Processing algorithm base interface class.
unsigned int m_raster2TargetAreaWidth
The raster 2 target area width (default:0 - The entire raster will be considered).
std::auto_ptr< te::gm::GeometricTransformation > m_transformationPtr
The generated geometric transformation with the base mininum required tie-points set ( depending on t...
unsigned int * m_nextRasterLinesBlockToProcessValuePtr
A pointer to a valid counter to control the blocks processing sequence.
unsigned int m_x
Point X coord.
InterestPointT m_point2
Interest point 2.
std::vector< unsigned int > m_inRaster1Bands
Bands to be used from the input raster 1.
FloatsMatrix const * m_integralRasterDataPtr
The integral image raster data.
MatchedInterestPointsT(const MatchedInterestPointsT &other)
bool m_enableGeometryFilter
Enable/disable the geometry filter/outliers remotion (default:true).
unsigned int m_raster2TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
float m_feature3
Interest point feature 3 value.
unsigned int getLinesNumber() const
The number of current matrix lines.
unsigned int m_maxPt1ToPt2Distance
Zero (disabled) or the maximum distance between a point from set 1 to a point from set 1 (points beyo...
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.
InterestPointsSetT * m_interestPointsPtr
A pointer to a valid interest points container.
unsigned int m_scalesNumber
Thread return value pointer.
unsigned int m_maxPt1ToPt2Distance
Zero (disabled) or the maximum distance between a point from set 1 to a point from set 1 (points beyo...
unsigned int * m_nextFeatureIdx1ToProcessPtr
boost::mutex * m_syncMutexPtr
SurfLocatorThreadParams()
unsigned int m_maxRasterLinesBlockMaxSize
The maximum lines number of each raster block to process.
Raster Processing algorithm base interface.
UCharsMatrix const * m_maskRasterDataPtr
The loaded mask raster data pointer (or zero if no mask is avaliable).
The parameters passed to the executeMatchingByEuclideanDistThreadEntry method.
~MoravecLocatorThreadParams()
MoravecLocatorThreadParams()
double m_geomTransfMaxError
The maximum allowed transformation error (pixel units, default:2).
Method
Allowed interpolation methods.
std::multiset< InterestPointT > InterestPointsSetT
boost::mutex * m_rastaDataAccessMutexPtr
A pointer to a valid mutex to controle raster data access.
double m_pixelSizeXRelation
The pixel resolution relation m_pixelSizeXRelation = raster1_pixel_res_x / raster2_pixel_res_x (defau...
ExecuteMatchingByCorrelationThreadEntryParams()
TiePointsLocator input parameters.
InterestPointT m_point1
Interest point 1.
FloatsMatrix const * m_featuresSet2Ptr
static void zeroFillBuffer(BufferElementT **bufferPtr, const unsigned int &bufferLinesNumber, const unsigned int &bufferColsNumber)
Fill a buffer with zeroes.
unsigned int m_maxR1ToR2Offset
The maximum offset (pixels units) between a raster 1 point end the respective raster 2 point (default...
unsigned int m_raster2TargetAreaLineStart
The first line of the raster 2 target area to process (default:0 - The entire raster will be consider...
ExecuteMatchingByEuclideanDistThreadEntryParams()
MatchedInterestPointsT(const InterestPointT &point1, const InterestPointT &point2, const float &feature)
float m_feature
Matched interest feature.
InteresPointsLocationStrategyType
unsigned int m_raster1TargetAreaLineStart
The first line of the raster 1 target area to process (default:0 - The entire raster will be consider...
unsigned int m_surfOctavesNumber
The number of octaves to generate, when applicable (default: 3, minimum:1).
float m_feature2
Interest point feature 2 value.
unsigned int m_raster2TargetAreaHeight
The raster 2 target area height (default:0 - The entire raster will be considered).
FloatsMatrix * m_corrMatrixPtr
unsigned int m_octavesNumber
The number of octaves to generate (minimum:1).
unsigned int m_moravecWindowWidth
Thread return value pointer.
std::string m_geomTransfName
The name of the geometric transformation used to ensure tie-points consistency (see each te::gm::GTFa...
InterestPointT const * m_interestPointsSet1Ptr
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.
InteresPointsLocationStrategyType m_interesPointsLocationStrategy
The strategy used to locate interest points (default:SurfStrategyT).
boost::mutex * m_interestPointsAccessMutexPtr
A pointer to a valid mutex to control the output interest points container access.
bool operator<(const MatchedInterestPointsT &other) const
static void roolUpBuffer(BufferElementT **bufferPtr, const unsigned int &bufferLinesNumber)
RoolUp a buffer of lines.
std::vector< unsigned int > m_inRaster2Bands
Bands to be used from the input raster 2.
The parameters passed to the matchCorrelationEuclideanThreadEntry method.
A generic template matrix.
double m_geometryFilterAssurance
Geometry assurance (the error-free selection percent assurance) - valid range (0-1) - default:0...
The parameters passed to the surfLocatorThreadEntry method.
float m_feature1
Interest point feature 1 value.
boost::mutex * m_syncMutexPtr
unsigned int getColumnsNumber() const
The number of current matrix columns.
double m_pixelSizeYRelation
The pixel resolution relation m_pixelSizeYRelation = raster1_pixel_res_y / raster2_pixel_res_y (defau...
double m_surfMaxNormEuclideanDist
The maximum acceptable euclidean distance when matching features (when applicable), default:0.5, valid range: [0,1].
InterestPointT(const InterestPointT &other)
~MatchedInterestPointsT()
te::rst::Raster const * m_inMaskRaster1Ptr
Optional one band input mask raster 1 (tie-points will not be generated inside mask image areas marke...
Raster Processing algorithm output parameters base interface.
An abstract class for raster data strucutures.
unsigned int * m_nextFeatureIdx1ToProcessPtr
This class can be used to inform the progress of a task.
unsigned int m_raster1TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
unsigned int m_maxRasterLinesBlockMaxSize
The maximum lines number of each raster block to process.
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...
unsigned int m_raster1TargetAreaWidth
The raster 1 target area width (default:0 - The entire raster will be considered).
UCharsMatrix const * m_maskRasterDataPtr
The loaded mask raster data pointer (or zero if no mask is avaliable).
te::rst::Raster const * m_inRaster1Ptr
Input raster 1.
bool m_enableMultiThread
Enable/Disable the use of multi-threads (default:true).
InterestPointT const * m_interestPointsSet2Ptr
const MatchedInterestPointsT & operator=(const MatchedInterestPointsT &other)
unsigned int m_maxTiePoints
The maximum number of tie-points to generate (default=0 - Automatically found).
static void printMatrix(const te::rp::Matrix< ElementT > &matrix)
Print the given matrix to std::out.
bool operator<(const InterestPointT &other) const
~ExecuteMatchingByCorrelationThreadEntryParams()
InterestPointT const * m_interestPointsSet2Ptr
unsigned int m_surfScalesNumber
The number of sub-sampling scales to generate, when applicable (default:4, minimum:3).
unsigned int m_raster1TargetAreaHeight
The raster 1 target area height (default:0 - The entire raster will be considered).
double m_rastersRescaleFactor
Global rescale factor to apply to all input rasters (default:1, valid range: non-zero positive values...
te::rst::Raster const * m_inRaster2Ptr
Input raster 2.
const InterestPointT & operator=(const InterestPointT &other)
std::multiset< MatchedInterestPointsT > MatchedInterestPointsSetT
static unsigned int getSurfOctaveBaseFilterSize(const unsigned int &octaveIndex)
Return the surf octave base filter size (width).
The parameters passed to the moravecLocatorThreadEntry method.
FloatsMatrix const * m_rasterDataPtr
The loaded raster data.
unsigned int * m_nextRasterLinesBlockToProcessValuePtr
A pointer to a valid counter to control the blocks processing sequence.
FloatsMatrix const * m_featuresSet1Ptr
FloatsMatrix * m_distMatrixPtr
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
TiePointsLocator::InputParameters m_inputParameters
TiePointsLocator input execution parameters.
Raster Processing algorithm input parameters base interface.
bool m_isInitialized
Tells if this instance is initialized.
TiePointsLocator output parameters.