tup:n维数组的序列,返回值:n维数组
实例:
a={1,2} b=a print(a==b, a~=b) true, false a={1,2} b={1,2} print(a==b, a~=b) false, true 。[root@tx3 ~]# awk '{ if ($2 >= 90 && $2 <= 100) {print $1,"a"} else if ($2 >= 80 && $2 < 90) {print $1,"b"} else if ($2 >= 70 && $2 < 80) {print $1,"c"} else if ($2 >= 60 && $2 < 70) {print $1,"d"} else {print $1,"e"} }' cj。from beautifulsoup import beautifulsoup soup =beautifulsoup('123') g =soup.recursivechildgenerator() while true: try: print g.next()except stopiteration: break # 1#23 # 2 #3 # 3。
1.] [ 1.
1.] [ 1.
0.] [ 0.
1.]]>>> print np.hstack((a,b))[[ 1.
1.
1.
0.] [ 1.
1.
0.
1.]]
'''
#相当于在原图像上叠加均衡化的直方图,从而使得图片亮度基本保持一致,这个是将两个图像放在一起
res = np.hstack((img , equ))
cv2.imwrite("res.png" , res)
plt.subplot(121) , plt.imshow(img , "gray") , plt.title("original")
plt.subplot(122) , plt.imshow(equ , "gray") , plt.title("opencv historgam equalization")
plt.show()'''CLAHE:优先对比适应性直方图均衡化直方图均衡化的缺点:会改变整个图像的对比度,会丢失信息。原因:图像的直方图并不是集中在某一个区域解决方法:使用自适应的直方图均衡化,将图像分成很多小块(tiles,默认8*8)再对每个小块分别进行直方图均衡化,在每一个区域中,直方图会集中在某一个小的区域中。如果有噪声,噪声会被放大。为了避免上述情况要使用对比度限制,对每个小块来说opencv直方图均衡化,如果直方图中的bin超过对比度上限,就把其中的像素点均匀分散到其他的bins中,然后进行直方图均衡化。最后:为了去除每个小块之间人造边界,使用双线性插值,对小块进行缝合。'''def CLAHE_test():
img = cv2.imread("tsukuba_l.png" , 0)
'''
element=cv2.getstructuringelement(cv2.morph_cross,(5,5))。kernel=cv2.getstructuringelement(cv2.morph_rect,(3,3))。kernel=cv2.getstructuringelement(cv2.morph_rect,(5,5))。
'''
clahe = cv2.createCLAHE(clipLimit=2.0 , tileGridSize=(8,8))
cl1 = clahe.apply(img)
plt.subplot(121) , plt.imshow(img , "gray") , plt.title("original")
plt.subplot(122) , plt.imshow(cl1 , "gray") , plt.title("clahe equalization")
plt.show()if __name__ == "__main__":
#myHist()
#mask_histogram()
#numpy_historgamEqualization()
#mask_filled()
#opencv_histogramEqualization()
CLAHE_test()
推荐:opencv程序八:灰度直方图均衡化
根据第一篇创建项目并添加两个文件 程序如下: // 14EqualizeHist.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <opencv2/opencv.hpp>
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-117992-2.html
打