Jun 01, 2021 Article blog
This article was reproduced to Know ID: Charles (Bai Lu) knows his personal column
Download the W3Cschool Mobile App, 0 Foundation Anytime, Anywhere Learning Programming >> Poke this to learn
Use Python to compress and enhance handwritten notes.
As for the causes are probably:
This content is very interesting...
——>
To say that is to say no. T_T
Baidu web download link:
https://pan.baidu.com/s/1oagM2fbKUJXSiZ93S_Mszg
Password: 47ws
link:
https://mzucker.github.io/2016/09/20/noteshrink.html
author:
Matt Zucker
Step1: Determine the background color
Assume that the paper color is the one that appears most often in scanned images.
At the same time, 8 bits per channel is reduced to 6 bits per channel to increase the reliability of background color acquisition.
Step2: Separate the foreground
Mapping colors from the RGB space to the HSV space enables the ability to separate the foreground.
The rule defaults to:
(1) Brightness V is 0.3 or more larger than background color;
(2) Saturation S is more than 0.2 larger than background color.
Satisfying one of them is the foreground.
Step3: Choose a render color
It is equivalent to using cluster analysis to solve a color quantification problem.
Convert the original 24-bit-per-pixel image into an image with a small number of colors.
It is mainly implemented by K mean algorithm.
Additional instructions:
(1) By default, the program will reset the maximum minimum intensity value of the color to 0 to 255, to increase the final palette of various colors of the flamboyance and contrast;
(2) The program automatically sorts by input file name by default, with keywords as numbers.
Python version: 3.5.4
Related modules:
Scipy modules, numpy modules, PIL modules, and some Python-owned modules.
Environment construction
Install Python and add it to the environment variable, and pip installs the relevant modules that are required.
Use the demo
Full feature options:
Basic features are used:
py -3.5 Note_Processor.py plus the name of the note picture to be processed
For example, the following image:
The results are shown
Note 1:
Results:
Note 2:
Results:
If you are not satisfied with the results, set the appropriate parameters in the command line window yourself, i.e. do not use the default values;
For example: