Skip to content

FR: Atkinson dithering #6

Description

@Sunspark-007

Hi, there are many dithering algorithms out there. A nice-to-have would be the Atkinson algorithm which was used on the 1-bit Macintosh computers. It would be a good match for 1-bit e-ink output selection.

function atkinson(pixels,w) {
	const e=Array(2*w).fill(0), m=[0,1,w-2,w-1,w,2*w-1]
	return pixels.map(x => {
		const pix=x+(e.push(0),e.shift()), col=pix>.5, err=(pix-col)/8
		m.forEach(x => e[x]+=err)
		return col
	})
}

Good article on B&W dithering with examples: https://surma.dev/things/ditherpunk/

Web component for html to do Atkinson which might work for you since cr2xt is using a web engine: https://github.com/andrewstephens75/as-dithered-image referred to in https://sheep.horse/2023/1/improved_web_component_for_pixel-accurate_atkinson.html

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions