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

Function Var

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

Compute the weighted variance of a Box NB: as with the raw statistics, this is really the variance * size

Source from the content-addressed store, hash-verified

257// Compute the weighted variance of a Box
258// NB: as with the raw statistics, this is really the variance * size
259ILfloat Var(Box *cube)
260{
261 ILfloat dr, dg, db, xx;
262
263 dr = (ILfloat)Vol(cube, mr);
264 dg = (ILfloat)Vol(cube, mg);
265 db = (ILfloat)Vol(cube, mb);
266 xx = gm2[cube->r1][cube->g1][cube->b1]
267 -gm2[cube->r1][cube->g1][cube->b0]
268 -gm2[cube->r1][cube->g0][cube->b1]
269 +gm2[cube->r1][cube->g0][cube->b0]
270 -gm2[cube->r0][cube->g1][cube->b1]
271 +gm2[cube->r0][cube->g1][cube->b0]
272 +gm2[cube->r0][cube->g0][cube->b1]
273 -gm2[cube->r0][cube->g0][cube->b0];
274
275 return xx - (dr*dr+dg*dg+db*db) / (ILfloat)Vol(cube, wt);
276}
277
278/* We want to minimize the sum of the variances of two subBoxes.
279 * The sum(c^2) terms can be ignored since their sum over both subBoxes

Callers 1

iQuantizeImageFunction · 0.85

Calls 1

VolFunction · 0.85

Tested by

no test coverage detected