|
1 | 1 | """ |
2 | | -PCLines transform for line detection |
3 | | -
|
4 | | -This package implements the method from |
5 | | - Dubska et al, PCLines - Line detection with parallel coordinates, CVPR 2011 |
6 | | -
|
7 | | -
|
8 | | -Module |
9 | | ------- |
10 | | -The module provides a high-level function for line detection in image |
11 | | -and also low-level functions for |
| 2 | +The module provides the class PCLines with "low level" functions for |
12 | 3 | * accumulation of observations to PCLines space, |
13 | 4 | * point mapping from PCLines space to homogeneous lines |
14 | 5 | that can be used to construct a custom PCLines transform of user-defined |
15 | | -edge points. |
16 | | -
|
17 | | -
|
18 | | -See also |
19 | | --------- |
20 | | -* pclines.accumulate |
21 | | -* pclines.find_peaks |
22 | | -* pclines.line_parameters |
| 6 | +edge points (observations). |
23 | 7 |
|
24 | 8 |
|
25 | 9 | References |
26 | 10 | ---------- |
27 | 11 | [1] Dubska et al, PCLines - Line detection with parallel coordinates, CVPR 2011 |
28 | | -
|
29 | | -
|
30 | 12 | """ |
31 | 13 |
|
32 | 14 |
|
@@ -167,17 +149,21 @@ def __init__(self, bbox, d=256): |
167 | 149 |
|
168 | 150 | @property |
169 | 151 | def origin(self): |
| 152 | + """ The origin of the bounding box of the observations """ |
170 | 153 | return self.bbox[:2] |
171 | 154 |
|
172 | 155 | @property |
173 | 156 | def input_shape(self): |
| 157 | + """ Size of the bounding box """ |
174 | 158 | return self.bbox[2:] |
175 | 159 |
|
176 | 160 | @property |
177 | 161 | def scale(self): |
| 162 | + """ Larger side of the bounding box """ |
178 | 163 | return max(self.input_shape) |
179 | 164 |
|
180 | 165 | def clear(self): |
| 166 | + """ Set the accumulator to 0 """ |
181 | 167 | self.A[:] = 0 |
182 | 168 |
|
183 | 169 | def transform(self, x): |
@@ -219,10 +205,22 @@ def inverse(self, l): |
219 | 205 | return lines |
220 | 206 |
|
221 | 207 | def valid_points(self, p): |
| 208 | + """ Check if the points fits the accumulator """ |
222 | 209 | return np.all(np.logical_and(p>=0, p<self.d), axis=1) |
223 | 210 |
|
224 | 211 | def insert(self, x, weight=None): |
225 | | - """ |
| 212 | + """ Insert observations x to the accumulator |
| 213 | +
|
| 214 | + Inputs |
| 215 | + ------ |
| 216 | + x : ndarray |
| 217 | + (N,2) observations |
| 218 | + weights : ndarray or None |
| 219 | + Weight of each observation in accumulator (defaults to 1 in None) |
| 220 | +
|
| 221 | + Notes |
| 222 | + ----- |
| 223 | + Any observation outside the bounding box is ignored. |
226 | 224 | """ |
227 | 225 | p = self.transform(x) |
228 | 226 | n = p.shape[0] |
|
0 commit comments