Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

anybody got a complex 2-D median filter script they can share?

216 views
Skip to first unread message

Cameron

unread,
Mar 4, 2011, 10:10:20 AM3/4/11
to
Hi,

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

Matt J

unread,
Mar 4, 2011, 10:38:07 AM3/4/11
to
"Cameron " <cameron....@yahoo.com> wrote in message <ikqvcs$dpd$1...@fred.mathworks.com>...

> Hi,
>
> 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!
============

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?

Matt J

unread,
Mar 4, 2011, 10:46:05 AM3/4/11
to
"Matt J" wrote in message <ikr10v$2e3$1...@fred.mathworks.com>...

>
> > 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!
> ============
>
> 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));

Cameron

unread,
Mar 4, 2011, 10:56:20 AM3/4/11
to
"Matt J" wrote in message <ikr1fs$2g0$1...@fred.mathworks.com>...

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.

Matt J

unread,
Mar 4, 2011, 11:09:20 AM3/4/11
to
"Cameron " <cameron....@yahoo.com> wrote in message <ikr234$d89$1...@fred.mathworks.com>...

>
>
> 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.

Cameron

unread,
Mar 4, 2011, 11:42:04 AM3/4/11
to
"Matt J" wrote in message <ikr2rg$345$1...@fred.mathworks.com>...
=================================
Fair enough... I am looking at two views of the same area. my data is coherently sampled so I have phase data. because I am looking at the area from different vantage points I have a different grazing angle and there is speckle associated with the phase offset.

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?

Matt J

unread,
Mar 4, 2011, 1:12:03 PM3/4/11
to
"Cameron " <cameron....@yahoo.com> wrote in message <ikr4os$515$1...@fred.mathworks.com>...

>
> since phase wraps around, I don't think a conventional median filter will necessarily provide any meaningful data.
============

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.

Cameron

unread,
Nov 13, 2012, 5:55:19 PM11/13/12
to
"Matt J" wrote in message <ikra1j$ani$1...@fred.mathworks.com>...
Hey you still there? took me long enough... anyhow, I think "math" was a poor choice of words on my part. I guess if a median filter is analagous to an edge preserving low pass filter, then I am concerned that there is no value to the edges in a low pass of a phase signal. what I really want to preserve are the phase components that aren't noise and that aren't impacted by the different grazing angles. its sort of like two cameras looking at different angles of the same picture, and the cameras get phase data that lets the light be sampled coherently. whats of value in that coherence between the two views? I don't know if a median filter will get it.
0 new messages