Skip to content

Instantly share code, notes, and snippets.

@luca-m
Forked from odebeir/gist:3918044
Created August 2, 2013 09:57
Show Gist options
  • Save luca-m/6138774 to your computer and use it in GitHub Desktop.
Save luca-m/6138774 to your computer and use it in GitHub Desktop.
#opencv
import cv2.cv as cv
import cv2
import numpy as np
def build_filters():
filters = []
ksize = 31
for theta in np.arange(0, np.pi, np.pi / 32):
params = {'ksize':(ksize, ksize), 'sigma':1.0, 'theta':theta, 'lambd':15.0,
'gamma':0.02, 'psi':0, 'ktype':cv2.CV_32F}
kern = cv2.getGaborKernel(**params)
kern /= 1.5*kern.sum()
filters.append((kern,params))
return filters
def process(img, filters):
results = []
for kern,params in filters:
fimg = cv2.filter2D(img, cv2.CV_8UC3, kern)
results.append[fimg]
return results
# main
g = some_image
filters = build_filters()
filtered_images = process(g, filters)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment