From: stephen e. <ste...@gm...> - 2006-06-10 19:40:13
|
Thanks for all the help! Convolving looks like a great way to do this, and I think that mean will be just fine for my purposes. That iterator also looks fantastic and is actually the sort of thing that I was looking for at first. I havn't tried it yet though. Any idea how fast it would be? Stephen On 6/10/06, Alex Liberzon <ale...@gm...> wrote: > > Not sure, but my Google desktop search of "medfilt" (the name of > Matlab function) brought me to: > > info_signal.py - N-dimensional order filter. medfilt -N-dimensional > median filter > > If it's true, then it is the 2D median filter. > > Regarding the neighbouring cells, I found the iterator on 2D ranges on > the O'Reily Cookbook by Simon Wittber very useful for my PyPIV > (Particle Image Velocimetry, which works by correlation of 2D blocks > of two successive images): > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334971 > > def blocks(size, box=(1,1)): > """ > Iterate over a 2D range in 2D increments. > Returns a 4 element tuple of top left and bottom right coordinates. > """ > box = list(box) > pos = [0,0] > yield tuple(pos + box) > while True: > if pos[0] >= size[0]-box[0]: > pos[0] = 0 > pos[1] += box[1] > if pos[1] >= size[1]: > raise StopIteration > else: > pos[0] += box[0] > topleft = pos > bottomright = [min(x[1]+x[0],x[2]) for x in zip(pos,box,size)] > yield tuple(topleft + bottomright) > > if __name__ == "__main__": > for c in blocks((100,100),(99,10)): > print c > for c in blocks((10,10)): > print c > > > > HIH, > Alex > > > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |