Private
Public Access
Release 0.12.0
This commit is contained in:
1 parent
f74a658097
commit
7f6eeab39e
48 files changed
+3617
-1266
No files matched your search
+12
-6
@@ -4,12 +4,18 @@
|
||||
#include <stddef.h>
|
||||
/* LG ABI: region ID followed by three planar channels, 256 uint16 bins
|
||||
* per channel. Bin index is the 8-bit intensity (0..255). */
|
||||
typedef struct { uint32_t id; uint16_t bins[3][256]; } Histogram;
|
||||
_Static_assert(sizeof(Histogram)==0x604,"LG ABI record size");
|
||||
_Static_assert(offsetof(Histogram,bins)==4,"LG ABI channel offset");
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
uint16_t bins[3][256];
|
||||
} Histogram;
|
||||
_Static_assert(sizeof(Histogram) == 0x604, "LG ABI record size");
|
||||
_Static_assert(offsetof(Histogram, bins) == 4, "LG ABI channel offset");
|
||||
static inline unsigned char histogram_mean(const uint16_t bins[256]) {
|
||||
uint64_t count=0,weight=0;
|
||||
for(unsigned b=0;b<256;b++){count+=bins[b];weight+=(uint64_t)bins[b]*b;}
|
||||
return count?(unsigned char)((weight+count/2)/count):0;
|
||||
uint64_t count = 0, weight = 0;
|
||||
for (unsigned b = 0; b < 256; b++) {
|
||||
count += bins[b];
|
||||
weight += (uint64_t)bins[b] * b;
|
||||
}
|
||||
return count ? (unsigned char)((weight + count / 2) / count) : 0;
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user