0827 Numpy来实现直方图频数统计

https://blog.csdn.net/jameschen9051/article/details/95108268   java 自动对比度

import numpy as np
from skimage import io
import matplotlib.pyplot as plt

file_name='data3.tiff'
img=io.imread(file_name)
sp = img.shape  # 获取图像形状:返回【行数值,列数值】列表
sph = sp[0]  # 图像的高度(行 范围)
spw = sp[1]
maxxx = np.max(img)
minnn = np.min(img)
arr=img.flatten()
n, bins, patches = plt.hist(arr,bins=maxxx,density=1)    # bins=256, normed=1, facecolor='green', alpha=0.75
tempx = 0
tempy = 0
resultx = 0
resulty = 0
for i in range(maxxx):
    tempx+=n[i]
    if tempx>=0.01:            #  0.01还是0.005?????
        resultx=i
        break
for i in range(maxxx):
    tempy+=n[maxxx-1-i]                           # 找没有黑边的测试图  ???准备切片
    if tempy>=0.01:
        resulty=maxxx-1-i
        break
for iy in range(sph):
    for ix in range(spw):
        pix=img[iy,ix]
        if pix<=resultx:
            img[iy, ix]=0
        elif pix>=resulty:
            img[iy, ix]=255
        else:
            img[iy, ix] = (pix-resultx)/(resulty-resultx)*255
# ist, bin_edges =np.histogram(, bins=[0, 1, 2, 3])

plt.figure(2)
plt.title('www.jb51.net')
plt.imshow(img)
plt.axis('off')
plt.show()
plt.savefig('DATA1.jpg')
# map=np.zeros(sph,spw)
# image = np.expand_dims(img, axis=2)
# image = np.concatenate((image, image, image), axis=-1)
# hist = cv2.calcHist([image], [0], None, [256], [minnn, maxxx])

# def PDF(img):
    # return imagepdf

http://www.sohu.com/a/273067674_654419

 画灰度图直方图  https://www.cnblogs.com/denny402/p/5096790.html

im = PIL.ImageOps.autocontrast(image, cutoff=0, ignore=None)    http://accu.cc/content/pil/pil_imageops/ 自动对比度

https://github.com/BBuf/Image-processing-algorithm

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值