def quickshift(image, ratio=1.0, kernel_size=5, max_dist=10, return_tree=False, sigma=0, convert2lab=True, random_seed=42):
 image = img_as_float(np.atleast_3d(image))
 if convert2lab:
  if (image.shape[2] != 3):
   ValueError('Only RGB images can be converted to Lab space.')
  image = rgb2lab(image)
 if (kernel_size < 1):
  raise ValueError('`kernel_size` should be >= 1.')
 image = ndi.gaussian_filter(image, [sigma, sigma, 0])
 image = np.ascontiguousarray((image * ratio))
 segment_mask = _quickshift_cython(image, kernel_size=kernel_size, max_dist=max_dist, return_tree=return_tree, random_seed=random_seed)
 return segment_mask

def quickshift ( image , ratio = 1.0 , kernel_size = 5 , max_dist = 10 , return_tree = False , sigma = 0 , convert2lab = True , random_seed = 42 ) : image = img_as_float ( np . atleast_3d ( image ) ) if convert2lab : if ( image . shape [ 2 ] != 3 ) : ValueError ( 'Only RGB images can be converted to Lab space.' ) image = rgb2lab ( image ) if ( kernel_size < 1 ) : raise ValueError ( '`kernel_size` should be >= 1.' ) image = ndi . gaussian_filter ( image , [ sigma , sigma , 0 ] ) image = np . ascontiguousarray ( ( image * ratio ) ) segment_mask = _quickshift_cython ( image , kernel_size = kernel_size , max_dist = max_dist , return_tree = return_tree , random_seed = random_seed ) return segment_mask
segments image using quickshift clustering in color- space .