DGtal  1.3.beta
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>

Public Types

typedef TDomain::Space Space
 
typedef TDomain::Size Size
 
typedef TDomain::Integer IntergerDom
 
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 596 of file BasicPointFunctors.h.

◆ IntergerDom

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

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

611  : mySourceDomain(aSourceDomain),
612  myGridShift(aGridShift),
613  myGridSize(aGridSize)
614  {
615  Point domainUpperBound=aSourceDomain.upperBound();
616  Point domainLowerBound=aSourceDomain.lowerBound();
617 
618  for (Dimension dim=0; dim< Space::dimension; dim++){
619  domainLowerBound[dim] = static_cast<IntergerDom>(floor(NumberTraits<IntergerDom>::castToDouble(domainLowerBound[dim]) /
620  NumberTraits<TValue>::castToDouble( aGridSize[dim] )));
621  domainUpperBound[dim] = static_cast<IntergerDom>(floor(NumberTraits<IntergerDom>::castToDouble(domainUpperBound[dim]) /
622  NumberTraits<TValue>::castToDouble( aGridSize[dim] )));
623  }
624  myNewDomain = TDomain(domainLowerBound,
625  domainUpperBound);
626  Point upperGrid;
627  for (Dimension dim=0; dim < Space::dimension; dim++)
628  upperGrid[dim] = myGridSize[dim];
629  myGridSampleDomain = TDomain(Point::diagonal(0), upperGrid);
630  };

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

679  {
680  return myNewDomain;
681  }

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

Referenced by main().

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

648  {
649  Point ptRes = Point::diagonal(0);
650  if(!myNewDomain.isInside(aPoint)){
651  trace.error() << " The point is not in the source domain: "<< aPoint << std::endl;
652  return ptRes;
653  }
654 
655  for (Dimension dim=0; dim< Space::dimension; dim++){
656  ptRes[dim] = static_cast<TInteger>(floor(NumberTraits<TInteger>::castToDouble(aPoint[dim])*
658  }
659  ptRes +=myGridShift;
660 
661  if(!mySourceDomain.isInside(ptRes)){
662  // we are looking for a point inside the domain
663  for(typename TDomain::ConstIterator it = myGridSampleDomain.begin();
664  it!= myGridSampleDomain.end(); it++){
665  if (mySourceDomain.isInside(ptRes+(*it)))
666  return ptRes+(*it);
667  }
668  }
669  return ptRes;
670  }

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:
ConstIterator
MyDigitalSurface::ConstIterator ConstIterator
Definition: greedy-plane-segmentation-ex2.cpp:93
DGtal::Trace::error
std::ostream & error()
aPoint
const Point aPoint(3, 4)
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::functors::BasicDomainSubSampler::Dimension
Space::Dimension Dimension
Definition: BasicPointFunctors.h:596
dim
unsigned int dim(const Vector &z)
Definition: viewDualSurface.cpp:174
DGtal::PointVector< dim, Integer >::diagonal
static Self diagonal(Component val=1)
DGtal::functors::BasicDomainSubSampler::IntergerDom
TDomain::Integer IntergerDom
Definition: BasicPointFunctors.h:595
DGtal::SpaceND::dimension
static const Dimension dimension
static constants to store the dimension.
Definition: SpaceND.h:132
DGtal::functors::BasicDomainSubSampler::myGridSampleDomain
TDomain myGridSampleDomain
Definition: BasicPointFunctors.h:687
DGtal::NumberTraitsImpl< std::decay< T >::type >::castToDouble
static double castToDouble(const std::decay< T >::type &aT)
Cast method to double (for I/O or board export uses only).
Definition: NumberTraits.h:154
DGtal::functors::BasicDomainSubSampler::myNewDomain
TDomain myNewDomain
Definition: BasicPointFunctors.h:685
DGtal::functors::BasicDomainSubSampler::mySourceDomain
TDomain mySourceDomain
Definition: BasicPointFunctors.h:684
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::functors::BasicDomainSubSampler::myGridShift
Point myGridShift
Definition: BasicPointFunctors.h:688
DGtal::functors::BasicDomainSubSampler::myGridSize
std::vector< TValue > myGridSize
Definition: BasicPointFunctors.h:689