Skip to content

Commit

Permalink
Add identify_foreground to EdgeAligner
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuhlich committed Jul 8, 2024
1 parent d4c7eff commit c9704b4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ashlar/reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import skimage.util.dtype
import skimage.io
import skimage.exposure
import skimage.filters
import skimage.transform
import sklearn.linear_model
import networkx as nx
Expand Down Expand Up @@ -504,6 +505,7 @@ def __init__(
def run(self):
self.make_thumbnail()
self.check_overlaps()
self.identify_foreground()
self.compute_threshold()
self.register_all()
self.build_spanning_tree()
Expand Down Expand Up @@ -533,6 +535,14 @@ def check_overlaps(self):
elif any(failures):
warn_data("Some neighboring tiles have zero overlap.")

def identify_foreground(self):
energies = np.array([
np.linalg.norm(utils.whiten(self.reader.read(i, self.channel), 0))
for i in range(self.metadata.num_images)
])
threshold = skimage.filters.threshold_otsu(energies)
self.foreground = energies > threshold

def compute_threshold(self):
if self.max_error is not None:
if self.verbose:
Expand Down

0 comments on commit c9704b4

Please sign in to comment.