28 #if defined(OTC_RECURSES)
29 #error Recursive header files inclusion detected in GAVector.h
51 template<
typename TSpace,
typename TInputValue =
typename TSpace::RealPo
int,
typename TOutputValue =
typename TSpace::Po
int>
53 const std::vector< std::vector< int > >&
_table;
71 OTC(
const std::vector< std::vector< int > >& table,
73 TOutputValue c,
int W,
int H )
79 TOutputValue corner00( 0, 0 );
80 TOutputValue cornerW0( W-1, 0 );
81 TOutputValue corner0H( 0,
H-1 );
82 TOutputValue cornerWH( W-1,
H-1 );
99 n +=
rbc.circle( r ).size();
110 angle = std::round((alpha*180.0)/M_PI);
111 rbc.setAngle() = alpha;
112 std::cout <<
"OTC angle="<<
rbc.angle()<<std::endl;
121 auto pc0 =
static_cast<TOutputValue
>(p -
my_center);
125 TOutputValue pc( pc0[ 0 ], pc0[ 1 ] );
129 TOutputValue rpc = ( angle < 90 ) ? pc
130 : ( angle < 180 ) ? TOutputValue( -pc[ 1 ], pc[ 0 ] )
131 : ( angle < 270 ) ? TOutputValue( -pc[ 0 ], -pc[ 1 ] )
132 : TOutputValue( pc[ 1 ], -pc[ 0 ] );
134 auto it =
rbc.point2circle.find( rpc );
135 if ( it ==
rbc.point2circle.end() )
return static_cast<TOutputValue
>(p);
136 int in_r = it->second[ 0 ];
137 int in_i = it->second[ 1 ];
141 int in_ring = in_r <= 0 ? 0 : 1 + ( (in_r - 1) /
_dr ) *
_dr;
143 int offset =
_offset[ in_ring ];
144 for (
auto k = in_ring; k < in_r; k++ ) in_ri +=
rbc.circle( k ).size();
145 const auto& I =
_table[ angle % 90 ];
146 int out_ri = I[ offset + in_ri ];
147 auto out_r = in_ring;
149 while ( out_i >=
rbc.circle( out_r ).size() )
151 out_i -=
rbc.circle( out_r ).size();
154 TOutputValue q =
rbc.circle( out_r )[ out_i ];
155 TOutputValue r = TOutputValue( q[ 0 ] +
outSize()/2, -q[ 1 ] +
outSize()/2 );
168 for (
int y = 0; y <
_H; y++ )
169 for (
int x = 0; x <
_W; x++ )
175 template<
typename TImage>
180 typedef std::pair < typename TSpace::Point, typename TSpace::Point > Bounds;
186 MyDomainTransformer domainTransformer ( *
this );
187 Bounds bounds = domainTransformer ( img.domain() );
188 TDomain transformedDomain ( bounds.first+bottomLeft, bounds.second+topRight );
189 TImage rotatedImage ( transformedDomain );
192 rotatedImage.setValue((*this).operator()(*it),img(*it));
Aim: implements bounds of transformed domain.
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
TPointType::Coordinate distance2(TPointType p, TPointType q)
OTC : Optimal Transport through Circle bijective rotation.
TOutputValue operator()(const TInputValue &aInput) const
TOutputValue rotatePoint(TInputValue p) const
std::string tostring() const
RBC_vec< TSpace, TInputValue, TOutputValue > rbc
TImage rotateImage(const TImage &img) const
void set_angle(double alpha)
TOutputValue center() const
OTC(const std::vector< std::vector< int > > &table, int dr, TOutputValue c, int W, int H)
std::vector< int > _offset
const std::vector< std::vector< int > > & _table
RBC : Bijective Rotation through Circles.
HyperRectDomain< Space > Domain