Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion bigstream/affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def ransac_affine(
if verbose:
ns = fix_spots.shape[0]
print(f'FIXED image: found {ns} key points')
else:
# Not sure what the convention should be for pixel vs. physical coordinates.
# This is assuming pixels at the same resolution as `fix` and `mov`.
fix_spots = features.cull_boundary_points(fix_spots, cc_radius, fix.shape)
if fix_spots.shape[1]==3:
fix_spots = np.hstack([fix_spots, np.ones((fix_spots.shape[0],1))])

if mov_spots is None:
mov_spots = features.blob_detection(
Expand All @@ -52,7 +58,11 @@ def ransac_affine(
if verbose:
ns = mov_spots.shape[0]
print(f'MOVING image: found {ns} key points')

else:
mov_spots = features.cull_boundary_points(mov_spots, cc_radius, mov.shape)
if mov_spots.shape[1]==3:
mov_spots = np.hstack([mov_spots, np.ones((mov_spots.shape[0], 1))])

# sort
sort_idx = np.argsort(fix_spots[:, 3])[::-1]
fix_spots = fix_spots[sort_idx, :3][:nspots]
Expand Down
10 changes: 10 additions & 0 deletions bigstream/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,13 @@ def match_points(A, B, scores, threshold):
# return positions of corresponding points
return a_pos[keeps, :3], b_pos[best_indcs[keeps], :3]

def cull_boundary_points(points, distance, volshape, offset=[0,0,0]):
"""
Only retain points farther than distance from the edges of volume with shape volshape
"""
upperlim = [i-distance for i in volshape]
lowerlim = [distance for i in volshape]
keep_lows = np.all(points[:,0:3] - offset > lowerlim, axis=1)
keep_highs = np.all(points[:,0:3] - offset + 1 < upperlim, axis=1)
idx = np.argwhere(keep_highs & keep_lows)
return np.squeeze(points[idx,:])