DGtal 1.3.0
Loading...
Searching...
No Matches
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 = typename TDomain::Size>
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 637 of file BasicPointFunctors.h.

Member Typedef Documentation

◆ Dimension

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

Definition at line 643 of file BasicPointFunctors.h.

◆ IntergerDom

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

Definition at line 642 of file BasicPointFunctors.h.

◆ Point

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

Definition at line 644 of file BasicPointFunctors.h.

◆ Size

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

Definition at line 641 of file BasicPointFunctors.h.

◆ Space

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

Definition at line 640 of file BasicPointFunctors.h.

Constructor & Destructor Documentation

◆ BasicDomainSubSampler()

template<typename TDomain , typename TInteger = DGtal::int32_t, typename TValue = typename TDomain::Size>
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 657 of file BasicPointFunctors.h.

658 : mySourceDomain(aSourceDomain),
659 myGridShift(aGridShift),
660 myGridSize(aGridSize)
661 {
662 Point domainUpperBound=aSourceDomain.upperBound();
663 Point domainLowerBound=aSourceDomain.lowerBound();
664
665 for (Dimension dim=0; dim< Space::dimension; dim++){
666 domainLowerBound[dim] = static_cast<IntergerDom>(floor(NumberTraits<IntergerDom>::castToDouble(domainLowerBound[dim]) /
668 domainUpperBound[dim] = static_cast<IntergerDom>(floor(NumberTraits<IntergerDom>::castToDouble(domainUpperBound[dim]) /
670 }
671 myNewDomain = TDomain(domainLowerBound,
672 domainUpperBound);
673 Point upperGrid;
674 for (Dimension dim=0; dim < Space::dimension; dim++)
675 upperGrid[dim] = myGridSize[dim];
676 myGridSampleDomain = TDomain(Point::diagonal(0), upperGrid);
677 };
static Self diagonal(Component val=1)
static const Dimension dimension
static constants to store the dimension.
Definition: SpaceND.h:132
static double castToDouble(const std::decay< T >::type &aT)
Cast method to double (for I/O or board export uses only).
Definition: NumberTraits.h:164
MyPointD Point
Definition: testClone2.cpp:383

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 = typename TDomain::Size>
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.
Examples
images/imageBasicSubsampling.cpp.

Definition at line 726 of file BasicPointFunctors.h.

726 {
727 return myNewDomain;
728 }

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

Referenced by main().

◆ operator()()

template<typename TDomain , typename TInteger = DGtal::int32_t, typename TValue = typename TDomain::Size>
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 694 of file BasicPointFunctors.h.

695 {
696 Point ptRes = Point::diagonal(0);
697 if(!myNewDomain.isInside(aPoint)){
698 trace.error() << " The point is not in the source domain: "<< aPoint << std::endl;
699 return ptRes;
700 }
701
702 for (Dimension dim=0; dim< Space::dimension; dim++){
703 ptRes[dim] = static_cast<TInteger>(floor(NumberTraits<TInteger>::castToDouble(aPoint[dim])*
705 }
706 ptRes +=myGridShift;
707
708 if(!mySourceDomain.isInside(ptRes)){
709 // we are looking for a point inside the domain
710 for(typename TDomain::ConstIterator it = myGridSampleDomain.begin();
711 it!= myGridSampleDomain.end(); it++){
712 if (mySourceDomain.isInside(ptRes+(*it)))
713 return ptRes+(*it);
714 }
715 }
716 return ptRes;
717 }
std::ostream & error()
Trace trace
Definition: Common.h:154
const Point aPoint(3, 4)

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 = typename TDomain::Size>
TDomain DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::myGridSampleDomain
private

◆ myGridShift

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

◆ myGridSize

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

◆ myNewDomain

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

◆ mySourceDomain

template<typename TDomain , typename TInteger = DGtal::int32_t, typename TValue = typename TDomain::Size>
TDomain DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::mySourceDomain
private

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