The situation
I need to apply a high pass filter to an image. The approach I'm following uses Fourier transform to apply a circular filter which would eliminate low frequencies.
Say I have a frequency threshold below which frequencies should be filtered out, i.e. cut-off frequency.
The resulting spectogram shape of the FTT operation is the same than the image, hence I am not sure how to link the radius value of the mask to the cut-off frequency of interest.
The code
# read image
image = cv2.imread('path/image_name.jpg', 0)
img = np.asarray(image)
# FFT
dft = cv2.dft(np.float32(img), flags=cv2.DFT_COMPLEX_OUTPUT)
dft_shift = np.fft.fftshift(dft)
magnitude_spectrum = 20 * np.log(cv2.magnitude(dft_shift[:,:,0], dft_shift[:,:,1]))
# center of image
rows, cols = img.shape
crow, ccol = int(rows/2), int(cols/2)
# create mask - circular filter
mask = np.ones((rows, cols, 2), np.uint8)
r=4.34
center = [crow, ccol]
x, y = np.ogrid[:rows, :cols]
mask_area = (x - center[0])**2 + (y - center[1])**2 <= r*r
mask[mask_area] = 0
# apply filter
fshift = dft_shift * mask
# return to spatial domain
f_ishift = np.fft.ifftshift(fshift)
img_back = cv2.idft(f_ishift)
img_back = cv2.magnitude(img_back[:,:,0], img_back[:,:,1])
The question
What is the intuition for the radius choice for the mask? I understand that a higher the radius will filter out more frequencies. However, how would I know that frequencies above the threshold are not being affected by the filter?