Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def shannon_entropy(img):
- histogram = img.histogram()
- histogram_length = sum(histogram)
- samples_probability = [float(h) / histogram_length for h in histogram]
- return -sum([p * math.log(p, 2) for p in samples_probability if p != 0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement