Re: Fast Image access for binarization
- From: pavel.holoborodko@xxxxxxxxx
- Date: 28 Feb 2006 02:15:53 -0800
Hi,
If pixel value range is 0..255 than you can efficiently remove checks
by lookup-table. Assuming that image has type unsigned char*, than:
unsigned char *curpixel, *stop;
unsigned char bin_tbl[256];
for(i=0;i<256;i++)
if(i>threshold)
bin_tbl[i] = 1;
else
bin_tbl[i] = 0;
stop = image+width*height;
for(curpixel = image; curpixel<stop; curpixel++)
*curpixel = bin_tbl[*curpixel];
Since bin_tbl small it will be in CPU cache all the time during
processing. So, memory access time to bin_tbl is negligible. Also
bin_tbl initialization loop is fast. It doesn't add any processing
time.In the same time the main
bottleneck is improved - no comparisons in loop body.
.
- References:
- Fast Image access for binarization
- From: siddharth
- Fast Image access for binarization
- Prev by Date: Re: Fast Image access for binarization
- Next by Date: Re: References/ Journals for license plate recognition
- Previous by thread: Re: Fast Image access for binarization
- Next by thread: Last Resort
- Index(es):
Relevant Pages
|