Is it possible to create a single kernel which can help us to perform an 2 step image processing?

For example, I want to first perform a median filter on my image to remove salt and pepper noise and then perform a sharpen operation on it.

For this purpose, I have to perform the following operation

(image * Median_Kernel) *  sharpening kernel = final_image

I want to have a kernel which combines the effect of Median_kernel and sharpening it such that

image * combined_kernel = final_image

Is this mathematically possible? If so, could someone please explain to me how to do this mathematically?

  • 6
    $\begingroup$ Yes if each kernel is just a convolution. Sharpening algorithms may or may not be, median also usually is not. Read this $\endgroup$
    – joojaa
    Oct 10, 2017 at 15:27
  • $\begingroup$ It might depend on the actual kernel. Can you include the specific kernels you're talking about in the question? $\endgroup$ Oct 11, 2017 at 18:05
  • $\begingroup$ "Kernel" is not a synonym for "filter". There is no such thing as a median kernel. $\endgroup$
    – user106
    Oct 12, 2017 at 18:23

1 Answer 1


Why not just do them one after the other?

Img = (Img * median) * sharpen;

I think you should look into how these filter operations actually work before attempting to use them. It's pretty simple, use wikipedia or even any image processing textbook. Even the Matlab docs have good explanations.

Median filtering is a non linear filtering operation which means that there is no fixed kernel function for it. You may define a neighborhood size but other than that, nope, no kernel. Have you looked into how it works? I dont know how you could generate a "kernel" for a non-linear filtering operation.

Maybe a basic refresher in Image Processing is in order? Perhaps even going over basics of Signal Processing / DSP? I would suggest looking over 2D filtering if you can.


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.