Isaac's Blog

Hough Transform for Plane Detection

2018/02/28

The Hough Transform is a method for detecting parameterized objects, typically used for lines and circles in 2D space. Nowadays, with proliferation of acquisitive devices, deriving a massive point cloud is an easy task. As we can also parameterize objects in 3D, Hough Transform can be applied to detect planes in 3D point clouds as well.

Parameterization of a Plane

Similar to a line in 2D space, a plane in 3D can be described using a slope–intercept equation, where $k_x$ is the slope in x-direction, $k_y$ is the slope in y-direction and $b$ is the intercept on z-axis:

$$\begin{equation}
z=k_xx+k_yy+b
\end{equation}$$

With this equation we can simply parameterize a plane as $(k_x,k_y,b)$.

However, values of $k_x$, $k_y$, and $b$ are unbounded, which would pose a problem when we try to parameterize a vertical plane. Thus, for computational reasons, we can write the plane equation in the Hesse normal form, where $\theta$ is the angle between the normal vector of this plane and the x-axis, $\phi$ is the angle between the normal vector and z-axis and $\rho$ is the distance from the plane to the origin:

$$\begin{equation}
x\cos\theta\sin\phi+y\sin\phi\sin\theta+z\cos\phi=\rho
\end{equation}$$

As is shown in Figure 1. The plane can be parameterized as $(\theta,\phi,\rho)$.

Hough Transform for Plane Detection figure 1

Figure 1: Parameterization of a plane.

To find planes in a 3D point cloud, we have to calculate the Hough Transform for each point, which is to say that we parameterize every possible plane that go through every point in the $(\theta,\phi,\rho)$ Hough Space. For instance, Figure 2 shows the parameterization of three points $(0,0,1)$, $(0,1,0)$ and $(1,0,0)$. Each point is marked as a 3D sinusoid curve in Hough Space and the intersection which is marked in black denotes the plane defined by the three points.

Hough Transform for Plane Detection figure 2

Figure 2: Transformation of three points from original space to Hough Space.

Hough Methods

Basically, the algorithm for doing Hough Transform can be described as a voting method, where we discretize the Hough Space with a bunch of $(\theta,\phi,\rho)$ cells. A data structure called accumulator then is needed to store all these cells with a score parameter for every cell. Incrementing a cell means increasing the score of it by +1. Each point votes for all cells of $(\theta,\phi,\rho)$ that define a plane on which it may lie.

Standard Hough Transform

A most basic and naïve Hough Transform algorithm for plane detection is outlined as follows:

Begin

Step 1: Traverse all the points in the point cloud $P$;

Step 2: For each point $p_i$ in $P$, vote for all the $A(\theta,\phi,\rho)$ cells in the accumulator $A$ defined by this point;

Step 3: After the whole iteration, search for the most prominent cells in the accumulator $A$, that define the detected planes in $P$.

End

The Standard Hough Transform is performed in two stages: incrementing the cells, which needs $O(\lvert P\rvert\cdot N_\phi\cdot N_\theta)$ operations, and searching for the most prominent cells, which takes $O(N_\rho\cdot N_\phi\cdot N_\theta)$ time, where $\lvert P\rvert$ is the size of the point cloud, $N_\phi$ is the number of cells in direction of $\phi$, $N_\theta$ in direction of $\theta$ and $N_\rho$ in direction of $\rho$.

Probabilistic Hough Transform

In the Standard Hough Transform, the size of the point cloud $\lvert P\rvert$ is usually much larger than the number $N_\rho \cdot N_\phi \cdot N_\theta$ of cells in the accumulator array. We can simply reduce the number of points to improve the computational expenses. Thus, the Standard Hough Transform can be adapted to the Probabilistic Hough Transform, which is shown as follows:

Begin

Step 1: Determine the size value $m$ and the threshold value $t$;

Step 2: randomly select $m$ points to create $P^m\subset P$;

Step 3: Do the Standard Hough Transform on the point set $P^m$;

Step 4: Delete the cells from the accumulator $A$ with a value that does not reach $t$, and search for the most prominent cells in $A$, that define the detected planes in $P$.

End

The $m$ points $(m<\lvert P\rvert)$ are randomly selected from the point cloud $P$, so the dominant part of the runtime is proportional to $O(m\cdot N_\phi\cdot N_\theta)$. However, the optimal choice of $m$ and the threshold $t$ depends on the actual problem, e.g., the number of planes, or the noise in the point cloud.

Adaptive Probabilistic Hough Transform

In order to find the optimal subsample of the point cloud, we can use an adaptive method to determine the reasonable number of selected points. The Adaptive Probabilistic Hough Transform monitors the accumulator. The structure of the accumulator changes dynamically during the voting phase. As soon as stable structures emerge and turn into significant peaks, voting is terminated.

Begin

Step 1: Check the stability order $m_k$ of the list of $k$ peaks $S_k$ in the accumulator, if it reaches the threshold value $t_k$ then finish;

Step 2: Randomly select a small subset $P^m\subset P$;

Step 3: Do the Standard Hough Transform on the point set $P^m$;

Step 4: Merge the active list of peaks $S_k$ with the previous one, determine the stability order $m_k$, goto Step 1;

End

In this algorithm, The stability is described by a set $S_k$ of $k$ peaks in the list, if the set contains all largest peaks before and after one update phase. The number $m_k$ of consecutive lists in which $S_k$ is stable is called the stability order of $S_k$.

Progressive Probabilistic Hough Transform

The Progressive Probabilistic Hough Transform calculates stopping time for random selection of points. The algorithm stops whenever a cell count exceeds a threshold.

Begin

Step 1: Check the input point cloud $P$, if it is empty then finish;

Step 2: Update the accumulator with a single point $p_i$ randomly selected from $P$;

Step 3: Remove $p_i$ from $P$ and add it to $P_{voted}$;

Step 4: Check if the highest peak in the accumulator that was modified by the new point is higher than threshold $t$, if not then goto Step 1;

Step 5: Select all points from $P$ and $P_{voted}$ that are close to the plane defined by the highest peak and add them to $P_{plane}$;

Step 6: Search for the largest connected region $P_{region}$ in $P_{plane}$ and remove from $P$ all points in $P_{region}$;

Step 7: Reset the accumulator by unvoting all the points in $P_{region}$;

Step 8: If the area covered by $P_{region}$ is larger than a threshold, add it to the output list, goto Step 1;

End

In this algorithm, $P_{voted}$ is the point set of all the voted points before a plane is detected, $P_{plane}$ is the set of points in the detected planes, and $P_{region}$ denotes the largest connected region in $P_{plane}$. For determining the stopping time, threshold $t$ is predicted on the percentage of votes for one cell from all points that have voted.

Randomized Hough Transform

As we know the fact that a plane is defined by three points. For detecting planes, three points from the input space are mapped onto one point in the Hough Space. When a plane is represented by a large number of points, it is more likely that three points from this plane are randomly selected. Eventually the cells corresponding to actual planes receive more votes and are distinguishable from the other cells. Inspired by this idea, we can come up with an algorithm described as follows:

Begin

Step 1: Check the input point cloud $P$, if it is empty then finish;

Step 2: Randomly pick three points $p_1$, $p_2$ and $p_3$ from $P$;

Step 3: If $p_1$, $p_2$ and $p_3$ fulfill the distance criterion, calculate plane $(\theta,\phi,\rho)$ spanned by $p_1$, $p_2$ and $p_3$ and increment cell $A(\theta,\phi,\rho)$ in the accumulator space;

Step 4: If the count of $\lvert A(\theta,\phi,\rho)\rvert$ reaches threshold $t$, $(\theta,\phi,\rho)$ parameterize the detected plane, delete all points close to $(\theta,\phi,\rho)$ from $P$, and reset the accumulator $A$;

Step 5: Goto Step 1;

End

This algorithm simply decreases the number of cells touched by exploiting the fact that a curve with $n$ parameters is defined by $n$ points. And also note that, if points are very far apart, they most likely do not belong to one plane. To take care of this and to diminish errors from sensor noise a distance criterion is introduced: $dist(p_1,p_2,p_3)≤dist_{max}$, i.e., the maximum point-to-point distance between $p_1$, $p_2$ and $p_3$ is below a fixed threshold.

Accumulator

An inappropriate accumulator may lead to detection failures of some specific planes and difficulties in finding local maxima, displays low accuracy, large storage space, and low speed. A tradeoff has to be found between a coarse discretization that accurately detects planes and a small number of cells in the accumulator to decrease the time needed for the Hough Transform.

Accumulator Array

For the standard implementation of the 2D Hough Transform, the Hough Space is divided into $N_\rho\times N_\theta$ rectangular cells. The size of the cells is variable and is chosen problem dependent. Using the same subdivision for the 3D Hough Space by dividing it into cuboid cells results in the patches seen in Figure 3. The cells closer to the poles are smaller and comprise less normal vectors. This means voting favors the larger equatorial cells.

Hough Transform for Plane Detection figure 3

Figure 3: Accumulator array.

Accumulator Cube

We can also project the unit sphere $S^2$ onto the smallest cube that contains the sphere using the diffeomorphism:

$$\begin{equation}
\phi:S^2\to cube,s\mapsto\Arrowvert s\Arrowvert_\infty
\end{equation}$$

Each face of the cube is divided into a regular grid, which is shown in Figure 4. With this design of accumulator, the difference of size between the patches on the unit sphere is negligible.

Hough Transform for Plane Detection figure 4

Figure 4: Accumulator cube.

Accumulator Ball

The commonly used design, accumulator array, which is shown in Figure 3, causes the irregularity between the patches on the unit sphere. To solve this issue, we can simply customize the the resolution in terms of polar coordinates depending on the position of the sphere. The resolution of the longitude $\phi$ is kept as for the accumulator array, which is defined as $\phi^\prime$. In $\theta$ direction, the largest latitude circle is the equator located at $\phi=0$. For the unit sphere it has the $max_l=2\pi$. The length of the latitude circle in the middle of the segment located above $\phi_i$ is given by $length_i=2\pi(\phi+\phi^\prime)$. The step width in $\theta$ direction for each slice is now computed as $\theta_{\phi_i}=\frac{360^\circ\cdot max_l}{length_i\cdot N_\theta}$, where $N_\theta$ is a constant that can be customized. The resulting design is illustrated in Figure 5.

Hough Transform for Plane Detection figure 5

Figure 5: Accumulator ball.
CATALOG
  1. 1. Parameterization of a Plane
  2. 2. Hough Methods
    1. 2.1. Standard Hough Transform
    2. 2.2. Probabilistic Hough Transform
      1. 2.2.1. Adaptive Probabilistic Hough Transform
      2. 2.2.2. Progressive Probabilistic Hough Transform
    3. 2.3. Randomized Hough Transform
  3. 3. Accumulator
    1. 3.1. Accumulator Array
    2. 3.2. Accumulator Cube
    3. 3.3. Accumulator Ball