0
$\begingroup$

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

enter image description here

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

enter image description here


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?!

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

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

$\endgroup$
3
  • $\begingroup$ I did this, it gets to center but it is a quarter of a circle. I don't know where the problem is. $\endgroup$ Apr 24 '20 at 22:01
  • $\begingroup$ How about when you take absolute values around mid point as I updated in the answer? $\endgroup$ Apr 24 '20 at 22:28
  • $\begingroup$ Yes, Finally it is work Thank you so much $\endgroup$ Apr 24 '20 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.