26 void Setup(
const int& in_x1,
const int& in_y1,
27 const int& in_x2,
const int& in_y2,
28 const int& out_x1,
const int& out_y1,
29 const int& out_x2,
const int& out_y2);
40 inline void Out2In(
const int& out_x,
const int& out_y,
41 int& in_x,
int& in_y) {
42 in_x =
F2I(m_rct*out_x-m_rst*out_y+m_C);
43 in_y =
F2I(m_rst*out_x+m_rct*out_y+m_c);
51 const float oWidth = (float)OutImg.
Width(),
52 oHeight = (float)OutImg.
Height();
53 const int iWidth = InImg.
Width(), iHeight = InImg.
Height();
54 const int iWidthM1 = iWidth-1, iHeightM1 = iHeight-1;
56 for (
float oy = 0.0f; oy < oHeight; oy++) {
57 for (
float ox = 0.0f; ox < oWidth; ox++, pOut++) {
58 float ix = m_rct*ox-m_rst*oy+m_C;
59 float iy = m_rst*ox+m_rct*oy+m_c;
69 float dx = ix-(float)ix_i;
71 float dy = iy-(float)iy_i;
73 T *pUL = pIn+iy_i*iWidth+ix_i, *pLL, *pUR, *pLR;
74 if (ix_i == iWidthM1) pUR = pUL;
76 if (iy_i == iHeightM1) { pLL = pUL; pLR = pUR; }
77 else {pLL = pUL+iWidth; pLR = pUR+iWidth; }
78 *pOut = (T)((
float)*pUL*dx1*dy1+(float)*pUR*dx*dy1+
79 (
float)*pLL*dx1*dy+(float)*pLR*dx*dy);
#define F2I(x)
Definition: utils.h:111
void Transform(CImg< T > &InImg, CImg< T > &OutImg, const T &BGVal=0)
Definition: affine.h:50
int Width() const
Definition: img.h:135
void Out2In(const int &out_x, const int &out_y, int &in_x, int &in_y)
Definition: affine.h:40
void Setup(const int &in_x1, const int &in_y1, const int &in_x2, const int &in_y2, const int &out_x1, const int &out_y1, const int &out_x2, const int &out_y2)
Definition: affine.cpp:22
int Height() const
Definition: img.h:138
T * pBuffer()
Definition: img.h:148
CAffine()
Definition: affine.cpp:12