# Ideal low-pass filter in the Frequency Domain

I try to create a low-pass filter to apply it for an image.

$$H(U, V)=1 \text{, if }D(U,V) ≤ D_0 \text{, and } 0 \text{ otherwise}$$

and $$D(U, V) = \sqrt{U^2 + V^2}$$

U,V = np.shape(padded)
H = np.zeros((U,V))
D = np.zeros((U,V))
#cut off point
D0 = 5
for u in range(U):
for v in range(V):
D[u,v] = np.sqrt(u**2+v**2)
if D[u,v] <= D0:
H[u,v] = 1
else:
H[u,v] = 0
plt.imshow(H,cmap='gray')
plt.show()


After I Run it I expect this image

But I get this circle at the left top of the image as bellow :

so I think I should get the center of $$\frac{U}{2}$$ and $$\frac{V}{2}$$ but I do not know how.

How can I get the expected filter image?!

• Can you share the original signal?
– GKH
Apr 24 '20 at 20:42
• @GKH I just want to create this filter Apr 24 '20 at 21:57

The rule should be something like this i suppose $$D(|U - U_o/2|,|V - V_o/2|)≤ D0$$ where $$U_o$$ is the length of image in horizontal dimension and $$V_o$$ is the length of image in vertical dimension