title: how to apply multiprocessing to this function?
body: <p>I want to apply multiprocessing a this function, because it takes a long time to run, around 187 seconds, I want to reduce that time. I try to apply multiprocessing but had no success. Somebody could help me?</p>
  <pre><code>def delete_tree(mat_ady, mat_origin, num_labels, dz_min):
  &quot;&quot;&quot;Allows you to eliminate low structures or noise in the image.
  
  Parameters
  ----------
  mat_ady : np.ndarray
      Integer matrix where each unique feature (island) in the
      entry has a unique label.
  mat_origin : np.ndarray
      original matrix corresponding to the elevation of the trees.
  num_labels: int
      Total number of labels in the mat_ady array.
  dz_min : float
      Maximum elevation threshold. 
  Returns
  -------
  np.ndarray
      Array without structure low or noise.
  &quot;&quot;&quot;
  
  tiempo_inicial = time() 
  
  # Each island is traversed and the islands whose maximum value (in the original matrix) exceeds the threshold are eliminated
  for label in range(num_labels):
      if np.max(mat_origin[mat_ady == label]) &lt; dz_min:
          mat_origin[mat_ady == label] = 0
  
  #Time of ejecution of the funtion
  tiempo_final = time() 
  tiempo_ejecucion = tiempo_final - tiempo_inicial
  print('El tiempo de ejecucion funcion delete_tree:',tiempo_ejecucion) #En segundos
  
  return mat_origin
  </code></pre>