Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Thanks LBerger!

As I understand second step is "multiply by filter"... but how to calculate appropriate convolution kernel and how to apply it in frequential domain? Please see below code:

img = cv2.imread("sad.jpg", 0)

# fft to convert the image to freq domain
f = np.fft.fft2(img)

**#  HOW TO APPLY GAUSSIAN FILTER HERE ?**

# inverse fft to get the image back
img_back = np.fft.ifft2(f)

img_back = np.abs(img_back)

plt.subplot(131), plt.imshow(img, cmap = 'gray')
plt.title('Input image'), plt.xticks([]), plt.yticks([])
plt.subplot(132), plt.imshow(img_back, cmap = 'gray')
plt.title('Image after HPF'), plt.xticks([]), plt.yticks([])
plt.subplot(133), plt.imshow(img_back)
plt.title('Final result'), plt.xticks([]), plt.yticks([])


plt.show()