7

As part of my Bachelor-Thesis, I'm trying to implement a corner detector with the Harris and Stephens algorithm: A combined Corner and Edge Detector

I do calculate:

  1. The x- and y- deviations with sobel Filters (3x3)
  2. Calculate the system Matrix M

    M = [A C; C B]

    which means, if I got all right:

    1. A = Response of sobel_x squared: Ix * Ix (at certain pixel)
    2. B = Response of sobel_y squared: Iy * Iy (at certain pixel)
    3. C = Response of sobel_x multiplied by response of sobel_y: Ix * Iy (at certain pixel)
  3. now I do calculate trace(M) and what I'm especially more concerned: determinant(M)

In there paper they suggest the following approximation for the determinant, as it avoids expensive calculation of the eigenvalues:

det(M) = A * B - C^2

This must always terminates in Zero!

The expression det(M) = A * B - C^2 can be rewritten as: (using the knowledge of point 2)

det(M) = A * B - C * C

det(M) = Ix*Ix * Iy*Iy - Ix*Iy * Ix*Iy

det(M) = Ix*Ix * Iy*Iy - Ix*Ix * Iy*Iy

det(M) = 0

So why should I even bother calculating the determinant? As far as I see, it is sufficent to calculate the trace! (Or did I make somewhere a major mistake?)

user1803551
  • 12,965
  • 5
  • 47
  • 74
muuh
  • 1,013
  • 12
  • 24

3 Answers3

5

Before you calculate the R, apply Gaussian kernel on Ix2, Iy2, Ixy.

hakunami
  • 2,351
  • 4
  • 31
  • 50
  • 1
    To elaborate on this: it seems like the matrix "M" should actually include the summation of gradient terms for a window around the pixel. Thus, the determinant terms should not cancel out. See this other post for more context: http://stackoverflow.com/questions/16803587/how-to-compute-the-structure-tensor-of-a-2d-array – Patrick Finnigan Apr 12 '15 at 19:48
0

Yes, it's a bit confuse. Let me try to make it a bit more clear.

As stated in some comments, Ix², and Iy² result from summing all elements in a patch around a pixel location. For example, if we take a 2×2 patch (where the subscripts 0-3 are the 4 "cells" in the patch), we have, for 1 pixel:

Which means that Ix²Iy² ≠ (IxIy)², i.e.:

enter image description here

Tony Power
  • 1,033
  • 11
  • 23
-1

I ran into the same issue. For each pixel in the image, you want to consider a small window, say 3x3 around the pixel.

For each pixel in that 3x3 window, you apply a gaussian mask to it for Ix^2, Ix*Iy, and Iy^2 to construct the 2x2 matrix H'. You then sum up the H' matrixes to obtain the final H matrix, and you calculate the determinant from there.

What I'm not clear on though is why the gaussian mask needs to be applied as many slides and resources found online don't mention it

Jay Hu
  • 83
  • 7