Go to the documentation of this file.00001
00002
00003
00004 import numpy as np
00005 from skimage.segmentation import slic
00006 from skimage.feature import peak_local_max
00007 from skimage.morphology import binary_closing
00008
00009 from jsk_recognition_utils.mask import descent_closing
00010
00011
00012 def split_fore_background(depth_img, footprint=None):
00013 if footprint is None:
00014 footprint = np.ones((3, 3))
00015 segments = slic(depth_img)
00016
00017 local_maxi = peak_local_max(
00018 depth_img, labels=segments, footprint=footprint, indices=False)
00019
00020 fg_mask = descent_closing(local_maxi, init_selem=np.ones((3, 3)), n_times=6)
00021 bg_mask = ~fg_mask
00022 return fg_mask, bg_mask