You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何Harris矩阵是半正定矩阵?技术推导疑问

Why is the Harris Corner Detector Matrix Positive Semi-Definite?

Great question! Let's break this down step by step to clear up your confusion and prove the semi-positive definiteness of the Harris matrix.

First, let's recall what the Harris matrix (also called the structure tensor) actually is. For a local window in an image, it's defined as:
$$
M = \begin{bmatrix}
\sum_{(x,y) \in \text{window}} I_x(x,y)^2 & \sum_{(x,y) \in \text{window}} I_x(x,y)I_y(x,y) \
\sum_{(x,y) \in \text{window}} I_x(x,y)I_y(x,y) & \sum_{(x,y) \in \text{window}} I_y(x,y)^2
\end{bmatrix}
$$
Where $I_x$ and $I_y$ are the image's gradient values in the x and y directions at each pixel in the window.

Proving Positive Semi-Definiteness

A matrix is positive semi-definite if for any non-zero vector $\mathbf{v} = [a, b]^T$, the quadratic form $\mathbf{v}^T M \mathbf{v}$ is non-negative (i.e., $\geq 0$). Let's compute this quadratic form directly:

$$
\begin{align*}
\mathbf{v}^T M \mathbf{v} &= a^2 \sum I_x^2 + 2ab \sum I_x I_y + b^2 \sum I_y^2 \
&= \sum_{(x,y) \in \text{window}} \left( a I_x(x,y) + b I_y(x,y) \right)^2
\end{align*}
$$

Notice that we've rewritten the sum as the sum of squared terms. Since squares are always non-negative ($z^2 \geq 0$ for any real $z$), the entire sum must also be non-negative. That's the core of the proof! No matter what values $a$ and $b$ you choose, this quadratic form can never be negative.

Correcting Your Feature Value Misconception

You mentioned that the trace (sum of diagonal elements) is positive, leading you to think eigenvalues could be one positive and one negative—but that's impossible here! Because we just proved $M$ is positive semi-definite, all its eigenvalues must be non-negative.

The trace of $M$ is $\sum I_x^2 + \sum I_y^2$, which is positive unless every pixel in the window has zero gradient (a completely flat region, where $M$ is the zero matrix with both eigenvalues zero). So the two eigenvalues can only be:

  • Both positive (corresponding to a corner, where gradients are strong in two perpendicular directions)
  • One positive, one zero (corresponding to an edge, where gradients are strong in one direction only)
  • Both zero (flat region, no gradients at all)

This aligns perfectly with how the Harris detector works: we look for windows where both eigenvalues are large (corners) by computing the response function $\text{det}(M) - k (\text{trace}(M))^2$.

内容的提问来源于stack exchange,提问作者justPassBy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 03:52:49