3x3 average filter

Post any questions, ideas, or topics related to Jython and Python scripting.
User avatar
kbedka1
Posts: 428
Joined: Wed Jan 28, 2009 7:27 pm

Re: 3x3 average filter

Post by kbedka1 »

I figured out after my post that it only works with ADDE. Yes, please post this when you get a chance, next week is fine. Thanks for the help.
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: 3x3 average filter

Post by tomw »

Kris -- here is a modified form of the 9 point filter that is designed to work with that fields that do not have a "time" dimension. While it is possible to create just one routine for this, I don't have the time right now to do that....sorry...

tom

Code: Select all

def singleTimeNinePointFilter(sdataset):
 newData = sdataset.clone();
 newVals = newData.getFloats();
 srcVals = sdataset.getFloats();
 (elementSize, lineSize) = getDomainSizes(sdataset);
 for i in xrange(1,lineSize-1):
  k = i*elementSize;
  for j in xrange(1,elementSize -1):
    newVals[0][k+j] = (srcVals[0][k+j] + srcVals[0][k+j-1] + srcVals[0][k+j+1]
            + srcVals[0][k+j-elementSize] + srcVals[0][k+j-elementSize-1] +
              srcVals[0][k+j-elementSize + 1]
            + srcVals[0][k+j+elementSize] + srcVals[0][k+j+elementSize-1] +
              srcVals[0][k+j+elementSize + 1]) / 9;
 newData.setSamples(newVals);
 return newData;
Post Reply