filter that uses elements from two arrays at the same time
- by Gacek
Let's assume we have two arrays of the same size - A and B.
Now, we need a filter that, for a given mask size, selects elements from A, but removes the central element of the mask, and inserts there corresponding element from B.
So the 3x3 "pseudo mask" will look similar to this:
A A A
A B A
A A A
Doing something like this for averaging filter is quite simple. We can compute the mean value for elements from A without the central element, and then combine it with a proper proportion with elements from B:
h = ones(3,3);
h(2,2) =0;
h = h/sum(h(:));
A_ave = filter2(h, A);
C = (8/9) * A_ave + (1/9) * B;
But how to do something similar for median filter (medfilt2 or even better for ordfilt2)