mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Opt imlib_integral_image
This commit is contained in:
parent
19121dec9f
commit
b621643763
@ -5,21 +5,22 @@
|
|||||||
|
|
||||||
void imlib_integral_image(struct image *src, struct integral_image *sum)
|
void imlib_integral_image(struct image *src, struct integral_image *sum)
|
||||||
{
|
{
|
||||||
int x, y, s,t;
|
typeof(*src->data) *data = src->data;
|
||||||
unsigned char *data = src->pixels;
|
|
||||||
typeof(*sum->data) *sumData = sum->data;
|
typeof(*sum->data) *sumData = sum->data;
|
||||||
|
|
||||||
for (y=0; y<src->h; y++) {
|
// Compute first column to avoid branching
|
||||||
s = 0;
|
for (int s=0, x=0; x<src->w; x++) {
|
||||||
|
/* sum of the current row (integer) */
|
||||||
|
s += data[src->w+x];
|
||||||
|
sumData[src->w+x] = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int y=1; y<src->h; y++) {
|
||||||
/* loop over the number of columns */
|
/* loop over the number of columns */
|
||||||
for (x=0; x<src->w; x++) {
|
for (int s=0, x=0; x<src->w; x++) {
|
||||||
/* sum of the current row (integer)*/
|
/* sum of the current row (integer) */
|
||||||
s += data[y*src->w+x];
|
s += data[y*src->w+x];
|
||||||
t = s;
|
sumData[y*src->w+x] = s+sumData[(y-1)*src->w+x];
|
||||||
if (y != 0) {
|
|
||||||
t += sumData[(y-1)*src->w+x];
|
|
||||||
}
|
|
||||||
sumData[y*src->w+x]=t;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user