Simon Johan wrote:
> 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.
>
I find it difficult to imagine any modern hardware where a lookup in a
dynamic table would be faster than an integer multiplication (division
could be different, but even that is getting pretty good on modern
processors)
There is a place for lookup tables but they need to be for operations
that are rather more computational demanding (20 years ago I used a 257
element (each 4 bytes) for sines and cosines (the table covered a right
angle and used linear interpolation for intermediate values, it actually
worked fast and efficiently)
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|