Multiply image kernels

594 Views Asked by At

If I have 3 image kernels (edge detection, sharpen, box blur) and want to perform each to an image in that order. Can I multiply the 3 together in some way and apply them to my image in one go?

Here are examples of the kernels -> http://en.wikipedia.org/wiki/Kernel_(image_processing)

If it is possible, like 3d transformation matrices, how would I go about doing it?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

In theory you can. The trick is to convolve the first filter with the first (as if the filter kernel was an image), then the result with the third (in the spatial domain), or to multiply the transforms (in the Fourier domain).

But in practice, this won't help you because

  • the edge detection filter is not a pure convolution (there is at least an absolute value); this is a nonlinear operation that will not commute with the other convolutions.

  • even if your package provides a way to convolve the kernels together, you will end up with a larger, general-purpose kernel, and the resulting filter will be much slower. You will lose the built-in optimizations of the predefined ones.

If the expected benefit is a speedup in processing, this is not the right approach in the general case with spatial domain filter implementations.

Assume filter sizes $p^2, q^2, r^2$; the combined filter will have size $(p+q+r)^2$. The computational cost of the filter cascade is more attractive because $$p^2+q^2+r^2<(p+q+r)^2.$$