def PrecentThreshold(image, percent):
"""
Threshold the hishest n precent of pixel in the image
INPUT: image, precent
OUTPUT: The image after the threshold
"""
number = np.size(image)
per = int(number * precent)
[hist, bin_edges] = np.histogram(a,bins=100)
a = 0
index = 0
for i in hist[::-1]:
if a < per:
a += i
index += 1
else:
threshold = bin_edges[-index-1]
break
image[image>threshold] = threshold
return image
百分之一阈值
最新推荐文章于 2022-06-07 11:53:05 发布