3
$\begingroup$

When high or low pass filters are being applied to an (grayscale) image, the borders need to be handled separately. They could be filled with 0's or 255's (b/w), repeat the nearest pixel value, or even the image could be repeated.

How do the different border-handling-methods impact the result of he filtering operations? What are the pro's and con's of using one method over an other with a HPF to improve the edges in a picture or a LPF to blur it?

OpenCV for example has various BorderTypes like BORDER_REPLICATE or BORDER_CONSTANT but I can't find any information about what happens when I use one of them with a HPF or LPF.

$\endgroup$

2 Answers 2

1
$\begingroup$

I guess it depends on the kind of filter and the use/expectations of its output.

For a lowpass filter where you want to look at a smoothed waveform, perhaps replicating the first sample is a good solution.

For a highpass filter where you want to detect edges, the above solution would still introduce a non-smooth derivative. So perhaps mirroring and flipping is a good solution.

For higher-order applications where you want smoothness/continuity in higher order derivatives? I dont know.

$\endgroup$
0
$\begingroup$

HPF or LPF linear operators. It means that an operation at pixel position i, j will only be affected by neighbors within the window size of your filter. Pixels outside the filter will not play a role - in other words, the effects of any filtering operation is localized around its support. Typically, if the image size post filtering is not a concern, we 0 pad an image and crop out the contents near the border with a size equal to half the filter window. To maintain the same size, it is advisable to replicate border values.

$\endgroup$
1
  • $\begingroup$ A recursive (iir-) filter is linear but will in principle have infinite support, though. $\endgroup$
    – Knut Inge
    Commented Nov 10, 2021 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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