Python cv2 图像自适应灰度直方图均衡化处理方法
__author__ = 'Administrator'
import numpy as np import cv2 mri_img = np.load('mri_img.npy') # normalization mri_max = np.amax(mri_img) mri_min = np.amin(mri_img) mri_img = ((mri_img-mri_min)/(mri_max-mri_min))*255 mri_img = mri_img.astype('uint8') r, c, h = mri_img.shape for k in range(h): temp = mri_img[:,:,k] clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8)) img = clahe.apply(temp) cv2.imshow('mri', np.concatenate([temp,img], 1)) cv2.waitKey(0)
均衡化前、后对比效果