-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGabor_1.py
32 lines (27 loc) · 1.12 KB
/
Gabor_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import numpy as np
import cv2
# cv2.getGaborKernel(ksize, sigma, theta, lambda, gamma, psi, ktype)
# ksize - size of gabor filter (n, n)
# sigma - standard deviation of the gaussian function Actual Value - 8
# theta - orientation of the normal to the parallel stripes
# lambda - wavelength of the sunusoidal factor
# gamma - spatial aspect ratio
# psi - phase offset
# ktype - type and range of values that each pixel in the gabor kernel can hold
g_kernel = cv2.getGaborKernel((15, 15), 8.0, np.pi/4, 10.0, 0.7, 0, ktype=cv2.CV_32F)
img = cv2.imread('MCUCXR_0301_1.png')
img = cv2.resize(img, (1024, 1024))
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
filtered_img = cv2.filter2D(img, cv2.CV_8UC3, g_kernel)
#cv2.imshow('image', img)
#cv2.resizeWindow('filtered image', 620,620)
cv2.imshow('filtered image', filtered_img)
h, w = g_kernel.shape[:2]
print (h,w)
g_kernel = cv2.resize(g_kernel, (5*w, 5*h), interpolation=cv2.INTER_CUBIC)
cv2.namedWindow('image', cv2.WINDOW_NORMAL)
#cv2.resizeWindow('image',620,620)
cv2.imshow('gabor kernel (resized)', g_kernel)
cv2.imwrite('Lung.png',filtered_img)
cv2.waitKey(0)
cv2.destroyAllWindows()