Advertisement

数字图像处理Python实践(2)灰度线性和对数、指数变换

阅读量:

目前较为容易处理的对象为灰度图像。这是因为其仅包含一个通道这一特点使得计算过程减少了一个维度从而让很多计算操作简化一个维度。了解 gray-scale image 的基本特性包括掌握 gray-scale histogram的概念以及如何利用它来进行后续的操作。以之前介绍的转 gray-scale 图像为例以下代码展示了如何绘制归一化 histogram:

复制代码
 from PIL import Image

    
 import numpy as np
    
 import matplotlib.pyplot as plt
    
  
    
 gray_girl = "C:/Users/60214/Desktop/python_work/DigitalExecution/gray_girl.jpg"
    
  
    
 def GrayHist(path, bins = 32):
    
 	im = Image.open(path)
    
 	imarray = np.array(im)
    
  
    
 	height, width = imarray.shape
    
 	data = imarray.reshape((height*width))
    
 	plt.hist(data, normed = 1, bins 

全部评论 (0)

还没有任何评论哟~