读图像、显示图像采用opencv接口,算法主体用python编写
算法步骤在代码中详细体现。
代码如下:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
'直方图均衡化函数,0::28 2019/06/20'
__author__ = 'mint'
import numpy as np
import cv2 as cv
#创建空列表(数组)
def createEmptyList(size):
newList = []
for eachNum in range(0, size):
newList.append(0)
return newList
#创建空图像矩阵
def createEmptyImage(rows, cols,type):
img = np.zeros((rows, cols), dtype=type)
return img
#直方图均衡化
def histequaLize(src, dst):
#step 1 校验参数#
assert(type(src)==np.ndarray)
assert(src.dtype == np.uint8)
assert (type(dst) == np.ndarray)
assert (dst.dtype == np.uint8)
# step 2 直方图统计#
hist = createEmptyList(256)
rows, cols