Image sampling, palette extraction, and duotone processing
Hue Codex image tools run in the browser. They use canvas pixels for sampling, extraction, and duotone rendering, with privacy and approximation caveats made visible.
Hue Codex processes user images locally in browser canvas, samples exact or averaged pixels, extracts palettes through bucketed color aggregation and Delta E diversity checks, and renders duotone PNG output from canvas pixels.
Uploaded images are read into the browser and processed locally by canvas APIs.
Eyedropper samples can use exact pixels or averaged sample windows depending on the selected sample size.
Image palette extraction skips mostly transparent pixels and composites partial transparency over the Hue Codex paper color.
Duotone processing maps source luminance into a shadow-to-highlight ramp, with intensity, contrast, and midtone controls.
Standards status
These badges identify which parts of this methodology are standards-backed, draft-track, Hue Codex-specific, approximate, or dependent on browser behavior.
Browser-dependentApproximationHue Codex heuristic
Browser-dependentOutput depends on browser APIs, rendering, color management, canvas pixels, clipboard, download, or CSS support.
ApproximationModel or estimate with known limits, including CMYK, color-vision simulation, image palette extraction, or CSS duotone output.
Hue Codex heuristicHue Codex ranking, role hints, bands, labels, or workflow guidance rather than an external standard.
Formulas, choices, heuristics, and limits
This separates standards-based formulas from Hue Codex implementation decisions, product heuristics, and known limitations for this methodology.
Standards-based formulas
Formula, threshold, syntax, or data behavior taken from a cited standard or standards-backed source.
WCAG contrast math can be applied after sampled or extracted colors are resolved.
CSS color conversion context supports the reported HEX, RGB, HSL, and OKLCH values.
Implementation choices
How Hue Codex chooses to parse, normalize, round, export, or sequence calculations.
Images are processed locally in browser canvas when browser security rules allow pixel access.
Mostly transparent pixels are skipped and partial alpha is composited over the Hue Codex paper color before bucketing.
Duotone PNG export renders from canvas pixels at source dimensions when available.
Hue Codex heuristics
Product rankings, bands, labels, suggestions, or role hints that are useful guidance but not external standards.
Palette bucket ranking, focus score, neutral merging, and Delta E diversity filtering are Hue Codex heuristics.
Duotone recommendations and overlay-text guidance are product review hints.
Known limitations
Caveats, edge cases, browser dependencies, approximations, or contexts the method does not prove.
Canvas pixels, image decoding, color management, and cross-origin rules are browser-dependent.
Palette extraction is approximate and depends on sampling quality, compression artifacts, and image content.
CSS duotone output is an approximation and may not match exported PNG pixels.
Local processing and privacy
Browser-dependent
Image files selected in Hue Codex are loaded into the browser for canvas processing. Palette extraction, pixel sampling, and duotone preview calculations happen client-side.
Hue Codex does not need to upload the selected image to calculate these results. Browser limitations, cross-origin image rules, and user-selected files still determine whether canvas pixel data can be read.
Eyedropper sampling
Browser-dependentApproximation
Image Eyedropper maps pointer coordinates to the rendered image canvas, reads the selected pixel area, and returns HEX, RGB, HSL, OKLCH, contrast, and export metadata.
A sample size of one pixel reports the exact canvas pixel. Larger sample sizes average nearby pixels and can smooth JPEG artifacts, antialiasing, and texture noise.
Palette extraction
ApproximationHue Codex heuristicBrowser-dependent
Image Palette Extractor scans the sampled canvas at a quality-dependent pixel step. Pixels with alpha below 0.5 are skipped. Partially transparent pixels are composited over the Hue Codex paper color before bucketing.
Colors are bucketed by rounded RGB channel groups, with optional neutral merging. Candidate buckets are ranked by coverage and focus score, then filtered with Delta E diversity so near duplicates do not crowd out stronger palette entries.
Duotone processing
ApproximationBrowser-dependent
Duotone Generator estimates source luminance from RGB channels, maps that luminance through contrast and midtone controls, then mixes between the selected shadow and highlight colors. Intensity blends the duotone result back toward the original pixel.
Downloaded PNG output is rendered from source image dimensions when a source image is available. CSS duotone output is an approximation for live treatments and may not match the exact PNG pixels.
Validation checks
Browser-dependentHue Codex heuristic
Image tool QA checks.
Check
Expected behavior
Fully transparent pixels
Skipped in palette extraction
Partial alpha pixels
Composited over paper color before bucketing
One-pixel eyedropper
Reports the canvas pixel at the mapped coordinate
Duotone intensity 0 percent
Keeps the source image colors
Duotone intensity 100 percent
Uses the mapped duotone colors
Image extraction pseudocode
Browser-dependentApproximationHue Codex heuristic
These steps apply after the browser has decoded the image and exposed canvas pixels. Browser image decoding and color management can still change the input pixels.
Image palette extraction, bucketing, diversity, and ranking
quality presets:
quick: maxDimension 420, pixelStep 5, bucketSize 36, neutralSpread 18, neutralStep 28, diversityDelta 7
balanced: maxDimension 640, pixelStep 3, bucketSize 28, neutralSpread 16, neutralStep 22, diversityDelta 9
detailed: maxDimension 860, pixelStep 2, bucketSize 20, neutralSpread 12, neutralStep 16, diversityDelta 11
extract_palette(canvas, count, quality, focus, sort, merge_neutrals):
for y from 0 to canvas.height step quality.pixelStep:
for x from 0 to canvas.width step quality.pixelStep:
r, g, b, a8 = canvas_pixel(x, y)
alpha = a8 / 255
if alpha < 0.5: continue
# Composite partial alpha over Hue Codex paper #FBFAF5.
r = round(r * alpha + 251 * (1 - alpha))
g = round(g * alpha + 250 * (1 - alpha))
b = round(b * alpha + 245 * (1 - alpha))
spread = max(r,g,b) - min(r,g,b)
midpoint = (max(r,g,b) + min(r,g,b)) / 2
if merge_neutrals and spread <= quality.neutralSpread:
key = "neutral-" + round(midpoint / quality.neutralStep) * quality.neutralStep
else:
key = round(r / bucketSize) * bucketSize,
round(g / bucketSize) * bucketSize,
round(b / bucketSize) * bucketSize
bucket[key].count += 1
bucket[key].r += r; bucket[key].g += g; bucket[key].b += b
candidates = average each bucket into HEX
candidates = top max(80, count * 16) by bucket count
ranked = sort candidates by focus_score(entry, focus), then count
diversity = focus == dominant ? max(4, quality.diversityDelta - 3) : quality.diversityDelta
selected = []
for entry in ranked:
if selected is empty or min(delta_e_76(entry, selected_entry)) >= diversity:
selected.append(entry)
if selected length == count: break
if selected has fewer than count:
append highest ranked non-duplicate HEX entries
return selected sorted by requested sort mode and labeled by role heuristic
These vectors validate the deterministic pieces of image processing once canvas pixels are available. Browser decoding and color management can still affect real uploaded images.
Image compositing, averaging, and duotone vectors.
Input
Expected output
Notes
#FF0000 at 50% alpha over paper #FBFAF5
#FD7D7B
Partial alpha is composited over the Hue Codex paper color before bucketing
Average of one #000000 pixel and one #FFFFFF pixel