calculating entropy of image or alternative?

telmo bacile telmo.bacile at gmail.com
Sat Jul 4 03:17:41 CEST 2015


Hi list,   I found a code that calculates entropy of images with
python that can be used for classifying interesting images from
uninteresting ones. Interesting images has more structured patterns
while uninsteresting are more noisy or completely homogeneous.

I was thinking this code (entropy of image) can be used for measuring
the level of disorder of a group of points in the image.
For example:
Imagine that we have 3 images,  each image has 6 dots, the first one
has very ordered dots , the second one have dots a little bit
disordered and the third one has very dissordered dots.
Then entropy of each image should measure the level of
dissorganization of the dots.

But the wierd thing is that when i experimented with this i got resuts
without sense.
The result i get is that  the image with intermedium dissorder has
less entropy that the very ordered image .  Do anybody have an idea
why im getting this result?

Maybe im misunderstanding something. Is it possible to use entropy of
image to measure the level of dissorganization of a group of points in
an image? If not , is there is another method for doing this?


thanks in advance

T.



here is the code:

import math
from PIL import Image
imageFile = 'int2.jpg'
print imageFile
im = Image.open(imageFile)
rgbHistogram = im.histogram()
print 'Snannon Entropy for Red, Green, Blue:'
for rgb in range(3):
    totalPixels = sum(rgbHistogram[rgb * 256 : (rgb + 1) * 256])
    ent = 0.0
    for col in range(rgb * 256, (rgb + 1) * 256):
        freq = float(rgbHistogram[col]) / totalPixels
        if freq > 0:
            ent = ent + freq * math.log(freq, 2)
    ent = -ent
    print ent


More information about the Python-list mailing list