用python语言读取二进制图片文件,并提取非零数据统计信息(例如:max,min,skewness and kurtosis)
python新手,注释较少,欢迎指教
import struct
import math
import numpy
import scipy.stats
filename = input('enter file name')
f = open(filename, 'rb')
f.seek(0, 0)
c = 0
numOfZero = 0
s = 0
num = []
m = 0
while True:
temp = f.read(4)
if len(temp) == 0:
break
else:
c = c + 1
print(c)
print(numOfZero)
sum = 0
squSum = 0
min = 2000
max = 0
list = []
num = []
f.seek(0, 0)
for i in range(0, c):
a = f.read(4)
b = struct.unpack('
list.append(b[0])
if list[i] == 0: