My project goal is to implement own function for Bilinear interpolation after Affine transformation. As I am beginner I could not find solution to locate the non integer coordinates after the image transformation, So I did like following. It is showing error after the execution as "cannot convert 'x' (type 'double*') to type 'cv::Point' ".
int main()
{
double value =0.0 ;double i,j;
const cv::Mat img = cv::imread("/media/sf_vbox_share/ubuntushare/chess2.jpg",CV_8U);
Mat imgAffine;
Mat par(2, 3, CV_64FC1);
imgAffine = Mat::zeros( img.rows, img.cols,CV_32FC1);
par.at<double>(0,0)= 1; //p1
par.at<double>(1,0)= 0.02 ; //p2;
par.at<double>(0,1)= -0.03 ; //p3;
par.at<double>(1,1)= 1 ; //p4;
par.at<double>(0,2)= -0.001 ; //p5;
par.at<double>(1,2)= -0.005;//p6;
warpAffine(img,imgAffine,par, img.size());
namedWindow("image",WINDOW_AUTOSIZE);
imshow("image",imgAffine);
//for locating non integer coordinates..
for(i=0.0;i< imgAffine.rows ; i += 0.1)
{
for(j=0.0;j< imgAffine.cols; j+= 0.1) {
Bil_interp(imgAffine,&i,&j,&value);
}}
imshow("interpol img",imgAffine);
waitKey(0);
return 0;
}
void Bil_interp(const Mat& image, double* x, double* y, double* val)
{
int x1 = cvFloor(x);int y1 = cvFloor(y);
int x2 = x1+1;int y2 = y1+1;
double q11,q12,q21, q22;
q11 = (image.at<double>(x1,y1));
q21 = (image.at<double>(x2,y1));
q12 = (image.at<double>(x1,y2));
q22 = (image.at<double>(x2,y2));
val = ((1/( (x2-x1)*(y2-y1) ) ) *(q11*(x2-x)*(y2-y)+q21*(x2-x1)*(y2-
y) +q12*(x2-x)*(y-y1)+q22*(x-x1)*(y-y1)));
image.at<double>(x,y) = val;
}
I really do not know how to use CV::Point in the code. And I am not allowed to use interpolation flag in warpaffine function. Can anyone suggest me how to solve the problem here. How exactly we could know there are non integer coordinates after the transformation.