Skip to content

Commit 0bb531c

Browse files
authoredFeb 11, 2018
small tweak to label_points_in_countours, huge speedup (#64)
1 parent c299731 commit 0bb531c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

‎floater/rclv.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,21 @@ def fill_in_contour(contour, label_data, value=1):
514514
xmax += roll_x
515515
xmin += roll_x
516516

517-
data = np.roll(np.roll(label_data, roll_x, axis=1), roll_y, axis=0)
517+
# only roll if necessary
518+
if roll_x or roll_y:
519+
data = np.roll(np.roll(label_data, roll_x, axis=1), roll_y, axis=0)
520+
else:
521+
data = label_data
518522
region_slice = (slice(ymin,ymax), slice(xmin,xmax))
519523
region_data = data[region_slice]
520524
data[region_slice] = value*grid_points_in_poly(region_data.shape,
521525
contour_rel)
522526

523-
return np.roll(np.roll(data, -roll_x, axis=1), -roll_y, axis=0)
527+
if roll_x or roll_y:
528+
res = np.roll(np.roll(data, -roll_x, axis=1), -roll_y, axis=0)
529+
else:
530+
res = data
531+
return res
524532

525533
labels = np.zeros(shape, dtype='i4')
526534
for n, con in enumerate(contours):

0 commit comments

Comments
 (0)