Ask Your Question

GRAFFAGE's profile - activity

2019-03-03 04:43:30 -0500 received badge  Popular Question (source)
2018-01-06 10:10:44 -0500 received badge  Student (source)
2012-08-13 02:39:47 -0500 received badge  Editor (source)
2012-08-13 02:38:07 -0500 asked a question How to interpolate the gaps in a pic?

Hi, thanks to previous question, I managed to control pics with buffers for FISH EYE EFFECT. But here I have another problem. The following code results an image with "black lines" like gap between certain pixels. I want to fill the gap with interpolation method like bicubic, linear etc.

        dstMat = new Mat(srcMat.size(),srcMat.type());      

        byte[] srcBuf = new byte[(int) srcMat.total() * srcMat.channels()];
        byte[] dstBuf = new byte[(int) dstMat.total() * dstMat.channels()];
        int cols = srcMat.cols();
        int rows = srcMat.rows();
        int hcols = cols/2;
        int hrows = rows/2;
        int channels = srcMat.channels();

        // Fish eye main routine
        srcMat.get(0, 0, srcBuf);
        for (int y=0;y<rows;y++) {
           for (int x=0;x<cols;x++) {
               double max = Math.sqrt(Math.pow(hcols,2) + Math.pow(hrows,2));
               double r = Math.sqrt(Math.pow((x-hcols),2) + Math.pow((y-hrows),2))/max;
               double rg = Math.pow(r, 0.8);
               vx = (int)((x-hcols)*rg/r + hcols + 0.5);
               vy = (int)((y-hrows)*rg/r + hrows + 0.5);

               if (vx >= 0 && vx < cols && vy >= 0 && vy < rows)
                   for (int i = 0; i <= 2; i++){
                       dstBuf[vy * cols * channels + 3 * vx + i] = srcBuf[y * cols * channels + 3 * x + i];
                   }
           }
        }
        dstMat.put(0, 0, dstBuf);

How to interpolate the image with these method? Actually I know remap method, but I dont know how to handle it...

Thanks in advance, graffage

2012-08-01 19:59:08 -0500 received badge  Supporter (source)
2012-08-01 17:58:00 -0500 received badge  Scholar (source)
2012-08-01 12:44:55 -0500 commented answer How to translate this to Java?

Thanks a lot for your quite fast comments and fruitful info! They help me a lot. Im trying that way and also checking the link. If I need any other help, please let me ask you again.
Thanks again,

graffage

2012-08-01 07:37:58 -0500 asked a question How to translate this to Java?

Now I am studying openCV with Java(not so familier to Java and C++ though...), following C++ documentations online as well as textbooks of C++. I am trying to make a "fisheye lens effect" following the C++ code in a textbook, but I stuck completely.

How to translate the following code to Java?

Especially, I don't exactly understand the part around <uchar>. That seems like pointer but in Java version, I never found this kind of part...

for (int y=0; y<srcMat.rows; y++){
  for (int x=0; x<srcMat.cols; x++){
    for(int i=0;i<=2; i++){
         // vx and vy are int that represent other positions
         dstMat.at<uchar>(y, 3*x+i) = srcMat.at<uchar>(vy, 3*vx+i) 
    }
  }
}