python实现灰度图像拉伸
1、灰度拉伸是一种简单的线性运算。经过变换后使得灰度布满整个灰度等级范围。为了把不同图像的灰度值映射到0-255范围内,常见的方法有:

2、处理过程如下:import cv2 as cvimport numpy as npfrom matplotlib import pyplot as pltimage = cv.imread('c:\\meiping1.png')imgGray = cv.cvtColor(image, cv.COLOR_RGB2GRAY)cv.imshow('imgGray', imgGray)

3、rows, cols = imgGray.shapereshapeGray = imgGray.reshape(rows * cols)print(reshapeGray)reshapeGrayList = reshapeGray.tolist()通过.tolist() 转换成列表 方便后面求最大灰度 和最小灰度

5、2)另一种方法MAX = 255MIN = 0Gxy = (imgGray - A) / (B - A) * (MAX - MIN) + MIN区别在gxy 其他不变!


