- Linear filter used for texture analysis
- Gabor filter allow a certain band of frequency and reject the others
- Edges and texture changes captured
- Filters are convolved with signal and Gabor space is obtained
- 2D Gabor filter is Gaussian Kernel modulated by a sinusoidal plane wave in spatial domain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
#cv2.getGaborKernet(ksize,sigma,theta,lambda,gamma,psi,ktype) | |
#size of habor filter | |
#sigma - standard deviation from gaussian | |
#theta - orientation from normal to the parallel stripes | |
#gamma - spacial aspect ratio | |
#psi - phase offset | |
#ktype - type and range values for each pixel in gabor kernel It can be CV_32F or CV_64F | |
def CheckGaborfilter(gabor_kernel): | |
inputimage = cv2.imread(r'D:\OpenCVExamples\IMG_20180923_150233_282.jpg') | |
grayimage = cv2.cvtColor(inputimage,cv2.COLOR_BGR2GRAY) | |
filteredimage = cv2.filter2D(grayimage,cv2.CV_8UC3,gabor_kernel) | |
cv2.imshow('Original Image',inputimage) | |
cv2.imshow('Filtered Image',filteredimage) | |
cv2.waitKey(0) | |
return | |
#ksize, sigma, theta, lambd, gamma[, psi[, ktype]] | |
#Example 1 | |
gabor_kernel = cv2.getGaborKernel((21,21),8.0,np.pi/4,10.0,0.5,0,ktype=cv2.CV_32F) | |
CheckGaborfilter(gabor_kernel) | |
#Example 2 | |
gabor_kernel = cv2.getGaborKernel((10,10),5.0,np.pi/4,10.0,0.5,1,ktype=cv2.CV_64F) | |
CheckGaborfilter(gabor_kernel) | |
#Example 3 | |
gabor_kernel = cv2.getGaborKernel((21,21),8.0,np.pi/4,5.0,0.5,0,ktype=cv2.CV_64F) | |
CheckGaborfilter(gabor_kernel) | |
#Example 4 | |
gabor_kernel = cv2.getGaborKernel((21,21),8.0,np.pi/4,10.0,0.5,0,ktype=cv2.CV_64F) | |
CheckGaborfilter(gabor_kernel) | |
cv2.destroyAllWindows() |
This also can be applied for feature extraction from images.
Ref - Link1 , Link2
Happy Learning!!!
No comments:
Post a Comment