convert image to pure black and white

564 views
Skip to first unread message

Rijal Asep Nugroho

unread,
Aug 15, 2021, 11:11:20 PM8/15/21
to golang-nuts
hello all,

I was browsing how to make a golang code to convert an image to pure black and white, but didn't find a suitable one, only got how to convert the image to grayscale.
Can anyone help? thank you.

Regards,

Dan Kortschak

unread,
Aug 15, 2021, 11:20:13 PM8/15/21
to golan...@googlegroups.com
If you do a greyscale conversion and then threshold on a level of grey
that is bright enough to be white/dark enough to be black, that's
monochrome.


https://github.com/ev3go/ev3dev/blob/a5fda5c6a492269e01b184046ed42dc4a1dfe8c9/fb/mono.go#L106-L113
.

I don't recall where I got the constants from, but I think they are
reasonably commonly used (you could just use the image/color
constants).

Dan


Reply all
Reply to author
Forward
0 new messages