[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

avoiding for loops

I've had such good luck recently with y'all that I thought I'd send
another one.  Although this is a little less esoteric.  I need to
apply a median filter all the way to the edges of an image.  So I came
up with putting an edge around it the width of the filter then
selecting out the original region.  Sort of what convol does

The following code is what I came up with.  It works, but it is clunky
as heck.  I know some of you guys are wizzes at getting rid of loops.
Care to lend a hand?

p.s. the data I'm working on array 4000x512 arrays not 100x100!


n = 3
bottshade = shift(dist(100),10)+randomu(100,100,100)*5.
azrange = 100
shotrange = 100
temp = fltarr(shotrange +2*n,azrange + 2*n)
temp(n,n) = bottshade
for i = 0,shotrange -1 +2*n do begin
   temp(i,0:n-1) = temp(i,n)
   temp(i,azrange-1+n:azrange-1+2*n) = temp(i,azrange +n - 2)
for i = 0,azrange -1 +2*n do begin
   temp(0:n-1,i) = temp(n,i)
   temp(shotrange-1+n:shotrange-1+2*n,i) = temp(shotrange +n - 2,i)
temp2 = median(temp,n)
bottshade = temp(n:n+shotrange-1,n:n+azrange)


Arete Associates
Tucson, Arizona