MCPcopy Create free account
hub / github.com/DentonW/DevIL / Hist3d

Function Hist3d

DevIL/src-IL/src/il_quantizer.cpp:89–122  ·  view source on GitHub ↗

Build 3-D color histogram of counts, r/g/b, c^2

Source from the content-addressed store, hash-verified

87
88// Build 3-D color histogram of counts, r/g/b, c^2
89ILboolean Hist3d(ILubyte *Ir, ILubyte *Ig, ILubyte *Ib, ILint *vwt, ILint *vmr, ILint *vmg, ILint *vmb, ILfloat *m2)
90{
91 ILint ind, r, g, b;
92 ILint inr, ing, inb, table[2560];
93 ILuint i;
94
95 for (i = 0; i < 256; i++)
96 {
97 table[i] = i * i;
98 }
99 Qadd = (ILushort*)ialloc(sizeof(ILushort) * size);
100 if (Qadd == NULL)
101 {
102 return IL_FALSE;
103 }
104
105 imemclear(Qadd, sizeof(ILushort) * size);
106
107 for (i = 0; i < size; i++)
108 {
109 r = Ir[i]; g = Ig[i]; b = Ib[i];
110 inr = (r>>3) + 1;
111 ing = (g>>3) + 1;
112 inb = (b>>3) + 1;
113 Qadd[i] = ind = (inr<<10)+(inr<<6)+inr+(ing<<5)+ing+inb;
114 //[inr][ing][inb]
115 vwt[ind]++;
116 vmr[ind] += r;
117 vmg[ind] += g;
118 vmb[ind] += b;
119 m2[ind] += (ILfloat)(table[r]+table[g]+table[b]);
120 }
121 return IL_TRUE;
122}
123
124/* At conclusion of the histogram step, we can interpret
125 * wt[r][g][b] = sum over voxel of P(c)

Callers 1

iQuantizeImageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected