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

Home » Public Forums » archive » Re: faster convol on local subsets?
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: faster convol on local subsets? [message #78632 is a reply to message #78631] Sun, 04 December 2011 17:19 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Dec 4, 7:37 pm, Andre <note....@gmail.com> wrote:
> Hello experts,
>
> Maybe somebody has an easy solution for this?
> I have a 2D array (img) and want the filter response from kernels that vary according to the image position. In a second array (loc, same dimensions as img) I have the information which kernel should be used at each pixel. My current approach is to first convolve the full image with the j-th kernel and take the response only at the positions with the current j indexed in the loc array:
>
> for j=0, n do begin
>       kernel=kernel_store[*,*,j]
>       response_temp = convol(img, kernel, /edge_zero, /NAN)
>       index=where(loc eq j)
>       if (index[0] gt -1)then response[index]=response_temp[index]
> endfor
>
> I works fine, but it is relatively slow and I wonder if there is a smarter (faster) to apply only the convolutions that are really needed?
>
> Thanks in advance for any help!

Hi,

Since the value of loc doesn't change, you might try precomputing the
values of index in loc for each step, j. That would save a two full
scans of you loc array at each iteration (one for loc eq j and one for
WHERE). Instead, use HISTOGRAM with its REVERSE_INDICES to get them
sorted and tagged. Then for each iteration step use David Fanning's
REVERSEINDICES to grab the correct indices in loc.

So, it might look like...

locHist = HISTOGRAM(loc, min = 0, REVERSE_INDICES = ri)

for j=0, n do begin
kernel=kernel_store[*,*,j]
response_temp = convol(img, kernel, /edge_zero, /NAN)
index = REVERSEINDICES(ri, j, COUNT =
count)
if (count GT 0)then response[index]=response_temp[index]
endfor

Cheers,
Ben



http://www.idlcoyote.com/programs/reverseindices.pro
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Another Map Projection Problem with Map_Proj_Init
Next Topic: WIDGET_CONTROL: Invalid widget identifier: 2

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

Current Time: Wed Oct 08 15:28:21 PDT 2025

Total time taken to generate the page: 0.00366 seconds