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

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. More...

#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 590 of file BasicPointFunctors.h.

Member Typedef Documentation

◆ Dimension

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 595 of file BasicPointFunctors.h.

◆ Point

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 596 of file BasicPointFunctors.h.

◆ Size

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 594 of file BasicPointFunctors.h.

◆ Space

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 593 of file BasicPointFunctors.h.

Constructor & Destructor Documentation

◆ BasicDomainSubSampler()

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 609 of file BasicPointFunctors.h.

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

References DGtal::PointVector< dim, Integer >::diagonal(), dim(), 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.

Member Function Documentation

◆ getSubSampledDomain()

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 676 of file BasicPointFunctors.h.

676  {
677  return myNewDomain;
678  }

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

◆ operator()()

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 644 of file BasicPointFunctors.h.

645  {
646  Point ptRes = Point::diagonal(0);
647  if(!myNewDomain.isInside(aPoint)){
648  trace.error() << " The point is not in the source domain: "<< aPoint << std::endl;
649  return ptRes;
650  }
651 
652  for (Dimension dim=0; dim< Space::dimension; dim++){
653  ptRes[dim] = static_cast<TInteger>(floor(NumberTraits<TInteger>::castToDouble(aPoint[dim])*
655  }
656  ptRes +=myGridShift;
657 
658  if(!mySourceDomain.isInside(ptRes)){
659  // we are looking for a point inside the domain
660  for(typename TDomain::ConstIterator it = myGridSampleDomain.begin();
661  it!= myGridSampleDomain.end(); it++){
662  if (mySourceDomain.isInside(ptRes+(*it)))
663  return ptRes+(*it);
664  }
665  }
666  return ptRes;
667  }
const Point aPoint(3, 4)
static const Dimension dimension
static constants to store the dimension.
Definition: SpaceND.h:132
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:144
static Self diagonal(Component val=1)
static double castToDouble(const std::decay< TInteger >::type &aT)
Cast method to double (for I/O or board export uses only).
Definition: NumberTraits.h:154
MyPointD Point
Definition: testClone2.cpp:383
unsigned int dim(const Vector &z)
std::ostream & error()

References aPoint(), DGtal::PointVector< dim, Integer >::diagonal(), dim(), 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.

Field Documentation

◆ myGridSampleDomain

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

◆ myGridShift

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

◆ myGridSize

template<typename TDomain, typename TInteger = DGtal::int32_t, typename TValue = DGtal::uint32_t>
std::vector<TValue> DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridSize
private

◆ myNewDomain

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

◆ mySourceDomain

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: