Shanon entropy of a matrix
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ali eskandari
el 18 de Mzo. de 2021
Respondida: Jan
el 18 de Mzo. de 2021
I defined a matrix like A and I want to calculate its entropy and when I use the entropy function it returns zero :
A = [2,3,4;4,5,6;10,12,1]
entropy(A)
ans =
0
but when I read the matlab entropy help, it mentioned that this funtion will return the entropy of a grayscale image, so I have decided to apply mat2gray to convert my matrix into the grayscale, and now it returns 2.9477.
b= mat2gray(A)
b =
0.0909 0.1818 0.2727
0.2727 0.3636 0.4545
0.8182 1.0000 0
entropy(b)
ans =
2.9477
so, could you please help to find is this way correct?
0 comentarios
Respuesta aceptada
Jan
el 18 de Mzo. de 2021
As the documentation tells, the input is expected to be a gray scale image. Then value over 1.0 are limit to 1.0 and you matrix is interpreted as [1, 1, 1; 1, 1, 1; 1, 1, 1] with zero entropy.
Converting the matrix by mat2gray divides the values by the larges element after subtracting the smalles element:
A = [2,3,4; 4,5,6; 10,12,1]
mA = min(A(:));
B = (A - mA) / (max(A(:)) - mA) % same as MAT2GRAY
As far as I understand, this is the correct way to determine the entropy.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!