Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

prapi::texture::CircularLocalSampler< T, U > Class Template Reference

#include <CircularLocalSampler.h>

Inheritance diagram for prapi::texture::CircularLocalSampler< T, U >:

prapi::ImageTransform< T, U > List of all members.

Detailed Description

template<class T, class U>
class prapi::texture::CircularLocalSampler< T, U >

CircularLocalSampler is a common superclass for all image transforms that work with a circular neighborhood.

"Circular neighborhood" is used to denote a situation where, instead of the traditional rectangular one, neighborhood pixels are defined to be the ones that lie at a certain distance from the center. The distance is also called "predicate". The number of samples at this distance and the predicate itself can be dynamically changed. In digital images, all pixels in a circular neighborhood do not necessarily match the pixel grid. Pixel values at these positions are obtained with bilinear interpolation or, if the interpolation flag is set to false, from the pixel nearest to the exact position.


Public Methods

 CircularLocalSampler (unsigned int samples, double predicate)
 Create a new CircularLocalSampler instance.

 CircularLocalSampler (unsigned int samples=8, unsigned int predicate=1, bool interpolated=true)
 Create a new CircularLocalSampler instance.

virtual ~CircularLocalSampler ()
void setPredicate (double p)
 Set the predicate value.

void setPredicate (unsigned int p)
 Set the predicate value, i.e.

void setPredicate (int p)
 Set the predicate value.

double getPredicate (void)
 Get the radius of the circular neighborhood.

void setInterpolated (bool intp)
 Set the interpolation flag.

bool isInterpolated (void)
 Get the interpolation flag.

void setSamples (unsigned int samples)
 Set the number of samples in the circular neighborhood.

unsigned int getSamples ()
 Get the number of samples in the circular neighborhood.

void setNeighborhood (unsigned int samples, double predicate)
 Set the parameters of the circular neighborhood.

void setNeighborhood (unsigned int samples, unsigned int predicate)
 Set the parameters of the circular neighborhood.

virtual T getValue (U center, util::List< U > &surrounding)
 Subclasses must implement this method to return a transformed value for a center pixel given a known circular neighborhood.

virtual util::Matrix< T > getTransformedImage (const util::Matrix< U > &mat) throw (ImageTransformException&)
 Goes through each matrix pixel, calculates the neighborhood values using the defined sample count and predicate, either with or without interpolation.

double getStartAngle () const
 Get the angle at which the first neighbor is located.

void setStartAngle (double angle)
 Set the angle of the first neighbor point.


Protected Methods

void updatePoints (void)
 Update the precalculated point value tables.


Protected Attributes

double _dPredicate
 The current predicate (radius), i.e.

unsigned int _uiPredicate
 The predicate rounded to the closest integer larger than _dPredicate.

bool _bInterpolated
 The interpolation flag.

unsigned int _uiSamples
 The number of samples in the local neighborhood.

double _dStartAngle
 The angle of the first neighbor.

prapi::graphics::Point< int > * _pPoints
 A precalculated table of interpolation points.

prapi::graphics::Point< double > * _pOffsets
 A precalculated table of interpolation offsets.

double * _dpMultipliers
 Precalculated values for interpolation multiplication.


Constructor & Destructor Documentation

template<class T, class U>
prapi::texture::CircularLocalSampler< T, U >::CircularLocalSampler unsigned int    samples,
double    predicate
 

Create a new CircularLocalSampler instance.

Make sure the compiler understands you are giving the predicate as a floating point value. Otherwise, it may have difficulties in detecting whether this or the other constructor should be used. Example:

 new CircularLocalSampler<int,int>(8,1.0);
 
Parameters:
predicate  the sampling radius
samples  the number of samples in the circular neighborhood

template<class T, class U>
prapi::texture::CircularLocalSampler< T, U >::CircularLocalSampler unsigned int    samples = 8,
unsigned int    predicate = 1,
bool    interpolated = true
 

Create a new CircularLocalSampler instance.

Make sure the compiler understands you are giving the predicate as an unsigned integer Otherwise, it may have difficulties in detecting whether this or the other constructor should be used. Example:

 new CircularLocalSampler<int,int>(8,1u);
 
Parameters:
samples  the number of samples in the circular neighborhood
predicate  the sampling radius
interpolated  if true, bilinear interpolation is in use. Otherwise, nearest neighbor is used.


