* 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)
| 304 | * color fidelity — especially for skin tones, gradients, and similar hues. |
| 305 | */ |
| 306 | function 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 |
no test coverage detected