1
$\begingroup$

I want to convert greyscale images to ones that have just black and white pixels.

Simply dividing the input pixels into black or white based on being below or above a set grey level, doesn't give nice results. I'm therefore looking for an algorithm that does some rasterisation.

My internet search led to many tutorials on how to rasterise using PhotoShop and similar applications, which is not what I'm after.

Would anyone be willing to point me to an online source that explains this kind of algorithms and/or explain a bit how to approach this problem?

$\endgroup$
2
  • 1
    $\begingroup$ Here’s an old blog post I wrote about this topic, including code: crisluengo.net/archives/355 $\endgroup$ Oct 6, 2021 at 3:08
  • $\begingroup$ @CrisLuengo Wow, thanks Chris. I've immediately added that to my short list of sources. Had a quick peek and your post looks great; will read over the weekend. $\endgroup$ Oct 6, 2021 at 6:43

2 Answers 2

4
$\begingroup$

The process of converting a grey scale image to 1-bit image of black and white pixels is called dithering. There are multiple different algorithms to achieve it with different looking results. Try the Wikipedia article on dither.

$\endgroup$
2
  • $\begingroup$ Thanks for reminding me about dithering, a concept I'd encountered decades ago but forgot to connect the dots ;-) when thinking about this problem. I'll be using Floyd-Steinberg Dithering. $\endgroup$ Oct 6, 2021 at 6:38
  • $\begingroup$ Just to be clear that the term "dithering" is a bit of a misnomer with the Floyd-Steinberg thing. That is error diffusion a.k.a. noise-shaped quantization, but it is not dithered. true dithering requires a random number generated noise that is added to the greyscale value before it is quantized to black or white. Noise shaping can be used with dithered quantization or undithered quantization. $\endgroup$ Oct 7, 2021 at 1:54
1
$\begingroup$

Such a conversion reduces the quantization of information with perceptual care, and is sometimes called dithering (as answered be @justme) or halftoning. It may play jointly on pixel value or spatial location, as illustrated below :

dither on value and spatial location

"Halftoning or analog halftoning is a process that simulates shades of gray by varying the size of tiny black dots arranged in a regular pattern"

In the above link, halftoning might encompass other techniques, like patterning, value dithering, spatial dithering, error diffusion. Ordered or averaged dithering are described in Image Dithering — How to Deceive your Eyes?

$\endgroup$
2
  • 1
    $\begingroup$ Thanks for pointing out the broader context of problems like this! I've selected @Justme's answer because he was a bit earlier and is what I need. But of course your answer is very selectable too. $\endgroup$ Oct 6, 2021 at 6:40
  • 1
    $\begingroup$ Perfect, and you reminded me to upvote @Justme's answer as well $\endgroup$ Oct 6, 2021 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.