网站建设资讯

NEWS

网站建设资讯

python读取rawbinary图片并提取统计信息的实例-创新互联

用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(' max:
    max = list[i]
  if list[i] < min and list[i] != 0:
    min = list[i]
  sum = sum + list[i]
 
stan_Dev = numpy.std(num)
median = numpy.median(num)
sk = scipy.stats.skew(num)
ku = scipy.stats.kurtosis(num)
 
print('numOfZero = ', numOfZero)
print('sum = ', sum)
print('meanValue = ',sum / (c - numOfZero))
print('maxValue = ', max)
print('minValue = ', min)
print('median = ', median)
print('stdev = ', stan_Dev)
print('skewness = ', sk)
print('kurtosis = ', ku)
 
f.close()

当前题目:python读取rawbinary图片并提取统计信息的实例-创新互联
标题来源:http://cdweb.net/article/ddihdc.html