Message Boards Message Boards

0
|
4650 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

Does MovingAverage work correctly on multi-dimensional Lists ?

Posted 10 years ago

Hi Community,

I am trying to create an artificial wavefront by using RandomReal and MovingAverage. Here is the code:

rframe = RandomReal[{rmin, rmax}, {rsize, rsize}];
mframe = MovingAverage[Transpose[MovingAverage[rframe, aveblks] ], aveblks];

where:

rmin=0; 
rmax=562*10^(-9);
aveblks=10;
dsize=256;
rsize=dsize+aveblks-1;

When I plot mframe with :

ArrayPlot[mframe, PlotRange -> {0.0, 4*10^(-7)}]

I see the attached image. It looks to me that there are 1 pixel wide longer streaks both vertically and horizontally. I expected a smoother image where these streaks are averaged out by MovingAverage. I really do not want to do interpolation here. Any good tip how to make it happen?

Thanks ahead, János

Attachments:
POSTED BY: Janos Lobb

Yes, the code is working correctly. The code you wrote below:

 MovingAverage[Transpose[MovingAverage[rframe, aveblks] ], aveblks]

Basically says "Smooth the data out horizontally and then smooth it veritically". This will produce the pattern you are seeing.

What you really wanted was a 2d convolution with some smooting kernel that's circular. So for example we can apply a gaussian filter:

ArrayPlot[GaussianFilter[rframe, 5]]

enter image description here

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract