parameters: (kernals, min_area=5)
return_statement: return pred, label_values
docstring: :param kernals:
      :param min_area:
      :return:
docstring_summary: :param kernals:
      :param min_area:
      :return:
docstring_tokens: : param kernals : : param min_area : : return :
function: def pse(kernals, min_area=5):
      '''
      :param kernals:
      :param min_area:
      :return:
      '''
      from .pse import pse_cpp
      kernal_num = len(kernals)
      if not kernal_num:
          return np.array([]), []
      kernals = np.array(kernals)
      label_num, label = cv2.connectedComponents(kernals[kernal_num - 1].astype(np.uint8), connectivity=4)
      label_values = []
      for label_idx in range(1, label_num):
          if np.sum(label == label_idx) < min_area:
              label[label == label_idx] = 0
              continue
          label_values.append(label_idx)
  
      pred = pse_cpp(label, kernals, c=6)
  
      return pred, label_values
function_tokens: def pse ( kernals , min_area = 5 ) : from . pse import pse_cpp kernal_num = len ( kernals ) if not kernal_num : return np . array ( [ ] ) , [ ] kernals = np . array ( kernals ) label_num , label = cv2 . connectedComponents ( kernals [ kernal_num - 1 ] . astype ( np . uint8 ) , connectivity = 4 ) label_values = [ ] for label_idx in range ( 1 , label_num ) : if np . sum ( label == label_idx ) < min_area : label [ label == label_idx ] = 0 continue label_values . append ( label_idx ) pred = pse_cpp ( label , kernals , c = 6 ) return pred , label_values