I am trying apply Gabor Filter for thetha=0,pi/4,pi/2,3pi/4,pi and want to see the resulting 5 images.
How to view those 5 images. I cannot clearly understand the code given in the link I have been trying to follow.
Here is my code snippet
def build_filters(sigma_size,kernel_size):
filters = []
ksize = kernel_size
for theta in np.arange(0, np.pi, np.pi / 5):
params = {'ksize':(ksize, ksize), 'sigma':sigma_size, '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(image,filters):
results = []
for kern, params in filters:
fimg = cv2.filter2D(image, cv2.CV_8UC3, kern)
results.append([fimg])
return results
def Gabor_features(image,filters):
filtered_images = process(image,filters)
return filtered_images
I am trying to call this function in main.py
imported above file as FE
gaborfilters = GaborFilterBank.build_filters(2.0,39) # matlab sig=2.0,kernel size 39
feature_2 = FE.Gabor_features(grayImage,gaborfilters)
# here I want to view the 5 filtered images
fig, ax = plt.subplots(nrows=1, ncols=5)
ax[0].imshow(??)
ax[1].imshow(??)
ax[2].imshow(??)
ax[3].imshow(??)
ax[4].imshow(??)
Does the 'results.append' is making a structure of all 5 images that I have calculated ? if not how ? please suggest.
I tried to follow Gabor Filtering openCV
Aucun commentaire:
Enregistrer un commentaire