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

Function processWithClassicLab

web/js/algorithms.js:306–316  ·  view source on GitHub ↗

* Algorithm: Classic LAB (recommended for classical pixel art) * - Averages blocks (clean solid-color blocks, no dithering) * - Palette generated via Median Cut in CIELAB space → more perceptually * distinct colors than RGB Median Cut * - Color matching uses LAB distance → nearest color is the

(imageData, blockSize, palette)

Source from the content-addressed store, hash-verified

304 * color fidelity — especially for skin tones, gradients, and similar hues.
305 */
306function processWithClassicLab(imageData, blockSize, palette) {
307 const { grid, rows, cols } = extractBlockGridAverage(imageData, blockSize);
308 const labPalette = buildLabPalette(palette);
309 for (let row = 0; row < rows; row++) {
310 for (let col = 0; col < cols; col++) {
311 const [r, g, b] = grid[row][col];
312 grid[row][col] = nearestLabColor(r, g, b, labPalette);
313 }
314 }
315 paintBlockGrid(grid, rows, cols, imageData, blockSize);
316}
317
318/**
319 * Algorithm: LAB + Floyd-Steinberg Dithering

Callers 1

processImageFunction · 0.85

Calls 4

extractBlockGridAverageFunction · 0.85
buildLabPaletteFunction · 0.85
nearestLabColorFunction · 0.85
paintBlockGridFunction · 0.85

Tested by

no test coverage detected