the kernel in array-blur is already very similar to a gaussian, but I'm interested in your suggestion about weighting by lightness. Maybe this would be easier to do in WebGL though?
Not necessarily, I think? The steps would be:
- extract lightness channel L
- blur L to remove noise
- specify max lightness difference d within which a pixel can contribute to the kernel
- for each pixel:
-- init hue sum `sh=0`, weight sum `sw=0`, lookup and store lightness at current pixel `pl`
-- for each pixel in kernel:
--- lookup pixel lightness `kl`
--- calc weight: `kw=clamp(0, 1, abs(pl-kl))`
--- if `kw==0` skip
--- lookup kernel pixel hue `kh`
--- `sh+=kw*kh`
--- `sw+=kw`