以下均为github上opencv的个人学习笔记,原路径如下:
https://github.com/JimmyHHua/opencv_tutorials
源码示例:
import cv2 as cv
import numpy as np
src = cv.imread("C:/Users/Mark/Desktop/CV/opencv_tutorials-master/opencv_tutorials-master/python/code_011/test.png")
cv.namedWindow("input",cv.WINDOW_AUTOSIZE)
cv.imshow("input", src)
gray = cv.cvtColor(src,cv.COLOR_BGR2GRAY)
#转换为浮点数类型数组
gray = np.float32(gray)
print(gray)
#scale and shift by NORM_MINMAX
dst = np.zeros(gray.shape,dtype = np.float32)
cv.normalize(gray, dst=dst, alpha=0, beta=1.0,norm_type=cv.NORM_MINMAX)
print(dst)
cv.imshow("NORM_MINMAX", np.uint8(dst*255))
#scale and shift by NORM_INF
dst1 = np.zeros(gray.shape,dtype=np.float32)
cv.normalize(gray,dst