1
$\begingroup$

I am applying a low-pass filter to X ray images, which changes the pixel distribution such that the background goes from black to gray. In the attached figure, this amounts to the mode increasing from 0 to 50. I want to postprocess the filtered images to have a black background, while minimizing additional information loss. One idea I have is to compute the mode of the filtered image, then reduce the brightness of the image by this amount. Is there a less ad-hoc way of achieving my goal?

Here is my procedure for low-pass filtering:

  1. Apply DFT to the input image
  2. Shift DC component to the center
  3. Apply a radial filter, setting all frequencies outside of radius $r$ from the center to zero
  4. Inverse shift
  5. Inverse DFT
  6. Normalize pixel values to be in $[0, 1]$

pixels

$\endgroup$
  • $\begingroup$ What does happen if you filter an all-black image? If you have the same mode shift, you can compute it, and subtract it from the filtered image. But if so, the low-pass filter has a strange behavior. Could you describe it? $\endgroup$ – Laurent Duval Oct 29 '19 at 22:03
  • $\begingroup$ @LaurentDuval I edited my question to detail my filtering procedure. When I apply this to a black image, I get back the same black image. I realized a potential issue with step 3 - if the image has even height or width, then there is no center pixel, and my filter is asymmetric. Could this be problematic? $\endgroup$ – tmakino Oct 29 '19 at 23:44
  • 1
    $\begingroup$ @tmakino. It is not good idea to use zeroing bins of FFT results. Please, read - dsp.stackexchange.com/questions/6220/…. There is a lot standard low-pass filter. $\endgroup$ – SergV Oct 30 '19 at 3:55
  • $\begingroup$ Yes, an asymmetric filter could be a problem, and it could be that you accidentally resolved this with your change to a rectangular filter. You want the filter to be symmetric around whatever the 0,0 frequency bin was before you did your shift. (I usually do my filtering without shifting -- I just make a mask that's symmetrical around 0 (or 0,0) given that everything is modulo the data set size). $\endgroup$ – TimWescott Oct 30 '19 at 20:42
  • 1
    $\begingroup$ @SergV Thank you for pointing me in this direction. Both butterworth and Gaussian filters resolve this issue for me. The cause is that sharp discontinuities in frequency domain filters results in negative values in the corresponding spatial domain filters, which after $[0, 1]$ normalization causes the previously zero-valued background pixels to become positive. I'm noticing that this effect is much less pronounced for smooth filters. $\endgroup$ – tmakino Nov 2 '19 at 19:18

Your Answer

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

Browse other questions tagged or ask your own question.