1

Hello I am trying to convert an image from full color image to 3 colors dithering image to convert this image

enter image description here

to this one

enter image description here

I don't have a clue how to do this, but I assume that I need to first change source image to tri color image (Black - White - Red) then apply dithering on it, so I am not sure how to convert a fully colored image into 3 colors only.

mohamed elsabagh
  • 352
  • 3
  • 16
  • 1
    opencv is for computer vision. it doesn't do dithering. wrong library. if you wanted to implement a dithering algorithm yourself, instead of using a library for it, you could use OpenCV, but you could also just use `imageio` and numpy. OpenCV does nothing special here. -- your assumption is wrong. if you "first change source image to tri color", all information required for dithering would be gone. – Christoph Rackwitz Jun 27 '23 at 15:17
  • 3
    Imagemagick can do dithering. If you need to do it in Python, then use Python Wand, which uses Imagemagick. – fmw42 Jun 27 '23 at 16:04
  • https://en.wikipedia.org/wiki/Dither – Pete Jun 27 '23 at 17:30
  • that was really enlightening using Imagemagick did exactly what I needed – mohamed elsabagh Jun 28 '23 at 11:13
  • 1
    Please consider posting your solution as an answer to share your enlightenment with the rest of the StackOverflow community. – Mark Setchell Jun 29 '23 at 07:10

1 Answers1

1

I found what I was looking for in this post https://learn.adafruit.com/preparing-graphics-for-e-ink-displays/command-line The answer was to use library like ImageMagick instead of opencv. I can do a dithering on one line command

convert input.jpg -dither FloydSteinberg -define dither:diffusion-amount=85% -remap eink-3color.png BMP3:output.bmp

the eink-3color.png is this one

enter image description here

mohamed elsabagh
  • 352
  • 3
  • 16