简体   繁体   English

如何将2D gabor小波“应用”到图像

[英]How to “apply” 2D gabor wavelet to an image

Possible duplicate - How to apply Gabor wavelets to an image? 可能重复- 如何将Gabor小波应用于图像?

I went through the answers in the above link but I really couldn't follow it. 我仔细查看了以上链接中的答案,但我确实无法遵循。 The first answer, the accepted one, multiplies the image's FFT with itself inside before taking the inverse FFT. 第一个答案(已接受)将图像的FFT与自身内部相乘,然后进行逆FFT。 That didn't make sense to me at all 这对我完全没有意义

Here is my question. 这是我的问题。 I am trying to reproduce the results of paper "Multilayered thresholding-based blood vessel segmentation for screening of diabetic retinopathy" ( http://search.proquest.com/openview/94a1d9b4eed15c442da4f8a62c82a83b/1?pq-origsite=gscholar&cbl=326339 ) 我正在尝试复制论文“基于多层阈值的血管分割以筛查糖尿病性视网膜病变”的结果( http://search.proquest.com/openview/94a1d9b4eed15c442da4f8a62c82a83b/1?pq-origsite=gscholar&cbl=326339

def gabor_wavelet(rows, cols, kmax, f, orientation, scale, delt2):

    k = (kmax / (f ** scale)) * np.exp(1j * orientation * np.pi / 8)
    kn2 = np.abs(k) ** 2

    gw = np.zeros((rows, cols), np.complex128)

    for m in range(int(-rows/2) + 1, int(rows / 2) + 1):
        for n in range(int(-cols/2) + 1, int(cols / 2) + 1):
            t1 = np.exp(-0.5 * kn2 * (m**2 + n**2) / delt2)
            t2 = np.exp(1j * (np.real(k) * m + np.imag(k) * n))
            t3 = np.exp(-0.5 * delt2)
            gw[int(m + rows/2 - 1),int(n + cols/2 - 1)] = (kn2 / delt2) * t1 * (t2 - t3)

    return gw

For plotting the wavelets(or is it filters?) For scale = 1 to 4 and orientation = 1 to 8, these are the wavelets produced(plotting the real part): 用于绘制小波(或它是滤波器吗?)对于比例= 1到4和方向= 1到8,这些是产生的小波(对实部进行绘图):

R = 128
C = 128

kmax = np.pi / 2
f = np.sqrt(2)
delt2 = (2 * np.pi) ** 2
fig = plt.figure()
for v in range(1, 5):
    for u in range(1, 9):
        gw = gabor_wavelet(R, C, kmax, f, u, v, delt2)
        fig.add_subplot(4, 8, 8*(v-1) + u)
        plt.imshow(np.real(gw), cmap='gray')

plt.show()

Resulting plots: 结果图: Gabor小波图

Now, the main focus is, I have the image of the retina, specifically the inverted green channel where the blood vessels are highly contrasted. 现在,主要的焦点是,我有视网膜的图像,特别是血管高度对比的倒置绿色通道。 I have to do " some operation " on it, using one of the above wavelets(or filters? please correct me here the difference between filter and wavelet). 我必须使用上面的小波(或滤波器之一)对其执行“ 某些操作 ”,请在此处更正滤波器和小波之间的区别。

What is the operation that I have to perform between the wavelet I have obtained and the image to increase the contrast of the vessels?: 为了增强血管的对比度,我在获得的小波和图像之间必须执行什么操作 ?:

在此处输入图片说明

Here is the image of absolute value of the wavelet too: 这也是小波绝对值的图像:

在此处输入图片说明

Kindly help me with this. 请帮助我。 I am stuck here from few days without much help from googling and reading papers. 几天以来,我一直被困在这里,而谷歌搜索和阅读论文没有太多帮助。 I am a beginner in the field. 我是该领域的初学者。

Thanks a lot 非常感谢

You need to apply a convolution. 您需要应用卷积。 You convolve the image with the Gabor kernel, then take the magnitude of the complex result. 将图像与Gabor内核卷积,然后取复杂结果的大小。

The convolution with OpenCV in Python is applied using the cv2.filter2D function. 使用cv2.filter2D函数应用Python中与OpenCV的卷积。 I presume it'll look something like: 我认为它看起来像:

gw = gabor_wavelet(R, C, kmax, f, u, v, delt2)
result = cv2.filter2D(image, CV_32F, gw)
result = np.absolute(result)

But maybe OpenCV doesn't do complex filters, then it's: 但是也许OpenCV不执行复杂的过滤器,那么它是:

gw = gabor_wavelet(R, C, kmax, f, u, v, delt2)
resultR = cv2.filter2D(image, CV_32F, np.real(gw))
resultI = cv2.filter2D(image, CV_32F, np.imag(gw))
result = np.hypot(resultR, resultI)

Disclamer : I haven't run any of the code above, and don't even have OpenCV installed. Disclamer :我没有运行以上任何代码,甚至没有安装OpenCV。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM