Re: Fast Image access for binarization
- From: "RoboRealm" <contact@xxxxxxxxxxxxx>
- Date: 27 Feb 2006 22:29:48 -0800
Siddharth,
you may at least want to reduce the width*height in the for loop. On
each iteration you're doing a multiplication that is not really needed
(assuming the compiler doesn't optimize this out).
Perhaps you can also try
int image[512*512];
int *pixel = image;
int *end = &image[512*512];
while (pixel!=end)
{
*pixel++ = *pixel>threshold;
}
and see if this makes a difference. Note that some compilers may not
compile the *pixel++ correctly. Also if you can make the 'threshold' a
constant that may help a little too.
You may also find that adding a
if (*pixel)
*pixel++ = *pixel>threshold;
else
pixel++;
may also make a difference depending on how your CPU caches read versus
write memory statements. Note that uneeded writes can sometimes be more
expensive than a read and comparison from a cache ... but this is very
CPU dependant.
Hope this helps!
STeven.
http://www.roborealm.com/
Where robots live ...
.
- Follow-Ups:
- Also,
- From: aruzinsky
- Re: Fast Image access for binarization
- From: RoboRealm
- Also,
- References:
- Fast Image access for binarization
- From: siddharth
- Fast Image access for binarization
- Prev by Date: Re: Object tracking
- Next by Date: Re: Fast Image access for binarization
- Previous by thread: Fast Image access for binarization
- Next by thread: Re: Fast Image access for binarization
- Index(es):
Relevant Pages
|