# When to Use Composite Filters and When to Use Separable Filters?

I’m a beginner in image processing, and was wondering since seperated (decomposed) filters help give faster and more efficient results, when do we even need to use composite filters? All I heard is the advantages of decomposed filters,but what about composite filters?

• Are you talking in the context of deep learning or in general?
– Royi
Sep 14, 2021 at 0:50
• @Royi in general Sep 14, 2021 at 17:01

## Image Processing Context

In classic Image Processing the filters used are known.
Hence being separable is a property of a given filter which is suitable to the task.
In this context, separability only means we can have a more efficient way to apply the filter computationally while the end result is the same. So, in Image Processing, if you have a filter which is separable, use that.

## Deep Learning Context

In deep learning context, where the filters are learned, being separate is a constrained. Namely, it has a model behind it.
The main property of in this context, if only one 1D kernel is used, is separable filters are symmetric. So if you want to learn a symmetric filter (You can chose the axis by rotating) this is the way to go.
For instance, it makes sense in a filter detecting elongated edges.

In case we allow the filter to be built using 2 different 1d filters then the property we enforce is rank 1 filter.

• “separable filters are symmetric” this is not true. Separability and symmetry are two different, unrelated properties. It’s easy to compose a 2D filter using two arbitrary non-symmetric 1D filters. This composed filter will obviously be non-symmetric and separable. The first half of the answer is good, though. Sep 18, 2021 at 19:43
• I updated to be clearer about the assumption for symmetry.
– Royi
Sep 19, 2021 at 3:45
• So if you build a 2D filter by composing identical horizontal and vertical 1D filters, then you can transpose the matrix and get the same filter, so that's a form of symmetry, the answer is technically correct now. But it's not what I first think of when talking about a symmetric filter: mirror symmetry. You can only get that if you restrict the 1D filters to be symmetric. Sep 19, 2021 at 4:06
• You could always, in the DL implementation, add a rotation matrix so the symmetry would be along any axis. I wrote that.
– Royi
Sep 19, 2021 at 5:01

For any given problem definition, there's a filter that -- if you ignore execution time and hardware expense -- is "best"*. In general, that "best" filter isn't separable. Depending on the problem at hand, the degree to which the optimum degrades if you find the best separable filter will vary.

So -- sometimes a non-separable filter will give "better" results in the absence of considerations of processing expense. Sometimes it'll be so much better that it's just what you need to use (I can't think of any cases off hand, but -- just assume I'm right, for the sake of argument).

Even today, there's a lot of video processing that needs to be optimized for processor effort rather than striving for that theoretical "cost no object" optimum that you'll see a lot of attention paid to easy computational optimization, like using separable filters, or small kernels, or similar.

* I put "best" in quotes because it depends so heavily on the problem definition, and it can be fiendishly difficult to make a formal definition of "best" with what you really need.

• In quite a few situations, the Gaussian is the optimal low-pass filter. It also happens to be separable. This doesn’t contradict what you’re saying, but hopefully it qualifies the “in general” statement. Sep 18, 2021 at 19:40
• In what situations is the Gaussian filter optimal? I thought it was ofte chosen because many analytic approaches are easier to calculate using Gaussians, because 2-d Gaussians are separable, and because Gaussians seems to have a reasonable (ad-hoc) compromise between frequency response and space (or time) response for applications where humans are to watch the results? Sep 19, 2021 at 7:16