Go to the documentation of this file.00001
00002
00003
00004 import numpy as np
00005 from skimage.morphology import binary_closing
00006
00007
00008 def bounding_rect_of_mask(img, mask):
00009 where = np.argwhere(mask)
00010 (y_start, x_start), (y_stop, x_stop) = where.min(0), where.max(0) + 1
00011 return img[y_start:y_stop, x_start:x_stop]
00012
00013
00014 def descent_closing(mask, init_selem, n_times):
00015 S = init_selem.shape
00016 for i in xrange(n_times):
00017 selem = np.ones((S[0] * (n_times - i), S[1] * (n_times - i)))
00018 mask = binary_closing(mask, selem=selem)
00019 return mask