diff --git a/computeFeatures.py b/computeFeatures.py index f9164e848212c5f5ebabf496604bdc492a6fb57c..040e4097cadcba4e03abf341d6224441c359e828 100644 --- a/computeFeatures.py +++ b/computeFeatures.py @@ -35,7 +35,15 @@ import scipy.ndimage import scipy as sp from skimage.morphology import remove_small_objects -from utils import getBoundingBox + +# Takes a binary mask image and outputs its bounding box +def getBoundingBox(img): + rows = np.any(img, axis=1) + cols = np.any(img, axis=0) + rmin, rmax = np.where(rows)[0][[0, -1]] + cmin, cmax = np.where(cols)[0][[0, -1]] + + return rmin, rmax, cmin, cmax # Computes sizes, diameters, and distance_to_closest_glom features for each glom @@ -385,4 +393,4 @@ log.info('%%%% Ended regularly ! %%%%') # print('Glom: {}'.format(glomN)) # print('Tuft: {}'.format(tuftN)) # print('Artery: {}'.format(arteryN)) -# print('Lumen: {}'.format(lumenN)) \ No newline at end of file +# print('Lumen: {}'.format(lumenN))