发布时间:2021-09-08 23:10:21编辑:run阅读(4705)
将应用幂等变换对具有scikit-image的RPG彩色图像进行这样的变换,然后可视化变换对颜色通道直方图的影响。
from skimage.io import imread import matplotlib.pylab as pylab import numpy as np pylab.rcParams['font.sans-serif'] = ['KaiTi'] # 解决保存图像是负号'-'显示为方块的问题 pylab.rcParams['axes.unicode_minus'] = False im = img_as_float(imread(r'D:\image_processing\image4\b.jpg')) gamma = 3 im1 = im**gamma pylab.style.use('ggplot') pylab.figure(figsize=(15, 5)) pylab.subplot(121) pylab.title('原始图像', size=20) pylab.axis('off') pylab.imshow(im) pylab.subplot(122) pylab.title('幂等变换(y=3)图像', size=20) pylab.axis('off') pylab.imshow(im1)
幂等变换颜色通道直方图
from skimage.io import imread from skimage import data, img_as_float,img_as_ubyte import matplotlib.pylab as pylab import numpy as np pylab.rcParams['font.sans-serif'] = ['KaiTi'] # 解决保存图像是负号'-'显示为方块的问题 pylab.rcParams['axes.unicode_minus'] = False def plot_hist(r, g, b, title=''): r, g, b = img_as_ubyte(r), img_as_ubyte(g), img_as_ubyte(b) pylab.hist(np.array(r).ravel(), bins=256, range=(0, 256), color='r', alpha=0.5) pylab.hist(np.array(g).ravel(), bins=256, range=(0, 256), color='g', alpha=0.5) pylab.hist(np.array(b).ravel(), bins=256, range=(0, 256), color='b', alpha=0.5) pylab.xlabel('像素值', size=20) pylab.ylabel('频率', size=20) pylab.title(title, size=20) im = img_as_float(imread(r'D:\image_processing\image4\b.jpg')) gamma = 3 im1 = im**gamma pylab.style.use('ggplot') pylab.figure(figsize=(15, 5)) pylab.subplot(121) plot_hist(im[..., 0], im[...,1], im[..., 2], '原始RPG颜色通道直方图') pylab.subplot(122) plot_hist(im1[..., 0], im1[...,1], im1[..., 2], '幂等变换(y=5)RPG颜色通道直方图') pylab.show()
上一篇: python3-PIL图像增强
下一篇: python3-PIL对比度拉伸
47742
46232
37103
34622
29224
25880
24740
19859
19413
17903
5711°
6311°
5829°
5883°
6979°
5825°
5841°
6355°
6311°
7669°