Re: Fast Image access for binarization
- From: Martin Brown <|||newspam|||@nezumi.demon.co.uk>
- Date: Tue, 28 Feb 2006 09:09:50 +0000
siddharth wrote:
hi,
is there any way to access image data efficiently to speedup the global
binarization code speed. our code is taking abt 40msec right now but we
need to reduce it down to 5-10msec.
our loop is like this:
for(i = 0; i < (width * height); i++)
{
if (image[i] > threshold)
image[i] = 1;
else
image[i] = 0;
}
image size is 512x512 to 4096x4096
there are different checks involved but we r trying to remove them from
the loop completely. this one check however cannot be moved out of the
loop.
On some architectures
image[i] = (image[i]>threshold);
may be faster since there is no branch in the loop. You are then a hostage to the values the system uses for true and false but you avoid a making an unpredictable branch if the threshold is near the median.
is there any platofrm and hardware independent way of speeding up this
code?
Not significantly provided that the optimising compiler is half decent (not always a safe assumption). The simplest way to check is disaasemble the generated code and examine it.
It is possible that explicit use of pointers might be slightly quicker (but these days unlikely if the optimiser is any good).
All other go faster stripes come with machine dependencies of one sort or another.
any unique solutions to this problem? please help us out.
Loop unrolling might help (but on modern machines with clever branch prediction and limited instruction cache could also hinder).
SIMD on x86 MMX instructions and vectorised routines in MSC like __mm_cmpgt_pi8 should be a fair bit faster provided your array is correctly aligned. It takes 8 bytes in parallel and compares them in a single instruction using dedicated hardware support.
Regards,
Martin Brown
.
- References:
- Fast Image access for binarization
- From: siddharth
- Fast Image access for binarization
- Prev by Date: Re: Orthogonal Filter vs Biorthogonal Filter
- Next by Date: Re: Fast Image access for binarization
- Previous by thread: Re: Fast Image access for binarization
- Next by thread: Re: Fast Image access for binarization
- Index(es):
Relevant Pages
|
Loading