Member Function Documentation

template<class T, class U>
double prapi::texture::CircularLocalSampler< T, U >::getStartAngle   const [inline]
 

Get the angle at which the first neighbor is located.

Angle is represented as radians in counter-clockwise direction. The direction of the positive x axis is 0. This value defaults to 0.

template<class T, class U>
util::Matrix< T > prapi::texture::CircularLocalSampler< T, U >::getTransformedImage const util::Matrix< U > &    mat throw (ImageTransformException&) [virtual]
 

Goes through each matrix pixel, calculates the neighborhood values using the defined sample count and predicate, either with or without interpolation.

For each neighborhood, calls getValue(U, List<U>&) and stores the returned value into the transformed matrix. The size of the resulting matrix is smaller than the input due to border effects. If you set the radius of the neighborhood to 3, the width and height of the result matrix will be 4 (=(3-1)*2) pixels smaller than those of the input.

Parameters:
mat  the input matrix
Returns:
the transformed matrix

Implements prapi::ImageTransform< T, U >.

Reimplemented in prapi::texture::GeneralLBP< T >, and prapi::texture::LBP8.

template<class T, class U>
virtual T prapi::texture::CircularLocalSampler< T, U >::getValue   center,
util::List< U > &    surrounding
[inline, virtual]
 

Subclasses must implement this method to return a transformed value for a center pixel given a known circular neighborhood.

The default implementation returns 0. This method is called for each pixel in an matrix from getTransformedImage(Matrix<U>&). For example, the local variance operator returns the variance of the values in surrounding. LBP, in turn, compares each value in surrounding to the value of the center pixel, and builds up a binary code that it then returns.

Parameters:
center  the value of the current center pixel
surrounding  the values of the surrounding pixels starting from horizontal x-axis direction (3 o'clock) and proceeding clockwise. The length of this list is equal to the number of samples set with the setSamples() method.
Returns:
a transformed value for the center pixel.

Reimplemented in prapi::texture::Contrast, prapi::texture::OpponentColorLBP< T >, and prapi::texture::Variance.

template<class T, class U>
void prapi::texture::CircularLocalSampler< T, U >::setInterpolated bool    intp [inline]
 

Set the interpolation flag.

Parameters:
intp  if true, points that do not match pixels exactly are interpolated. If false, nearest pixels are used.

template<class T, class U>
void prapi::texture::CircularLocalSampler< T, U >::setNeighborhood unsigned int    samples,
unsigned int    predicate
[inline]
 

Set the parameters of the circular neighborhood.

Parameters:
samples  the number of neighborhood samples (e.g. 8u)
the  radius of the neighborhood (e.g. 2u)

template<class T, class U>
void prapi::texture::CircularLocalSampler< T, U >::setNeighborhood unsigned int    samples,
double    predicate
[inline]
 

Set the parameters of the circular neighborhood.

Parameters:
samples  the number of neighborhood samples (e.g. 8u)
the  radius of the neighborhood (e.g. 1.5)

template<class T, class U>
void prapi::texture::CircularLocalSampler< T, U >::setPredicate int    p [inline]
 

Set the predicate value.

This will update the precalculated point table.

Parameters:
p  the new predicate. Must be larger than 0.

template<class T, class U>
void prapi::texture::CircularLocalSampler< T, U >::setPredicate unsigned int    p [inline]
 

Set the predicate value, i.e.

the radius of the neighborhood. This will update the precalculated point table. Example:

 sampler.setPredicate(3u);
 
Parameters:
p  the new predicate. Must be larger than 0.

template<class T, class U>
void prapi::texture::CircularLocalSampler< T, U >::setPredicate double    p [inline]
 

Set the predicate value.

This will update the precalculated point table. Example:

 sampler.setPredicate(3u);
 
Parameters:
p  the new predicate. Must be larger than 0.

template<class T, class U>
void prapi::texture::CircularLocalSampler< T, U >::setSamples unsigned int    samples
 

Set the number of samples in the circular neighborhood.

The precalculated point table will be updated.

Reimplemented in prapi::texture::LBP8.


Member Data Documentation

template<class T, class U>
double prapi::texture::CircularLocalSampler< T, U >::_dPredicate [protected]
 

The current predicate (radius), i.e.

the distance of the neighborhood from its center.


The documentation for this class was generated from the following file:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.