TerraLib 4.1
TePDIMMIOMatching Class Reference

Modified Moravec Interest Operator based image area matching. More...

#include <TePDIMMIOMatching.hpp>

Inheritance diagram for TePDIMMIOMatching:
TePDIAlgorithm

List of all members.

Classes

class  CalcCCorrelationMtxParams
class  ExtractLocalMaximasParams
struct  GenerateCorrelationFeaturesParams
class  LoadImageParams
struct  MaximasListNodeT

Public Types

enum  FeatMatchingMethod { NormCrossCorrMethod }

Public Member Functions

 TePDIMMIOMatching ()
 ~TePDIMMIOMatching ()
bool CheckParameters (const TePDIParameters &parameters) const
 Checks if the supplied parameters fits the requirements of each PDI algorithm implementation.

Protected Types

typedef TePDIMatrix< unsigned
char > 
MaskMatrixT
typedef std::list
< MaximasListNodeT
MaximasListT
typedef std::pair< unsigned
int, unsigned int > 
MaximasMapNodeT
typedef std::multimap< double,
MaximasMapNodeT
MaximasMapT

Protected Member Functions

bool RunImplementation ()
 Runs the current algorithm implementation.
void ResetState (const TePDIParameters &params)
 Reset the internal state to the initial state.
void moravecRepeatability (const MaximasListT &inputList, const MaximasListT &constraintList, unsigned int constraintImageWidth, unsigned int constraintImageHeight, double moravecRepeatabilityMinTolerance, double moravecReSampleFactor, MaximasListT &outputList)
 Applies a Moravec repeatability constraint over an image maximas list.
bool matchFeatures (FeatMatchingMethod matching_method, const TePDIMatrix< double > &img1featMtx, const MaximasListT &img1_maximas_list, const TePDIMatrix< double > &img2featMtx, const MaximasListT &img2_maximas_list, TeCoordPairVect &tiePointsVec, std::vector< double > &tiePointsWeights)
 Features matching and tie-points generation.

Static Protected Member Functions

static void loadImage (void *paramsPtr)
 A job function load raster data into a simple matrix.
static void createImgMatrix (TeDataType dataType, TeSharedPtr< TePDIMtxDoubleAdptInt > &matrixPtr)
static void extractLocalMaximas (void *paramsPtr)
 Extract local interest maxima points using a Modified Moravec Interest Operator aproach.
static bool extractLocalMaximas (TePDIMtxDoubleAdptInt const *imgMatrixPtr, MaskMatrixT const *maskMatrixPtr, const unsigned int &xStart, const unsigned int &yStart, const unsigned int &width, const unsigned int &height, TePDIMatrix< double > &bufferMatrix, const unsigned int &moravecWindowSize, const unsigned int &maximasNumber, MaximasListT &outMaximasList, TePDIPIManager &progress)
 Extract local interest maxima points from an sub-image sub-region using a Modified Moravec Interest Operator aproach.
static void generateCorrelationFeatures (void *paramsPtr)
 Generate correlation features.
static void calcCCorrelationMtx (void *paramsPtr)
 cross-correlation matrix calcule.
static void matrix2Tiff (const TePDIMtxDoubleAdptInt &input_matrix, const std::string &out_file_name, const MaximasListT &maxima_points=MaximasListT())
 Save the output matrix to a geotiff file.
static void matrix2Tiff (const TePDIMtxDoubleAdptInt &input_matrix, const std::string &out_file_name, const TeCoordPairVect &tiepoints, bool usePt1)
 Save the output matrix to a geotiff file.
static void doublesMatrix2Tiff (const TePDIMatrix< double > &input_matrix, const std::string &out_file_name, const MaximasListT &maxima_points=MaximasListT())
 Save the output matrix to a geotiff file.
static void features2Tiff (unsigned int corr_window_width, const MaximasListT &img_maxima_points, TePDIMatrix< double > &img_features_matrix, const std::string &filenameaddon)
 Save the generated features to tif files.
static bool bicubicResampleMatrix (const TePDIMtxDoubleAdptInt &inputMatrix, unsigned int outLines, unsigned int outCols, bool progressEnabled, TeMutex &globalMutex, double outMinValue, double outMaxValue, TePDIMtxDoubleAdptInt &outputMatrix)
 Input matrix bicubic resample.
static bool generateMaximasRaster (const TePDIMtxDoubleAdptInt &inputMatrix, const MaximasListT &maximaPoints, TeRaster &outRaster)
 Generate the output maximas image ( 3 RGB bands where the maximas points are marked with value R255G0B0).

Protected Attributes

const double moravecDownSampleFactor_
const double moravecUpSampleFactor_
const double moravecRepeatabilityMinTolerance_
TeThreadJobsManager jobsMan_
TeMutex globalMutex_

Detailed Description

Modified Moravec Interest Operator based image area matching.

Author:
Emiliano F. Castejon <castejon@dpi.inpe.br>.
Note:
The required parameters are:
Parameters:
input_image1_ptr(TePDITypes::TePDIRasterPtrType) - The input image 1.
input_channel1( unsigned int ) - Band to process from input_image1.
input_image2_ptr(TePDITypes::TePDIRasterPtrType) - The input image 2.
input_channel2( unsigned int ) - Band to process from input_image2.
out_tie_points_ptr( TeSharedPtr< TeCoordPairVect > ) - The output tie-points where TeCoordPair.pt1 are input_image1 matricial indexes and TeCoordPair.pt2 are input_image2 matricial indexes.
Note:
The Optional parameters are:
Parameters:
matching_method(TePDIMMIOMatching::FeatMatchingMethod) Features matching method (default: TePDIMMIOMatching::NormCrossCorrMethod).
pixel_x_relation(double) - The pixel resolution relation pixel_x_relation = img1_pixel_res_x / img2_pixel_res_x (default=1.0).
pixel_y_relation(double) - The pixel resolution relation pixel_y_relation = img1_pixel_res_y / img2_pixel_res_y (default=1.0).
gt_params( TeGTParams ) - The geometric transformation parameters to be used (if not supplied, the dafult TeGTParams will be used - affine transformation, max direct mapping error = 2 pixels, RANSACRemotion outliers remotion ).
out_gt_params_ptr( TeGTParams::pointer ) - The output parameters of internally generated geometric transformation (only valid when geometrical filtering is enabled).
input_box1( TeBox ) - Box (image matrix coords) to process from input_image1 ( the entire image will be used if no box was supplied ).
input_box2( TeBox ) - Box (image matrix coords) to process from input_image2 ( the entire image will be used if no box was supplied ).
enable_multi_thread(int) - If present (any value) a multi-threaded processing will be used. (default: multi-thread disabled).
enable_threaded_raster_read(int) - If present (any value) a multi-threaded input rasters data reading will be performed if enable_multi_thread is also enabled; Some TeDecoders do not support multi-thread so use it with caution (default: multi-threaded raster read disabled).
max_tie_points(unsigned int) - The maximum number of generated tie-points (default=1000).
skip_geom_filter(int) - If present (any value) will disable the geometric filtering ( default: geometric filtering enabled ).
enable_upsampled_filter(int) - If present (any value) will enable the upsampled image Moravec repeatability filter ( default: upsampled filtering disabled - only the downsampled image filter will be applied ).
disable_reap_filter(int) - If present (any value) will disable the image Moravec repeatability filters (upsample and downsample) ( default: filtering enabled - filter will be applied to avoid creation of tie-points over noisy areas).
corr_window_width(unsigned int) - The correlation window width used to correlate points between images (Must be an odd number, minimum 13, default: 21).
moravec_window_width(unsigned int) - The Moravec window width used to locate canditate tie-points (Must be an odd number, minimum 11, default: 11 ).
out_tie_points_weights_ptr( TeSharedPtr< std::vector< double > > ) - The output tie- points weights vector (normalized between 0 and 1).
mask_image1_ptr(TePDITypes::TePDIRasterPtrType) - Mask image 1 pointer (tie-points falling inside mask image areas marked with zeroes will not be generated; this image must have the same number of lines/columns as input_image1).
mask_image2_ptr(TePDITypes::TePDIRasterPtrType) - Mask image 2 pointer (tie-points falling inside mask image areas marked with zeroes will not be generated; this image must have the same number of lines/columns as input_image1).
disable_subimage_search(int) - If present (any value) the sub-image search will not enabled (the sub-image search improves the tie-point distribution homogeneity - default:sub-image search enabled).
out_maximas_image1_ptr(TePDITypes::TePDIRasterPtrType) - This parameters is for visualization and test purposes and if this parameter is present and the pointer is valid (pointing to a valid raster instance) the output maximas image (frim input image 1) will be generated an copied to the pointed raster (this raster will be initiated to 3 RGB bands where the maximas points are marked with value R255G0B0).
out_maximas_image2_ptr- The same as the out_maximas_image1_ptr parameter but for the second input image.
Examples:

TePDIMMIOMatching_test.cpp.


Member Typedef Documentation

typedef TePDIMatrix< unsigned char > TePDIMMIOMatching::MaskMatrixT [protected]

