gabor.py

Johannes Bauer, 2012-12-18 11:59 am

Download (525 Bytes)

 
1
import cv2
2
import numpy
3
import math
4
5
sigma = 3.
6
theta = 0.
7
lambd = math.pi/2
8
gamma = 1.
9
psi = math.pi/2
10
11
image = numpy.zeros((100,100,3), numpy.uint8)
12
for i in range(1,15):
13
        dim = (i,i)
14
        kernel = cv2.getGaborKernel(ksize=dim, sigma=sigma, theta=theta, lambd=lambd, gamma=gamma, psi=psi)
15
        onekernel = numpy.ones((100,100,1), numpy.uint8)
16
        print("size : %s" % (dim,))
17
        print("ones")
18
        cv2.filter2D(src=image, ddepth = -1, kernel=onekernel)
19
        print("gabor")
20
        cv2.filter2D(src=image, ddepth = -1, kernel=kernel)
21
        print("Success.")