comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Convolution with non-constant Kernel?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Convolution with non-constant Kernel? [message #73573 is a reply to message #73468] Fri, 19 November 2010 02:07 Go to previous messageGo to previous message
rogass is currently offline  rogass
Messages: 200
Registered: April 2008
Senior Member
Hi, try the following routines for 2D images and 2D mask or mask sized
[maskx,masky,n_elements(image)],whereas boundary pixels are not
considered, large images and small masks will cause heavy memory
usage:

function cr_discrete_convolve,mask,im
szm = ulong(size(mask,/dimensions))
szi = ulong(size(im,/dimensions))
return, reform(/
over,total(total(im[cr_window(szi[0],szi[1],szm[0],szm[1])]* $
n_elements(szm) eq 2? rebin(/
sample,mask,szm[0],szm[1],szi[0]*szi[1]):$
mask,2),1),szi[0],szi[1])
end

function cr_window,sx,sy,wx,wy,norot=norot
wx = ulong(wx)
wy = ulong(wy)
sx = ulong(sx)
sy = ulong(sy)
base = ((ll=ulindgen(wx,wy) mod wx)) + transpose(ll)*sx
return, rebin(/sample,(keyword_set(norot)? temporary(base) : $
rot(reform(/over,temporary(base),wx,wy),180)),wx,wy,sx*sy) + $
rebin(/sample,ulindgen(1,1,sx*sy),wx,wy,sx*sy)
end


Cheers

CR
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: plot of implicit function
Next Topic: Re: IDLPong, a Pong game in IDL.

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Tue Dec 02 08:06:28 PST 2025

Total time taken to generate the page: 1.12621 seconds