I am in a bit of a time crunch and am looking for a script to handle 2-D complex data with a median filter. long story short I've been doing the operation wrong and getting good results with bad math. any assistance is appreciated!
- Cam
median filtering relies on the ability to sort/order the input data. Since your data is complex valued, how would you define an ordering for it, on which to base calculations of the medians?
If you mean that you just want to median filter the real and imaginary part of the image separately, you could just do
X_filtered = medfilt2(real(X))+i*medfilt2(imag(X));
Thats essentially what I was doing before. I think it violates some part of signal processing to do it that way though and is just filtering out a bunch of stuff I don't want serendipitously. I am trying to preserve a phase characteristic of the complex imaginary data. there are a few papers on IEEE about the application for complex weighted median filters, but frankly I don't think I have time to digest the math and get a script written.
So your 2D image is frequency domain data? Maybe you just want to filter the amplitude response and keep the phase, e.g.,
X=medfilt2(abs(X)).*angle(X)
In any case, I doubt you're going to find anyone on here (quickly) who is familiar with the few obscure IEEE papers that you've alluded to. You'd best start describing your problem in enough detail for people to make suggestions.
I don't want to discard the phase information entirely so I don't want to look at the magnitude. I found for the application a median filter works very well, but I want analyze the phase data with it and the standard medfilt2 algorithm only works on real numbers.
since phase wraps around, I don't think a conventional median filter will necessarily provide any meaningful data.
SO - I guess an addendum to this request for help would be:
if I median filter the amplitude,then separately median filter the phase or angle and then resolve the two datasets to a complex number, is the math in fact non-valid?
Well, you could apply the filter in regions where the signals are supposed to be continuous (i.e., for phase, not near pi and -pi) and then fill in the holes with some sort of extrapolation.
> SO - I guess an addendum to this request for help would be:
>
> if I median filter the amplitude,then separately median filter the phase or angle and then resolve the two datasets to a complex number, is the math in fact non-valid?
===============
What math are you referring to? What equations need to be satisfied? The main concern I would have is if your complex data is going to be passed through some sort IFFT operation. In that case, errors in the median filtering could propagate spatially throughout the entire result.