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

Function M3d

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

Compute cumulative moments

Source from the content-addressed store, hash-verified

136
137// Compute cumulative moments
138void M3d(ILint *vwt, ILint *vmr, ILint *vmg, ILint *vmb, ILfloat *m2)
139{
140 ILushort ind1, ind2;
141 ILubyte i, r, g, b;
142 ILint line, line_r, line_g, line_b, area[33], area_r[33], area_g[33], area_b[33];
143 ILfloat line2, area2[33];
144
145 for (r = 1; r <= 32; r++) {
146 for (i = 0; i <= 32; i++) {
147 area2[i] = 0.0f;
148 area[i]=area_r[i]=area_g[i]=area_b[i]=0;
149 }
150 for (g = 1; g <= 32; g++) {
151 line2 = 0.0f;
152 line = line_r = line_g = line_b = 0;
153 for (b = 1; b <= 32; b++) {
154 ind1 = (r<<10) + (r<<6) + r + (g<<5) + g + b; // [r][g][b]
155 line += vwt[ind1];
156 line_r += vmr[ind1];
157 line_g += vmg[ind1];
158 line_b += vmb[ind1];
159 line2 += m2[ind1];
160 area[b] += line;
161 area_r[b] += line_r;
162 area_g[b] += line_g;
163 area_b[b] += line_b;
164 area2[b] += line2;
165 ind2 = ind1 - 1089; // [r-1][g][b]
166 vwt[ind1] = vwt[ind2] + area[b];
167 vmr[ind1] = vmr[ind2] + area_r[b];
168 vmg[ind1] = vmg[ind2] + area_g[b];
169 vmb[ind1] = vmb[ind2] + area_b[b];
170 m2[ind1] = m2[ind2] + area2[b];
171 }
172 }
173 }
174
175 return;
176}
177
178
179// Compute sum over a Box of any given statistic

Callers 1

iQuantizeImageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected