Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Look-up table w...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 9543 of 9593
Post > Topic >>

Look-up table with anonymous functions

by "Simon Johan" <simon@[EMAIL PROTECTED] > Apr 24, 2008 at 03:43 PM

Hi all,

I'm programming some image convolutions which I want to speed up.When 
convolving an image (two-dimensional array of integers) with a filter
matrix

(the same), the center of the filter is placed on every image pixel and
the 
elements on top of each other are multiplied and summed. This implies that
a

lot of the same multiplications are performed and I got an optimization
idea

but I don't know if it is possible or practical in C++.

The idea is to generate a look-up table with all the computed 
multiplications, so when an output pixel is to be calculated it only 
multiplies numbers not previously multiplied. Otherwise it fetches the 
result from the table. Provided that a look-up operation is faster than a 
multiplication, this will lead to speed improvements.

For the actual implementation I was thinking something along the lines of 
having a data structure with keys being two two-tuples for the image and 
filter multiplicant indexes respectively and the value would be anonymous 
functions returning the multiplication of the appropriate elements. For 
example multi(<4,5>, <3,2>) would return a function returning image[4][5]
* 
filter[3][2]. After doing this the first, the multi data structure would
be 
updated so the anonymous function at multi(<4,5>, <3,2>) next time will 
return the result immediately, for example the value 98. The multi
structure

could be pre-allocated with these anoymous functions. I have a feeling
that 
this might be faster than setting boolean flags in a smiliar stucture to 
determine if a calculation has been performed.

Any ideas on this?

Thanks in advance!
Andreas 



-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]




 5 Posts in Topic:
Look-up table with anonymous functions
"Simon Johan" &  2008-04-24 15:43:19 
Re: Look-up table with anonymous functions
Greg Herlihy <greghe@[  2008-04-25 10:14:20 
Re: Look-up table with anonymous functions
Le Chaud Lapin <jaibud  2008-04-28 23:29:06 
Re: Look-up table with anonymous functions
Francis Glassborow <fr  2008-04-29 10:37:33 
Re: Look-up table with anonymous functions
Alan McKenney <alan_mc  2008-04-30 17:02:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 2:37:16 CDT 2008.