-1

I have stumbled upon some good explanations on how to get the entropy of an RGB image using matlab. Matlab provides a built in function that allows as to get the entropy of a grayscale image using -sum(p.*log2(p)). One answer provides a way on how to get the entropy of an rgb image given in this link ---> https://stackoverflow.com/a/28239789/3995148

How Matlab explains the function :

E = entropy(I) returns E, a scalar value representing the entropy of grayscale image I. Entropy is a statistical measure of randomness that can be used to characterize the texture of the input image.

Entropy is defined as -sum(p.*log2(p))

where p contains the histogram counts returned from imhist. By default, entropy uses two bins for logical arrays and 256 bins for uint8, uint16, or double arrays.

I can be a multidimensional image. If I has more than two dimensions, the entropy function treats it as a multidimensional grayscale image and not as an RGB image.

Questions :

Does entropy consider or detects image irregularities? For example, if variable A contains the entropy of IMAGE AA, and variable B contains the entropy of the Alter(IMAGE AA). Where Alter is a function that swaps random pixels inside the image. Does Variable A and Variable B contains the entropy value? Given that both images contains the same pixels but differs only on their position in the image. I need to clarify because I am new to this topic,

Does entropy need to consider image irregularities, why? What entropy implementation do I need to cover image irregularities? Is it available as built in function in python or other image processing programs?

Community
  • 1
  • 1
DPallega
  • 1
  • 4

2 Answers2

1

Not sure what you mean by "irregularity", but I can show entropy does not vary when you rotate an image, flip it horizontally or vertically, using ImageMagick, so therefore it does not matter if you exchange pixels:

# Check entropy of image
convert image.png -print '%[entropy]' null:
0.89247

# Rotate 90 degrees and check - still same
convert image.png -rotate 90 -print '%[entropy]' null:
0.89247

# Rotate 270 degrees and check - still same
convert image.png -rotate 270 -print '%[entropy]' null:
0.89247

# Flip image and check - still same
convert image.png -flip -print '%[entropy]' null:
0.89247

# Flop image and check - still same
convert image.png -flop -print '%[entropy]' null:
0.89247

You can check the standard deviation, mean and entropy all in one go with:

 convert image.png -rotate 90 -verbose +identify null: | grep -Ei "entropy|deviation|mean" | tail -3
  image.png=> PNG 70x46=>46x70 46x70+0+0 8-bit sRGB 0.000u 0:00.000
  mean: 105.147 (0.412341)
  standard deviation: 59.4199 (0.233019)
  entropy: 0.89247
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
0

the default function is there in the matlab for calculating the entropy.

Just try

I=imread('image name');
entropy(I)
kvorobiev
  • 5,012
  • 4
  • 29
  • 35