|
7 | 7 | def rolling_ball(image, *, radius=100, kernel=None, nansafe=False, num_threads=None): |
8 | 8 | """Estimate background intensity using the rolling-ball algorithm. |
9 | 9 |
|
10 | | - This function estimates the background intensity of an n-dimensional |
11 | | - image. Typically, it is useful for background subtraction in case of |
12 | | - uneven exposure. It is a generalization of the well-known rolling-ball |
13 | | - algorithm [1]_. |
| 10 | + This function is a generalization of the rolling-ball algorithm [1]_ to |
| 11 | + estimate the background intensity of an n-dimensional image. This is |
| 12 | + typically useful for background subtraction in case of uneven exposure. |
| 13 | + Think of the image as a landscape (where altitude is determined by |
| 14 | + intensity), under which a ball of given radius is rolled. At each |
| 15 | + position, the ball's apex gives the resulting background intensity. |
14 | 16 |
|
15 | 17 | Parameters |
16 | 18 | ---------- |
@@ -39,20 +41,14 @@ def rolling_ball(image, *, radius=100, kernel=None, nansafe=False, num_threads=N |
39 | 41 |
|
40 | 42 | Notes |
41 | 43 | ----- |
42 | | - The algorithm is easy to grasp in 2D: Consider that each pixel value |
43 | | - defines a height, forming a 2D surface in 3D space. Then, a (3D) ball of |
44 | | - given radius (or a kernel, in the general case) is placed under this |
45 | | - surface and raised until it touches it. The background intensity is |
46 | | - estimated by the hull of the volume reachable by the ball. |
47 | | -
|
48 | | - Clearly, for this method to give meaningful results, the radius of the |
49 | | - ball (or typical size of the kernel, in the general case) should be (much) |
50 | | - larger than the typical size of the image features of interest. |
51 | | -
|
52 | 44 | This implementation assumes that dark pixels correspond to the background. If |
53 | 45 | you have a bright background, invert the image before passing it to this |
54 | 46 | function, e.g., using :func:`skimage.util.invert`. |
55 | 47 |
|
| 48 | + For this method to give meaningful results, the radius of the ball (or |
| 49 | + typical size of the kernel, in the general case) should be larger than the |
| 50 | + typical size of the image features of interest. |
| 51 | +
|
56 | 52 | This algorithm is sensitive to noise (in particular salt-and-pepper |
57 | 53 | noise). If this is a problem in your image, you can apply mild |
58 | 54 | Gaussian smoothing before passing the image to this function. |
|
0 commit comments