MCPcopy Create free account
hub / github.com/32comic/image2pixel-web / getAvgRgb

Method getAvgRgb

web/js/algorithms.js:150–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

148 this.splitChannel = Lr >= ar && Lr >= br ? 0 : ar >= br ? 1 : 2;
149 }
150 getAvgRgb() {
151 const n = this.pixels.length;
152 let L = 0, a = 0, b = 0;
153 for (const p of this.pixels) { L += p[0]; a += p[1]; b += p[2]; }
154 return labToRgb(L / n, a / n, b / n);
155 }
156 split() {
157 if (this.pixels.length < 2) return null;
158 const ch = this.splitChannel;

Callers 1

medianCutGetPaletteInLabFunction · 0.80

Calls 1

labToRgbFunction · 0.85

Tested by

no test coverage detected