25 #ifndef __TERRALIB_RP_INTERNAL_SKELETON_H
26 #define __TERRALIB_RP_INTERNAL_SKELETON_H
30 #include "../raster/Raster.h"
31 #include "../raster/BandProperty.h"
32 #include "../raster/RasterFactory.h"
33 #include "../raster/Grid.h"
34 #include "../common/progress/TaskProgress.h"
36 #include <boost/thread.hpp>
105 void reset() throw( te::rp::Exception );
111 AbstractParameters* clone() const;
135 void reset() throw( te::rp::Exception );
141 AbstractParameters* clone() const;
149 bool execute( AlgorithmOutputParameters& outputParams ) throw( te::rp::Exception );
152 void reset() throw( te::rp::Exception );
157 bool isInitialized() const;
193 ApplyVecDiffusionThreadParams&
operator=(
const ApplyVecDiffusionThreadParams& other )
232 bool getGradientMaps(
234 const bool unitVectors,
244 template<
typename MatrixElementT >
252 if( ! output.
reset( nRows,nCols ) )
255 const unsigned int lastRowIdx = nRows - 1;
256 const unsigned int lastColIdx = nCols - 1;
257 unsigned int row = 0;
258 unsigned int col = 0;
259 unsigned int nextRow = 0;
260 unsigned int nextCol = 0;
261 unsigned int prevRow = 0;
262 unsigned int prevCol = 0;
264 for( row = 0 ; row < nRows ; ++row )
266 output[ row ][ 0 ] = input[ row ][ 0 ];
267 output[ row ][ lastColIdx ] = input[ row ][ lastColIdx ];
270 for( col = 0 ; col < nCols ; ++col )
272 output[ 0 ][ col ] = input[ 0 ][ col ];
273 output[ lastRowIdx ][ col ] = input[ lastRowIdx ][ col ];
276 for( row = 1 ; row < lastRowIdx ; ++row )
281 for( col = 1 ; col < lastColIdx ; ++col )
286 output[ row ][ col ] =
288 input[ row ][ prevCol ]
289 + input[ row ][ nextCol ]
290 + input[ prevRow ][ prevCol ]
291 + input[ prevRow ][ col ]
292 + input[ prevRow ][ nextCol ]
293 + input[ nextRow ][ prevCol ]
294 + input[ nextRow ][ col ]
295 + input[ nextRow ][ nextCol ]
310 template<
typename MatrixElementT >
325 if( ! magnitude.
reset( nRows,nCols ) )
329 unsigned int row = 0;
330 unsigned int col = 0;
334 for( row = 0 ; row < nRows ; ++row )
336 for( col = 0 ; col < nCols ; ++col )
338 xValue = xMap[ row ][ col ];
339 yValue = yMap[ row ][ col ];
341 magnitude[ row ][ col ] = std::sqrt( ( xValue * xValue ) +
342 ( yValue * yValue ) );
356 bool getEdgeStrengthMap(
368 void createTifFromVecField(
372 const unsigned int vecPixelStep,
373 const std::string& tifFileName )
const;
384 bool applyVecDiffusion(
401 bool createSkeletonStrengthMap(
412 static void applyVecDiffusionThreadEntry( ApplyVecDiffusionThreadParams* paramsPtr);
te::rp::Matrix< double > const * m_initialXBufPtr
A pointer to the input buffer initial X component.
Skeleton::InputParameters m_inputParameters
Input execution parameters.
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output registered raster.
double m_diffusionRegularization
The diffusion regularization parameter.
unsigned int m_firstRowIdx
First row to process.
te::rst::Raster const * m_inputMaskRasterPtr
A pointer to an input raster (where pixels with zero velues will be ignored) or an null pointer if no...
unsigned int m_lastRowIdx
Last row to process.
bool applyMeanSmooth(const te::rp::Matrix< MatrixElementT > &input, te::rp::Matrix< MatrixElementT > &output) const
Apply a mean filter.
double m_diffusionRegularization
A regularization parameter to control the variation from one iteration to the next one (higher values...
Raster Processing algorithm base interface class.
te::rp::Matrix< double > const * m_inputMagBufPtr
A pointer to the input magnitude buffer.
te::rp::Matrix< double > * m_outputMagBufPtr
A pointer to the output magnitude buffer.
double * m_currentIterationResiduePtr
A pointer the the current iteration residue;.
unsigned int getLinesNumber() const
The number of current matrix lines.
te::rp::Matrix< double > const * m_inputBufYPtr
A pointer to the input buffer Y component.
ApplyVecDiffusionThreadParams & operator=(const ApplyVecDiffusionThreadParams &other)
ApplyVecDiffusionThreadParams(const ApplyVecDiffusionThreadParams &other)
Raster Processing algorithm base interface.
Skeleton output parameters.
bool m_enableMultiThread
Enable (true) the use of threads.
~ApplyVecDiffusionThreadParams()
te::rst::Raster const * m_inputRasterPtr
Input raster.
boost::mutex * m_mutexPtr
A pointer to the sync mutex.
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
te::rp::Matrix< double > * m_outputBufXPtr
A pointer to the output buffer X component.
te::rp::Matrix< double > const * m_initialYBufPtr
A pointer to the input buffer initial Y component.
te::rp::Matrix< double > const * m_inputBufXPtr
A pointer to the input buffer X component.
bool m_enableProgress
Enable/Disable the progress interface (default:false).
unsigned int m_diffusionMaxIterations
The maximum number of iterations to perform (zero: no iterations limit).
Skeleton input parameters.
unsigned int getColumnsNumber() const
The number of current matrix columns.
double m_skeletonThreshold
A threshold to select those pixels as being part of the final skeleton - valid range [0...
Raster Processing algorithm output parameters base interface.
void reset()
Reset (clear) the active instance data.
bool m_isInitialized
Tells if this instance is initialized.
An abstract class for raster data strucutures.
This class can be used to inform the progress of a task.
Creation of skeleton images.
ApplyVecDiffusionThreadParams()
unsigned int m_inputRasterBand
Bands to process from the input raster.
te::rp::Matrix< double > * m_outputBufYPtr
A pointer to the output buffer X component.
double m_diffusionThreshold
A threshold over the residue from one iteration to another, if the residue drops below this value the...
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Raster Processing algorithm input parameters base interface.
bool getMagnitude(const te::rp::Matrix< double > &xMap, const te::rp::Matrix< double > &yMap, te::rp::Matrix< MatrixElementT > &magnitude) const
Generate the magnitude map from the input vectors.