def pct_total_area(image, percentile=0.8):
 idx = int(((image.size - 1) * percentile))
 sorted_pixels = np.sort(image.flat)
 return sorted_pixels[idx]

def pct_total_area ( image , percentile = 0.8 ) : idx = int ( ( ( image . size - 1 ) * percentile ) ) sorted_pixels = np . sort ( image . flat ) return sorted_pixels [ idx ]
return threshold value based on percentage of total area .