def mark_boundaries(image, label_img, color=(1, 1, 0), outline_color=None, mode='outer', background_label=0):
 marked = img_as_float(image, force_copy=True)
 if (marked.ndim == 2):
  marked = gray2rgb(marked)
 if (mode == 'subpixel'):
  marked = ndi.zoom(marked, ([(2 - (1 / s)) for s in marked.shape[:(-1)]] + [1]), mode='reflect')
 boundaries = find_boundaries(label_img, mode=mode, background=background_label)
 if (outline_color is not None):
  outlines = dilation(boundaries, square(3))
  marked[outlines] = outline_color
 marked[boundaries] = color
 return marked

def mark_boundaries ( image , label_img , color = ( 1 , 1 , 0 ) , outline_color = None , mode = 'outer' , background_label = 0 ) : marked = img_as_float ( image , force_copy = True ) if ( marked . ndim == 2 ) : marked = gray2rgb ( marked ) if ( mode == 'subpixel' ) : marked = ndi . zoom ( marked , ( [ ( 2 - ( 1 / s ) ) for s in marked . shape [ : ( - 1 ) ] ] + [ 1 ] ) , mode = 'reflect' ) boundaries = find_boundaries ( label_img , mode = mode , background = background_label ) if ( outline_color is not None ) : outlines = dilation ( boundaries , square ( 3 ) ) marked [ outlines ] = outline_color marked [ boundaries ] = color return marked
return image with boundaries between labeled regions highlighted .