标签:
创建两个滑动条来分别控制高斯核的size和
注意:由于
python+opencv实现阈值分割
python+opencv实现霍夫变换检测直线
(2016-5-10)到OpenCV-Python Tutorials’s documentation!可以下载
# -*- coding: utf-8 -*-
import cv2
#两个回调函数
def GaussianBlurSize(GaussianBlur_size):
global KSIZE
KSIZE = GaussianBlur_size * 2 +3
print KSIZE, SIGMA
dst = cv2.GaussianBlur(scr, (KSIZE,KSIZE), SIGMA, KSIZE)
cv2.imshow(window_name,dst)
def GaussianBlurSigma(GaussianBlur_sigma):
global SIGMA
SIGMA = GaussianBlur_sigma/10.0
print KSIZE, SIGMA
dst = cv2.GaussianBlur(scr, (KSIZE,KSIZE), SIGMA, KSIZE)
cv2.imshow(window_name,dst)
#全局变量
GaussianBlur_size = 1
GaussianBlur_sigma = 15
KSIZE = 1
SIGMA = 15
max_value = 300
max_type = 6
window_name = "GaussianBlurS Demo"
trackbar_size = "Size*2+3"
trackbar_sigema = "Sigma/10"
#读入图片,模式为灰度图,创建窗口
scr = cv2.imread("G:\homework\lena.bmp",0)
cv2.namedWindow(window_name)
#创建滑动条
cv2.createTrackbar( trackbar_size, window_name, GaussianBlur_size, max_type, GaussianBlurSize )
cv2.createTrackbar( trackbar_sigema, window_name, GaussianBlur_sigma, max_value, GaussianBlurSigma )
#初始化
GaussianBlurSize(1)
GaussianBlurSigma(15)
if cv2.waitKey(0) == 27:
cv2.destroyAllWindows()
需要把图片和cv2.pyd与GaussianBlur.py放在同一文件夹下
>>> import os
>>> os.chdir("g:\homework")
>>> import GaussianBlur
5 15
5 1.5
5 1.6
5 1.9
5 2.4
5 2.5
5 2.9
5 3.0
5 3.3
5 3.6
5 3.9
5 4.1
5 4.2
5 4.3
5 4.4
5 4.5
5 4.6
5 4.7
5 4.8
标签:
原文地址:http://blog.csdn.net/xieyi4650/article/details/51355303