Ask Your Question

Priya KUMARI's profile - activity

2017-06-14 03:14:40 -0600 commented question Error with interpolation function c++

@berak. As I have understood from [Geometric transformation] (http://docs.opencv.org/2.4/modules/im...). After the image transformation or warping. There will be newly created pixels (non integer coordinates or floating coordinates). I thought those will be created between main pixels. How can we retrieve those values. Could you please explain me more specifically. my project goal is to implement Bilinear interpolation function.

2017-06-13 09:52:05 -0600 asked a question Error with interpolation function c++

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.

2017-06-12 09:23:44 -0600 commented question How to get the non-integer coordinate pixels.

@LBerger. Okay I already have read the description from that manual, but i do not really understand the purpose of that function. Is it used to get the value of non integer coordinates. Do you have any example to explain it bit easily.

2017-06-12 08:48:02 -0600 commented answer How to write this interpolate function using OpenCV?

@lovaj. I am also trying to implement the bilinear interpolation after affine transformation. Could you please tell me how did you locate the newly created subpixels??.

2017-06-12 08:40:29 -0600 commented question How to get the non-integer coordinate pixels.

@LBerger. Thank you for the reply. My project is to implement the own function for the Interpolation. Could you explain me the functionality of the " getRectSubPix ". what it gives. And Can you tell me the basic formula we use from the Bilinear interpolation gives the same accuracy as the flag in Opencv??..

2017-06-12 06:03:02 -0600 received badge  Editor (source)
2017-06-12 05:45:35 -0600 asked a question How to get the non-integer coordinate pixels.

Hallo Everyone,

I am very beginner to OpenCv as well as coding. I am using affine transformation to get the warped image and I am trying to implement the bilinear Interpolation function to remove distortion after image transformation. I have Idea on implementing the algorithm, but I do not know how to get the location of newly created pixels (non-integer coordinate pixels) or subpixels . Is there any function in opencv that detects this kind of pixels and give us location or any method that you could suggest.

Thanks in advance.

2017-06-06 10:11:01 -0600 asked a question How to use warpAffine function in openvc c++

I am very beginner to coding as well as image processing. I just need to warp an image by using affine transformation and need to see the image how it would be appeared without interpolation. Actually My goal is to implement an interpolation method (Bicubic or linear interpolation). I have only theoretical knowledge on interpolation, but coming to coding i do not know how find out the newly created images in warped image and give the calculated value in it. meanwhile i just need to see how the following function would work, but the code is unable to be run.

 Mat imgAffine, image, par;
image = imread ("/media/sf_vbox_share/ubuntushare/board.jpg",1);

par.at<double>(0,0)=  1.01121;  //p1
par.at<double>(1,0)=  0.21067 ;  //p2;
par.at<double>(0,1)= -89.69693; //p3;
par.at<double>(1,1)= - 0.11557;  //p4;
par.at<double>(0,2)= 1.44982;   //p5;
par.at<double>(1,2)= -193.66149;//p6;

  imgAffine = Mat::zeros( image.rows, image.cols,image.type());
   warpAffine(image,imgAffine,par, image.size(),INTER_LINEAR);
   namedWindow("image",WINDOW_AUTOSIZE);
               imshow("image",imgAffine);

    cvWaitKey(0);

The error is code is crashed. Can anyone tell me what mistake I have done here. Thanks in advance