如何找到矩阵列表的置换分布以计算图像的香农熵
How to find the permutation distribution for a list of matrices for calculating Shanon entropy of an Image
其中 H(X)=−∑xp(x)logp(x) 是 Shanon entropy.In 论文“History of art paintings through the lens of entropy and complexity”
我最近在研究绘画数据集的探索性工作,希望这能解决您的问题。根据参考文献分布长度不能超过24.
def permutataion_distribution(matrix_list):
'''
Returns the distribution of matrix permutaions.
Input:
matrix_list: the output of sliding_matrix.
output:
num_of_perm: list of number of each permutations in order recieved
list_of_perm: list of permutations in order recieved
distribution: distrubution
'''
list_of_perm = []
num_of_perm = []
distribution = np.zeros(24)
for i in matrix_list:
mat_perm = np.argsort((np.array[i]).flatten())
indicator = 0
for j in range(0, len(list_of_perm)):
if np.all(mat_perm == list_of_perm[j]):
num_of_perm[j] = num_of_perm[j] + 1
indicator = 1
if indicator == 0:
list_of_perm.append(mat_perm)
num_of_perm.append(1)
distribution = np.array(num_of_perm) / sum(num_of_perm)
return num_of_perm, list_of_perm, distribution
其中 H(X)=−∑xp(x)logp(x) 是 Shanon entropy.In 论文“History of art paintings through the lens of entropy and complexity”
我最近在研究绘画数据集的探索性工作,希望这能解决您的问题。根据参考文献分布长度不能超过24.
def permutataion_distribution(matrix_list):
'''
Returns the distribution of matrix permutaions.
Input:
matrix_list: the output of sliding_matrix.
output:
num_of_perm: list of number of each permutations in order recieved
list_of_perm: list of permutations in order recieved
distribution: distrubution
'''
list_of_perm = []
num_of_perm = []
distribution = np.zeros(24)
for i in matrix_list:
mat_perm = np.argsort((np.array[i]).flatten())
indicator = 0
for j in range(0, len(list_of_perm)):
if np.all(mat_perm == list_of_perm[j]):
num_of_perm[j] = num_of_perm[j] + 1
indicator = 1
if indicator == 0:
list_of_perm.append(mat_perm)
num_of_perm.append(1)
distribution = np.array(num_of_perm) / sum(num_of_perm)
return num_of_perm, list_of_perm, distribution