diff --git a/DAB_Analysis_Functions.py b/DAB_Analysis_Functions.py index cbf822f..32f9904 100644 --- a/DAB_Analysis_Functions.py +++ b/DAB_Analysis_Functions.py @@ -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):