I wrote a filter that loosely thins the line art image with black lines drawn on a white background. The thinning is not for analysis such as extracting a 1-pixel line, but rather for practical use in the retouching software area. Along with thinning the lines, it also includes the aim of making several lines of different thicknesses as uniform as possible.
Works with Python.
https://github.com/a-nakanosora/blender-scripts/blob/master/Image/Petit%20Thinning%20CLI/petit_thinning.py
You need Pillow
to use it.
(It is recommended to use Anaconda that includes this library from standard Python)
Addendum: In the first version, Numpy and Pillow were required for the external library, but with the improvement by @ pashango2, Pillow has been unified and speeded up. Many thanks! </ font>
$ python petit_thinning.py 6 0.95 5 input.png output.png
Command line arguments
petit_thinning.py <emptyrange> <emptythres> <dilation_max_depth> <path_in> [<path_out>] [-p]
It looks like this.
ʻEmptyrange, ʻemptythres
, dilation_max_depth
are the parameters that change the effect of the filter.
dilation_max_depth
: An integer greater than or equal to 1. By specifying a large number, it is possible to make thicker lines thinner, but if the lines are too thick, noise tends to occur.path_in
: Input file pathpath_out
: Output file path. If omitted, the input path name with _out
at the end will be used.-p
flag: Print various parameters and calculation timeBasically, if ʻempty rangeis set to a value larger than
dilation_max_depth, noise will be reduced, but the degree of thinning will also be reduced. It is safe to set
dilation_max_depth to about
5`.
I'm just doing some dilation of the morphology filter and synthesizing them.
Recommended Posts