DGtal  0.9.4beta
Public Types | Public Member Functions | Private Attributes
DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue > Class Template Reference

#include <DGtal/kernel/BasicPointFunctors.h>

Collaboration diagram for DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >:
[legend]

Public Types

typedef TDomain::Space Space
 
typedef TDomain::Size Size
 
typedef Space::Dimension Dimension
 
typedef Space::Point Point
 

Public Member Functions

 BasicDomainSubSampler (const TDomain &aSourceDomain, const std::vector< TValue > &aGridSize, const Point &aGridShift)
 
Point operator() (const Point &aPoint) const
 
const TDomain & getSubSampledDomain ()
 

Private Attributes

TDomain mySourceDomain
 
TDomain myNewDomain
 
TDomain myGridSampleDomain
 
Point myGridShift
 
std::vector< TValue > myGridSize
 

Detailed Description

template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
class DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >

Aim: Functor that subsamples an initial domain by given a grid size and a shift vector. By this way, for a given point considered in a new domain, it allows to recover the point coordinates in the source domain. Such functor can be usefull to apply basic image subsampling in any dimensions by using ImageAdapter class.

Description of template class 'BasicDomainSubSampler'

See also
tests/kernel/testBasicPointFunctors.cpp
Template Parameters
TDomainthe type of the domain.
TIntegerspecifies the integer number type used to define the space.
TValuespecify the type of the value which define the grid size (generally type int (default) when subsampling with large grid size and double to re sampling with grid size less than 1).
Examples:
images/imageBasicSubsampling.cpp.

Definition at line 589 of file BasicPointFunctors.h.

Member Typedef Documentation

template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
typedef Space::Dimension DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::Dimension

Definition at line 594 of file BasicPointFunctors.h.

template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
typedef Space::Point DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::Point

Definition at line 595 of file BasicPointFunctors.h.

template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
typedef TDomain::Size DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::Size

Definition at line 593 of file BasicPointFunctors.h.

template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
typedef TDomain::Space DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::Space

Definition at line 592 of file BasicPointFunctors.h.

Constructor & Destructor Documentation

template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::BasicDomainSubSampler ( const TDomain &  aSourceDomain,
const std::vector< TValue > &  aGridSize,
const Point aGridShift 
)
inline

Constructor. Construct the functor from a source domain, a grid size, and a shift vector. The points of the resulting domain are defined as the upper left of the sampling grid.

Parameters
aSourceDomainthe source domain.
aGridSizethe subsampling grid size.
aGridShiftthe shift applied to the sampling grid.

Definition at line 608 of file BasicPointFunctors.h.

References DGtal::PointVector< dim, Integer >::diagonal(), DGtal::SpaceND< dim, TInteger >::dimension, DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridSampleDomain, DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridSize, and DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myNewDomain.

609  : mySourceDomain(aSourceDomain),
610  myGridShift(aGridShift),
611  myGridSize(aGridSize)
612  {
613  Point domainUpperBound=aSourceDomain.upperBound();
614  Point domainLowerBound=aSourceDomain.lowerBound();
615 
616  for (Dimension dim=0; dim< Space::dimension; dim++){
617  domainLowerBound[dim] /= aGridSize[dim];
618  domainUpperBound[dim] /= aGridSize[dim];
619  }
620  myNewDomain = TDomain(domainLowerBound,
621  domainUpperBound);
622  Point upperGrid;
623  for (Dimension dim=0; dim < Space::dimension; dim++)
624  upperGrid[dim] = myGridSize[dim];
625  myGridSampleDomain = TDomain(Point::diagonal(0), upperGrid);
626  };
static const Dimension dimension
static constants to store the dimension.
Definition: SpaceND.h:132
static Self diagonal(Component val=1)

Member Function Documentation

template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
const TDomain& DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::getSubSampledDomain ( )
inline

This method can be usefull to directely recover the new domain associated to the resulting subsampled domain.

Returns
the new subsampled domain.

Definition at line 675 of file BasicPointFunctors.h.

References DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myNewDomain.

675  {
676  return myNewDomain;
677  }
template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
Point DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::operator() ( const Point aPoint) const
inline

The operator computes the coordinates of the point in the subsampled domain. By default it returns the first lower point of the window associated to the sampling grid. If the resulting point is outside the source domain it scans this window and returns a point belonging to the source domain. If such a point does not exits it return the point with null coordinates.

Parameters
aPointa point which should belong to the new domain.
Returns
the point to be taken in the subsampled domain.

Definition at line 643 of file BasicPointFunctors.h.

References DGtal::PointVector< dim, Integer >::diagonal(), DGtal::SpaceND< dim, TInteger >::dimension, DGtal::Trace::error(), DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridSampleDomain, DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridShift, DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridSize, DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myNewDomain, DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::mySourceDomain, and DGtal::trace.

644  {
645  Point ptRes = Point::diagonal(0);
646  if(!myNewDomain.isInside(aPoint)){
647  trace.error() << " The point is not in the source domain: "<< aPoint << std::endl;
648  return ptRes;
649  }
650 
651  for (Dimension dim=0; dim< Space::dimension; dim++){
652  ptRes[dim] = static_cast<TInteger>(floor(NumberTraits<TInteger>::castToDouble(aPoint[dim])*
653  NumberTraits<TValue>::castToDouble(myGridSize[dim])));
654  }
655  ptRes +=myGridShift;
656 
657  if(!mySourceDomain.isInside(ptRes)){
658  // we are looking for a point inside the domain
659  for(typename TDomain::ConstIterator it = myGridSampleDomain.begin();
660  it!= myGridSampleDomain.end(); it++){
661  if (mySourceDomain.isInside(ptRes+(*it)))
662  return ptRes+(*it);
663  }
664  }
665  return ptRes;
666  }
static const Dimension dimension
static constants to store the dimension.
Definition: SpaceND.h:132
Trace trace
Definition: Common.h:137
static Self diagonal(Component val=1)
static double castToDouble(const TInteger &aT)
Definition: NumberTraits.h:154
std::ostream & error()

Field Documentation

template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
TDomain DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridSampleDomain
private
template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
Point DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridShift
private
template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
std::vector<TValue> DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridSize
private
template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
TDomain DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myNewDomain
private
template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
TDomain DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::mySourceDomain
private

The documentation for this class was generated from the following file: