parameters: (vol, seg, do_rgb=True, seg_wt=0.5, cmap=None)
return_statement: return olap
docstring: overlap a nd volume and nd segmentation (label map)
  
      not well tested yet.
docstring_summary: overlap a nd volume and nd segmentation (label map)
docstring_tokens: overlap a nd volume and nd segmentation ( label map )
function: def seg_overlay(vol, seg, do_rgb=True, seg_wt=0.5, cmap=None):
      '''
      overlap a nd volume and nd segmentation (label map)
  
      not well tested yet.
      '''
  
      # compute contours for each label if necessary
  
      # compute a rgb-contour map
      if do_rgb:
          if cmap is None:
              nb_labels = np.max(seg) + 1
              colors = np.random.random((nb_labels, 3)) * 0.5 + 0.5
              colors[0, :] = [0, 0, 0]
          else:
              colors = cmap[:, 0:3]
  
          seg_flat = colors[seg.flat, :]
          seg_rgb = np.reshape(seg_flat, vol.shape + (3, ))
  
          # get the overlap image
          olap = seg_rgb * seg_wt + np.expand_dims(vol, -1) * (1-seg_wt)
  
      else:
          olap = seg * seg_wt + vol * (1-seg_wt)
  
      return olap
function_tokens: def seg_overlay ( vol , seg , do_rgb = True , seg_wt = 0.5 , cmap = None ) : # compute contours for each label if necessary # compute a rgb-contour map if do_rgb : if cmap is None : nb_labels = np . max ( seg ) + 1 colors = np . random . random ( ( nb_labels , 3 ) ) * 0.5 + 0.5 colors [ 0 , : ] = [ 0 , 0 , 0 ] else : colors = cmap [ : , 0 : 3 ] seg_flat = colors [ seg . flat , : ] seg_rgb = np . reshape ( seg_flat , vol . shape + ( 3 , ) ) # get the overlap image olap = seg_rgb * seg_wt + np . expand_dims ( vol , - 1 ) * ( 1 - seg_wt ) else : olap = seg * seg_wt + vol * ( 1 - seg_wt ) return olap