> Hi all
>
[quoted text clipped - 20 lines]
>
> Is it possible to improbe?
Use a table of logarithms instead of calculating it. You didn't show any of
the types involved, but presumably you're using 8 bits per pixel (or per
component), so a 256-entry table would suffice.
-cd
Andrea Sansottera - 24 Feb 2005 11:18 GMT
> Use a table of logarithms instead of calculating it. You didn't show any of
> the types involved, but presumably you're using 8 bits per pixel (or per
> component), so a 256-entry table would suffice.
Another solution could be to approximate the logaritm function with
precomputated taylor polynomials (it depends on the precision you need),
maybe it may be a little faster... but I'm not sure about that. Any opinion?

Signature
Andrea Sansottera
UGIdotNET [Italian] http://www.ugidotnet.org
My weblog [Italian] http://blogs.ugidotnet.org/andrew/
>Hi all
>
[quoted text clipped - 18 lines]
>}
>this part of the code takes 200mSec
I don't know the type of S[][], but even if it is double you can
probably create a reasonable table of doubles, there is a range limit
on the output (one byte I assume), so accuracy is not the ultimate
need. You need sufficient accuracy to produce valid output.
If S[][] are bytes, you need a simple 256-byte lookup table, as Carl
suggested. Otherwise, you may need a bit wider table -- but I would
think no larger than 64KB. if S[][] are doubles, you'll need to reduce
them to fit the table; but considering the limited output range, this
shouldn't be a problem.
Once built, this table will allow you to do your calculations in a
tiny amount of time.
--
Sev
mosimu - 23 Feb 2005 21:01 GMT
You can simplify one of the inner equations like so. Multiplying two
thirty-two bit numbers takes many cycles.
for (i=0;i<iDepth;i++) {
int c = i*(iDepth+2);
for (j=0;j<aLength;j++) {
lpBmpValue = lpBmp1 + j + c;
*lpBmpValue =dContrast*(10*log10(S[i][j])+dBrightness);
}
}
mosimu
> >Hi all
> >
[quoted text clipped - 35 lines]
> --
> Sev
Steve McLellan - 23 Feb 2005 21:41 GMT
The log is definitely where the performance is going though; one of our
applications (without the vectorised maths code we use) spends over 20% of
its calculation time in each of a log and exponential calculation that can't
be tabulated unlike (as Carl pointed out) this case. We've found this on
both PCs and Macs, where other maths operations are relatively inexpensive.
Steve
> You can simplify one of the inner equations like so. Multiplying two
> thirty-two bit numbers takes many cycles.
[quoted text clipped - 48 lines]
>> --
>> Sev