|
10 | 10 |
|
11 | 11 | from skimage.measure import fit as sk_fit |
12 | 12 | # from skimage.measure.fit import EllipseModel # fix in future skimage>0.13.0 |
13 | | -from imsegm.utilities.drawing import ellipse |
14 | | -from imsegm.descriptors import (reduce_close_points, compute_ray_features_segm_2d, |
15 | | - reconstruct_ray_features_2d) |
16 | | -from imsegm.superpixels import (segment_slic_img2d, superpixel_centers, |
17 | | - make_graph_segm_connect_grid2d_conn4) |
18 | | - |
19 | | -INIT_MASK_BORDER = 50. |
| 13 | +from .utilities.drawing import ellipse |
| 14 | +from .descriptors import ( |
| 15 | + reduce_close_points, compute_ray_features_segm_2d, reconstruct_ray_features_2d) |
| 16 | +from .superpixels import ( |
| 17 | + segment_slic_img2d, superpixel_centers, make_graph_segm_connect_grid2d_conn4) |
| 18 | + |
| 19 | +# INIT_MASK_BORDER = 50. |
| 20 | +#: define minimal size of estimated ellipse |
20 | 21 | MIN_ELLIPSE_DAIM = 25. |
| 22 | +#: define maximal Figure size in larger dimension |
21 | 23 | MAX_FIGURE_SIZE = 14 |
22 | | -SEGM_OVERLAP = 0.5 |
| 24 | +# SEGM_OVERLAP = 0.5 # define transparency for overlapping two images |
| 25 | +#: smoothing background with morphological operation |
23 | 26 | STRUC_ELEM_BG = 15 |
| 27 | +#: smoothing foreground with morphological operation |
24 | 28 | STRUC_ELEM_FG = 5 |
25 | 29 |
|
26 | 30 |
|
@@ -207,21 +211,21 @@ def ransac_segm(points, model_class, points_all, weights, labels, table_prob, |
207 | 211 | best_inliers = None |
208 | 212 |
|
209 | 213 | if isinstance(min_samples, float): |
210 | | - if not (0 <= min_samples <= 1): |
211 | | - raise ValueError("`min_samples` as ration must be in range (0, 1)") |
| 214 | + if not (0 < min_samples <= 1): |
| 215 | + raise ValueError("`min_samples` as ration must be in range (0, 1]") |
212 | 216 | min_samples = int(min_samples * len(points)) |
213 | | - if min_samples < 0: |
214 | | - raise ValueError("`min_samples` must be greater than zero") |
| 217 | + if not (0 < min_samples <= len(points)): |
| 218 | + raise ValueError("`min_samples` must be in range (0, <nb-samples>]") |
215 | 219 |
|
216 | 220 | if max_trials < 0: |
217 | 221 | raise ValueError("`max_trials` must be greater than zero") |
218 | 222 |
|
219 | | - # make sure points is list and not tuple, so it can be modified below |
| 223 | + # make sure points is ndarray and not tuple/list, so it can be modified below |
220 | 224 | points = np.array(points) |
221 | 225 |
|
222 | 226 | for _ in range(max_trials): |
223 | 227 | # choose random sample set |
224 | | - random_idxs = np.random.randint(0, len(points), min_samples) |
| 228 | + random_idxs = np.random.choice(len(points), min_samples, replace=False) |
225 | 229 | samples = points[random_idxs] |
226 | 230 | # for d in points: |
227 | 231 | # samples.append(d[random_idxs]) |
|
0 commit comments