I want to create high pass filter from low pass filter in Python. My code:

h_lowpass = lp_design_window(fc, N, window)   
dirac_delta = np.concatenate((np.ones(1), np.zeros(h_lowpass.shape[0] - 1)))
h_highpass = dirac_delta - h_lowpass

where lp_design_window is the function with arguments: cutoff frequency, number of coefficients and window function - and returns coefficients of low pass filter using window method. It attenuates desired frequencies, but not enough. Is it something wrong with dirac_delta? Or maybe I should search for the problem somewhere else?


You need to line up your direc_delta with the center tap of your low pass filter. Put the 1 in the middle at N/2.

  • $\begingroup$ works fine, thank you $\endgroup$
    – skeleton32
    Apr 21 '20 at 22:29
  • $\begingroup$ @skeleton32 if it worked you should mark his answer as correct so it closes the question out $\endgroup$ Apr 22 '20 at 3:26

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.