Skip to content

Commit

Permalink
Empirical Otsu Sanity Check
Browse files Browse the repository at this point in the history
  • Loading branch information
JBeckwith committed Jun 12, 2024
1 parent 6fa21c8 commit 29213e5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions DAB_Analysis_Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,24 @@ def clean_protein_mask(self, image_mask):
return cleaned_mask

def otsu_filtering(self, image):
"""otsu threshold a single colour image
""" otsu threshold a single colour image
Args:
image (np.2darray): single grayscale image
Returns:
mask (np.2darray): single boolean mask image"""

seed = np.copy(image)
seed[1:-1, 1:-1] = image.max()
mask = image

filled = reconstruction(seed, mask, method="erosion")
holes = np.abs(image - filled)
filled = reconstruction(seed, mask, method='erosion')
holes = np.abs(image-filled)
thresh = threshold_otsu(holes)
mask = holes > thresh
if thresh > 0.025:
mask = holes > thresh
else:
mask = np.full_like(thresh, False)
return mask

def analyse_DAB(self, img, filename):
Expand Down

0 comments on commit 29213e5

Please sign in to comment.