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

Function learn

DevIL/src-IL/src/il_neuquant.cpp:340–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338// ------------------
339
340void learn()
341{
342 ILint i,j,b,g,r;
343 ILint radius,rad,alpha,step,delta,samplepixels;
344 ILubyte *p;
345 ILubyte *lim;
346
347 alphadec = 30 + ((samplefac-1)/3);
348 p = thepicture;
349 lim = thepicture + lengthcount;
350 samplepixels = lengthcount/(3*samplefac);
351 delta = samplepixels/ncycles;
352 alpha = initalpha;
353 radius = initradius;
354
355 rad = radius >> radiusbiasshift;
356 if (rad <= 1) rad = 0;
357 for (i=0; i<rad; i++)
358 radpower[i] = alpha*(((rad*rad - i*i)*radbias)/(rad*rad));
359
360 // beginning 1D learning: initial radius=rad
361
362 if ((lengthcount%prime1) != 0) step = 3*prime1;
363 else {
364 if ((lengthcount%prime2) !=0) step = 3*prime2;
365 else {
366 if ((lengthcount%prime3) !=0) step = 3*prime3;
367 else step = 3*prime4;
368 }
369 }
370
371 i = 0;
372 while (i < samplepixels) {
373 b = p[0] << netbiasshift;
374 g = p[1] << netbiasshift;
375 r = p[2] << netbiasshift;
376 j = contest(b,g,r);
377
378 altersingle(alpha,j,b,g,r);
379 if (rad) alterneigh(rad,j,b,g,r); // alter neighbours
380
381 p += step;
382 if (p >= lim) p -= lengthcount;
383
384 i++;
385 if (i%delta == 0) {
386 alpha -= alpha / alphadec;
387 radius -= radius / radiusdec;
388 rad = radius >> radiusbiasshift;
389 if (rad <= 1) rad = 0;
390 for (j=0; j<rad; j++)
391 radpower[j] = alpha*(((rad*rad - j*j)*radbias)/(rad*rad));
392 }
393 }
394 // finished 1D learning: final alpha=alpha/initalpha;
395 return;
396}
397

Callers 1

iNeuQuantFunction · 0.85

Calls 3

contestFunction · 0.85
altersingleFunction · 0.85
alterneighFunction · 0.85

Tested by

no test coverage detected