Recipe
Classify a window with the Harris response
Use when: you have Sobel gradients G_x,G_y over a small window and need to decide flat, edge, or corner without solving for eigenvalues
Goal: a single signed number R that classifies the window
Taught in Corner detection: Harris, Shi-Tomasi, and FAST
Quick recipe
-
1
Run Chapter 0's Sobel kernels over the window to get one (G_x,G_y) pair per pixel.
Why: everything downstream is built from these gradient readings, and Sobel is this course's own noise-resistant way to compute them.
-
2
Sum G_x^2, G_y^2, and G_xG_y over every pixel in the window into the 2\times2 matrix M.
Why: one pixel's gradient could be a fluke; summing over the whole window confirms the pattern holds throughout the neighborhood, not just at one point.
-
3
Read these two numbers straight off M's own entries: no eigenvalue solve needed.
⚡ Shortcut
\det(M)=Sxx\cdot Syy-Sxy^2 and \operatorname{trace}(M)=Sxx+Syy are both a couple of multiplications and one subtraction — the same 2\times2 trace/determinant shortcut that skips straight to a matrix's eigenvalues without ever writing out \det(A-\lambda I) by hand.
Why: \det(M)=\lambda_1\lambda_2 and \operatorname{trace}(M)=\lambda_1+\lambda_2 carry everything the classification below needs about the two eigenvalues, without solving for either one.
-
4
Use k=0.04 unless a specific value is given — the standard empirical range is 0.04–0.06.
Why: this single number is large and positive exactly when both eigenvalues are large and comparable, and negative exactly when one dominates the other.
-
5
Read R's sign against \operatorname{trace}(M)'s own size to reach the final verdict.
- \operatorname{trace}(M) itself is small — flat, regardless of R's sign.
- R is strongly positive — corner.
- R is negative — edge.
Why: each case matches one of the three eigenvalue signatures this section already derived — flat (both eigenvalues small), edge (one large, one ≈0), corner (both large).
Common mistakes
- Checking R's sign without first confirming \operatorname{trace}(M) is meaningfully large — a truly flat region can also produce R near zero, but for the opposite reason (nothing there at all, not a narrowly-missed corner).
- Treating \det(M) alone as the verdict. A window can have a sizeable \det(M) and an even larger \operatorname{trace}(M), so the k\operatorname{trace}(M)^2 penalty still pushes R negative — both terms have to be weighed together, which is the entire reason the penalty exists.
- Assuming a bigger k always finds more corners. A larger k makes the penalty stronger, which makes the detector pickier — fewer borderline windows clear R>0, not more.