어파인 변환

$\begin{cases} x' = f_{1}(x, y) \\ y' = f_{2}(x, y) \end{cases}$

어파인 변환

https://drive.google.com/uc?id=1wbDAOEPT_wUCsGN_ll3ObpHl7kOy0EtQ

$\begin{cases} x' = f_{1}(x, y) = ax + by + c \\ y' = f_{2}(x, y) = dx + ey + f \end{cases}$

$\left( \begin{array}{rr} x' \\ y' \end{array} \right) = \left( \begin{array}{rr} a & b \\ d & e \end{array} \right) \left( \begin{array}{rr} x \\ y \end{array} \right) + \left( \begin{array}{rr} c \\ f \end{array} \right)$

$\left( \begin{array}{rr} x' \\ y' \end{array} \right) = \left( \begin{array}{rrr} a & b & c \\ d & e & f \end{array} \right) \left( \begin{array}{rrr} x \\ y \\ 1 \end{array} \right)$

https://drive.google.com/uc?id=12T0HosWBsVGvi-sQfvhh-7z2Hi_bqrSU

Mat src = imread("tekapo.bmp");

if (src.empty())
{
  cerr << "Image load failed!" << endl;
  return;
}

Point2f srcPts[3], dstPts[3];
srcPts[0] = Point2f(0, 0);
srcPts[1] = Point2f(src.cols - 1, 0);
srcPts[2] = Point2f(src.cols - 1, src.rows - 1);
dstPts[0] = Point2f(50, 50);
dstPts[1] = Point2f(src.cols - 100, 100);
dstPts[2] = Point2f(src.cols - 50, src.rows - 50);

Mat M = getAffineTransform(srcPts, dstPts);

Mat dst;
warpAffine(src, dst, M, Size());

imshow("src", src);
imshow("dst", dst);