Given an instance and a border function `border_fn`, extends the instance points with crossing points between the instance and the crop borders. The crossing points are obtained using border_fn.
(self, instance, border_fn)
| 396 | return [min_h, min_w, max_h, max_w] |
| 397 | |
| 398 | def extend_instance_points(self, instance, border_fn): |
| 399 | """ Given an instance and a border function `border_fn`, extends the instance points with crossing points between the instance and |
| 400 | the crop borders. The crossing points are obtained using border_fn. |
| 401 | """ |
| 402 | p = instance[:,0] |
| 403 | p_next = np.roll(p, (-1), axis=(0)) |
| 404 | final_points = [] |
| 405 | for x, xn in zip(p, p_next): |
| 406 | final_points.append(x) |
| 407 | for r in border_fn(x, xn): |
| 408 | final_points.append(r.astype(np.int32)) |
| 409 | p = np.stack(final_points) |
| 410 | return p[:,None] |
| 411 | |
| 412 | def remove_redundant_lines(self, orig_instance, instance): |
| 413 | """ Removes the redundant lines added during cropping. |