入力画像を魚眼レンズのように処理するプログラミングが本に載っていたのですが、
この関数では、どういった処理をしているのかよくわからないです。
なので、わかる方がいましたら説明をお願いしたいです。
void
toycamera_fisheye(cv::Mat img_src, cv::Mat img_dst, int weight)
{
int vx, vy;
double hcols = img_src.cols / 2.0, hrows = img_src.rows / 2.0;
double max = sqrt(pow(hcols, 2) + pow(hrows, 2));
for (int y = 0; y<img_src.rows; y++){
for (int x = 0; x<img_src.cols; x++){
double r = sqrt(pow((x - hcols), 2) + pow((y - hrows), 2)) / max;
double rg = pow(r, (double)weight / 100.0);
vx = (int)((x - hcols) * rg / r + hcols + 0.5);
vy = (int)((y - hrows) * rg / r + hrows + 0.5);
if (0 <= vx && vx < img_src.cols && 0 <= vy && vy < img_src.rows){
for (int i = 0; i <= 2; i++)
img_dst.at<uchar>(y, 3 * x + i) = img_src.at<uchar>(vy, 3 * vx + i);
}
}
}
}