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

Method constructor

web/js/algorithms.js:136–149  ·  view source on GitHub ↗
(px)

Source from the content-addressed store, hash-verified

134
135 class LabBox {
136 constructor(px) {
137 this.pixels = px;
138 let minL = Infinity, maxL = -Infinity;
139 let mina = Infinity, maxa = -Infinity;
140 let minb = Infinity, maxb = -Infinity;
141 for (const [L, a, b] of px) {
142 if (L < minL) minL = L; if (L > maxL) maxL = L;
143 if (a < mina) mina = a; if (a > maxa) maxa = a;
144 if (b < minb) minb = b; if (b > maxb) maxb = b;
145 }
146 const Lr = maxL - minL, ar = maxa - mina, br = maxb - minb;
147 this.largestRange = Math.max(Lr, ar, br);
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;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected