How to convert an image to FFT mask?

maybe the following code worth to try if you still trying to solve your previous question.

import cv2
import numpy as np

img = cv2.imread('d:/test/pt4.png', cv2.IMREAD_GRAYSCALE) # load an image as GRAYSCALE

ed = cv2.ximgproc.createEdgeDrawing()
ed.detectEdges(img)
grad_img = np.float32(img)

grad_img = ed.getGradientImage()

cv2.imshow("",grad_img*255)
cv2.waitKey()

a