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