Mask matrix type.

typedef std::list< MaximasListNodeT > TePDIMMIOMatching::MaximasListT [protected]

Maximas list type

typedef std::pair< unsigned int, unsigned int > TePDIMMIOMatching::MaximasMapNodeT [protected]

Ordered maximas map node type

Parameters:
unsignedint (first) Column - X.
unsignedint (second) Line - Y.
typedef std::multimap< double, MaximasMapNodeT > TePDIMMIOMatching::MaximasMapT [protected]

Ordered maximas map type.


Member Enumeration Documentation

Features matching methods.

Enumerator:
NormCrossCorrMethod 

Features normalized cross-correlation method


Constructor & Destructor Documentation

TePDIMMIOMatching::TePDIMMIOMatching ( )
TePDIMMIOMatching::~TePDIMMIOMatching ( )

Member Function Documentation

bool TePDIMMIOMatching::bicubicResampleMatrix ( const TePDIMtxDoubleAdptInt inputMatrix,
unsigned int  outLines,
unsigned int  outCols,
bool  progressEnabled,
TeMutex globalMutex,
double  outMinValue,
double  outMaxValue,
TePDIMtxDoubleAdptInt outputMatrix 
) [static, protected]

Input matrix bicubic resample.

Parameters:
inputMatrixInput matrix.
outLinesOutput number of lines.
outColsOutput number of columns.
progressEnabledProgress enabled flag.
globalMutexGlobal mutex.
outMinValueThe allowed output min value.
outMaxValueThe allowed output max value.
outputMatrixOutput matrix.
Returns:
true if OK, false on errors.
void TePDIMMIOMatching::calcCCorrelationMtx ( void *  paramsPtr) [static, protected]

cross-correlation matrix calcule.

Parameters:
paramsPtrThe parameters needed for the thread execution (a pointer to a CalcCCorrelationMtxParams struct).
bool TePDIMMIOMatching::CheckParameters ( const TePDIParameters parameters) const [virtual]

Checks if the supplied parameters fits the requirements of each PDI algorithm implementation.

Note:
Error log messages must be generated. No exceptions generated.
Parameters:
parametersThe parameters to be checked.
Returns:
true if the parameters are OK. false if not.

Implements TePDIAlgorithm.

void TePDIMMIOMatching::createImgMatrix ( TeDataType  dataType,
TeSharedPtr< TePDIMtxDoubleAdptInt > &  matrixPtr 
) [static, protected]

Instantiate an image matrix capable of store pixel data of the supplied type.

Parameters:
dataTypePixel type.
matrixPtrA pointer for the new created matrix.
void TePDIMMIOMatching::doublesMatrix2Tiff ( const TePDIMatrix< double > &  input_matrix,
const std::string out_file_name,
const MaximasListT maxima_points = MaximasListT() 
) [static, protected]

Save the output matrix to a geotiff file.

Parameters:
input_matrixInput matrix.
out_file_nameOutput file name.
maxima_pointsThe maxima points to be filled with 255
bool TePDIMMIOMatching::extractLocalMaximas ( TePDIMtxDoubleAdptInt const *  imgMatrixPtr,
MaskMatrixT const *  maskMatrixPtr,
const unsigned int &  xStart,
const unsigned int &  yStart,
const unsigned int &  width,
const unsigned int &  height,
TePDIMatrix< double > &  bufferMatrix,
const unsigned int &  moravecWindowSize,
const unsigned int &  maximasNumber,
MaximasListT outMaximasList,
TePDIPIManager progress 
) [static, protected]

Extract local interest maxima points from an sub-image sub-region using a Modified Moravec Interest Operator aproach.

Parameters:
imgMatrixPtrInput image matrix pointer.
maskMatrixPtrInput mask matrix pointer (or null if mask is not used).
xStartImage sub-region initial X coordinate.
yStartImage sub-region initial y coordinate.
widthImage sub-region width.
heightImage sub-region height.
bufferMatrixPre-initiated buffer with at least width x height.
moravecWindowSizeMoravec window size
maximasNumberThe number of maximas to append to outMaximasMap.
outMaximasListThe found maximas will be appended to this container.
progresProgress interface manager reference.
returntrue if OK, false on errors.
void TePDIMMIOMatching::extractLocalMaximas ( void *  paramsPtr) [static, protected]

Extract local interest maxima points using a Modified Moravec Interest Operator aproach.

Parameters:
paramsPtrThe parameters needed for the thread execution (a pointer to a ExtractLocalMaximasParams struct).
void TePDIMMIOMatching::features2Tiff ( unsigned int  corr_window_width,
const MaximasListT img_maxima_points,
TePDIMatrix< double > &  img_features_matrix,
const std::string filenameaddon 
) [static, protected]

Save the generated features to tif files.

Parameters:
corr_window_widthThe correlation windows width.
img_maxima_pointsThe image maxima points (these are the correlation matrix centers).
img_features_matrixThe output image features matrix ( each line is a stacked version of one rotated correlation window ). A string to be appended to the file name of each feature file.
Returns:
true if OK, false on errors.
void TePDIMMIOMatching::generateCorrelationFeatures ( void *  paramsPtr) [static, protected]

Generate correlation features.

Parameters:
paramsPtrThe parameters needed for the thread execution (a pointer to a ExtractLocalMaximasParams struct).
bool TePDIMMIOMatching::generateMaximasRaster ( const TePDIMtxDoubleAdptInt inputMatrix,
const MaximasListT maximaPoints,
TeRaster outRaster 
) [static, protected]

Generate the output maximas image ( 3 RGB bands where the maximas points are marked with value R255G0B0).

Parameters:
inputMatrixInput image data matrix.
maximaPointsInput maximas point list.
outRasterThe ouptput raster.
Returns:
true if ok, false on errors.
void TePDIMMIOMatching::loadImage ( void *  paramsPtr) [static, protected]

A job function load raster data into a simple matrix.

Parameters:
paramsPtrThe parameters needed for the thread execution (a pointer to a LoadImageParams struct).
bool TePDIMMIOMatching::matchFeatures ( FeatMatchingMethod  matching_method,
const TePDIMatrix< double > &  img1featMtx,
const MaximasListT img1_maximas_list,
const TePDIMatrix< double > &  img2featMtx,
const MaximasListT img2_maximas_list,
TeCoordPairVect tiePointsVec,
std::vector< double > &  tiePointsWeights 
) [protected]

Features matching and tie-points generation.

Parameters:
matching_methodFeatures matching method.
img1featMtxImage 1 features matrix.
img1_maximas_listImage 1 maximas list.
img2featMtxImage 2 features matrix.
img2_maximas_listImage 2 maximas list.
tiePointsVecOutput tie-points vector.
tiePointsWeightsOutput tie-points weights vector ( normalized between DBL_MIN and 1 ).
Returns:
true if OK, false on errors.
void TePDIMMIOMatching::matrix2Tiff ( const TePDIMtxDoubleAdptInt input_matrix,
const std::string out_file_name,
const TeCoordPairVect tiepoints,
bool  usePt1 
) [static, protected]

Save the output matrix to a geotiff file.

Parameters:
input_matrixInput matrix.
out_file_nameOutput file name.
tiepointsThe tie oints to be filled with 255
usePt1Use pt1 from tiepoints, otherwise use pt1
void TePDIMMIOMatching::matrix2Tiff ( const TePDIMtxDoubleAdptInt input_matrix,
const std::string out_file_name,
const MaximasListT maxima_points = MaximasListT() 
) [static, protected]

Save the output matrix to a geotiff file.

Parameters:
input_matrixInput matrix.
out_file_nameOutput file name.
maxima_pointsThe maxima points to be filled with 255
void TePDIMMIOMatching::moravecRepeatability ( const MaximasListT inputList,
const MaximasListT constraintList,
unsigned int  constraintImageWidth,
unsigned int  constraintImageHeight,
double  moravecRepeatabilityMinTolerance,
double  moravecReSampleFactor,
MaximasListT outputList 
) [protected]

Applies a Moravec repeatability constraint over an image maximas list.

Parameters:
inputListOriginal image maximas list.
constraintListConstraint list.
constraintImageWidthConstraint image width.
constraintImageHeightConstraint image height.
moravecRepeatabilityMinToleranceError tolerance (pixels)
  • constraint image reference.
moravecReSampleFactorMoravec resample factor (factor = inputList_scal / constraintList_scale).
outputListOutput maximas list from input list.
void TePDIMMIOMatching::ResetState ( const TePDIParameters params) [protected, virtual]

Reset the internal state to the initial state.

Parameters:
paramsThe new parameters referente at initial state.

Implements TePDIAlgorithm.

bool TePDIMMIOMatching::RunImplementation ( ) [protected, virtual]

Runs the current algorithm implementation.

Returns:
true if OK. false on error.

Implements TePDIAlgorithm.


Member Data Documentation

A global syncronization mutex.

Internal threaded jobs manager.

Moravec downsample factor = original_image / downsampled_image

Moravec repeatability tolerance

Moravec upsample factor = original_image / upsampled_image


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines