0

I load the vertical and horizontal gradients into the function posted here and it calculates the sums which than make up the corner response. Why do only boarder pixels get to be found, my threshold is 0 otherwise there is 0 corners on the image. For gradients I used sobel operator.

Look at the output image below.

Output image

for (int i = 0; i < width; i++)
{
    for (int j = 0; j < height; j++)
    {
        if ((i - search_size / 2 < 0 || i + search_size / 2 > image1.rows - 1) || (j - search_size / 2 < 0 || j + search_size / 2 > image1.cols - 1)) {
            continue;
        }

        double Ix2 = 0, Iy2 = 0, Ixy = 0;

        double detM=0;
        double traceM=0;
        double R = 0;

        for (int m = i-search_size /2; m < i + search_size /2 ; m++){
            for (int n = j-search_size /2; n < j + search_size/2 ; n++){

                gauss = exp(-(((i - m) * (i - m)) + ((j - n) * (j - n))) / gaus_del);
                //Compute Ix^2 , Iy^2 and Ixy
                Ix2 += gauss*(image1.at<float>(m, n)*image1.at<float>(m, n));
                Iy2 += gauss*(image2.at<float>(m, n)*image2.at<float>(m, n));
                Ixy += gauss*(image1.at<float>(m, n)*image2.at<float>(m, n));
            }
        }



        detM = (Ix2*Iy2 - Ixy*Ixy);
        traceM = Ix2*Ix2 + Iy2*Iy2;

        R = detM / traceM;
        //cout <<i+j<< endl;
        //  std::cout << "R :" << Iy2 << endl;
        if (R > threshold)
        {
            circle(image, cv::Point2f(i, j), 3.5, cv::Scalar(255, 255, 0), 1, 5);
            cout << "corner found" << endl;
        }
    }
}

EDIT : i am using uchars now and the result looks alot better new result2

4
  • Unless you can elaborate a bit more, you're using floating point for these calculations. Floating point is not exact, and possibly this is one reason for the slight errors in the image? I certainly would not rely on floating point calculations to come up with a perfect image, unless there is code that explicitly does error corrections (I do not know if your code takes this in consideration). Dec 22, 2015 at 14:37
  • I tried other types,i tried R= det(M) - k*trace(M) also,no major change.Im not sure if i calculate the sums of gradients correctly to be more exact,thanks for your support Dec 22, 2015 at 14:42
  • If you did change the calculations to mathematically equivalent ones, and you got a slight change in the image, then indeed it looks like a floating point error issue. If that's the case, you may have to come up with a method that takes the error in consideration and corrects it (or use integers in some way instead of floating point). Don't know how easy or difficult it would be. Dec 22, 2015 at 14:46
  • Thanks,i it started finding corners on the whole image when i set it to uchar,which i didnt consider.Thanks alot friend Dec 22, 2015 at 14:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.