Create a binary image for OCR using Image Magick

nice /usr/local/bin/convert \
  -colors 2 \
  -colorspace gray \
  -compress group4 \
   /var/www/html/uploads/pokemon.jpg \
   /var/www/html/uploads/pokemontest.jpg

This team worked with a truly OLD version of Image Magick.

In the latest version, this method creates a completely black image.

nice /usr/local/bin/convert \
  -colorspace gray \
  -compress group4 \
   /var/www/html/uploads/pokemon.jpg \
   /var/www/html/uploads/pokemontest.jpg

nice /usr/local/bin/convert \
   -colors 2 \
    /var/www/html/uploads/pokemontest.jpg \
    /var/www/html/uploads/pokemontestfinal.jpg

This results in a bital gray and black image, but it is really rude. NOT clean.

+3
source share
1 answer

You can try simple

convert  input.jpg  -threshold 50%  output.jpg

(and play around with the settings a bit 50%) and see if this comes next.

In addition, you can see these answers:

+2
source

Source: https://habr.com/ru/post/1745375/


All Articles