画像から SVG ファイルを作成するツール
コマンドラインから gui でできるツールです
Inkscape
Inkscape – Draw Freely. | Inkscape
画像を選択し、[パス]-[ビットマップをトレース]
不要な画像を消します
mkdir y:\output_png
mkdir y:\output_f
for /r y:\output_png %%f in (*.png) do (
"D:\app2\inkscape\bin\inkscape" --export-type=svg %%f --export-plain-svg=Y:\output_png\%%~nf.svg
"D:\app2\inkscape\bin\inkscape" --export-type=png -h 320 -w 320 Y:\output_png\%%~nf.svg -o Y:\output_f\%%~nf.png
)
timeout /t 55
GIMP
GIMP – GNU Image Manipulation Program
左上のパネル「色域を選択」をクリック
変換したい画像をクリック。画像全体が動く点線で囲まれます。
メニューバー「選択」-「選択範囲をパスに」をクリック
不要な画像を消します
potrace
PNG ファイルは変換できないので BMP ファイルに変換してから使用します
ImageMagickを使って透明な背景を白の背景に変換しています
scourを Python にインストールして SVG ファイルを最適化しています これは特に行わなくても構いません
for /r y:\output_png %%f in (*.png) do (
"C:\app\ImageMagick\convert.exe" %%f -strip -flatten y:\input_png\%%~nf.bmp
"C:\app\potrace\potrace.exe" y:\input_png\%%~nf.bmp -o y:\input_png\a%%~nf.svg --svg --flat --opttolerance 0.8 --alphamax 1.4 --blacklevel 0.5
scour -i y:\input_png\a%%~nf.svg -o y:\input_png\%%~nf.svg
del y:\input_png\a%%~nf.svg
del y:\input_png\%%~nf.bmp
)
AutoTrace
中心線を探すことができます
"C:\app\AutoTrace\autotrace.exe" --centerline --color-count 2 --input-format png --output-format SVG --output-file "D:\TE00003\U+2A3FB.svg" "D:\TE00003\U+2A3FB.png"
最新版では動かなかったのでautotrace-0.40.0-20200219-win64-setup.zipを使ってください
Usage: autotrace.exe [options] <image_file_name> ...
Options:<input_name> must be a supported image file.
You can use '--' or '-' to start an option.
You can use any unambiguous abbreviation for an option name.
You can separate option names and values with '=' or ' '.
-background-color <hexadecimal>: the color of the background that should
be ignored, for example FFFFFF; default is no background color.
-centerline: trace a character's centerline, rather than its outline.
-charcode <unsigned>: code of character to load from GF font file.
-color-count <unsigned>: number of colors a color bitmap is reduced to,
it does not work on grayscale, allowed are 1..256;
default is 0, that means no color reduction is done.
-corner-always-threshold <angle-in-degrees>: if the angle at a pixel is
less than this, it is considered a corner, even if it is within
`corner-surround' pixels of another corner; default is 60.
-corner-surround <unsigned>: number of pixels on either side of a
point to consider when determining if that point is a corner;
default is 4.
-corner-threshold <angle-in-degrees>: if a pixel, its predecessor(s),
and its successor(s) meet at an angle smaller than this, it's a
corner; default is 100.
-despeckle-level <unsigned>: 0..20; default is 0: no despeckling.
-despeckle-tightness <real>: 0.0..8.0; default is 2.0.
-dpi <unsigned>: The dots per inch value in the input image, affects scaling
of mif output image
-error-threshold <real>: subdivide fitted curves that are off by
more pixels than this; default is 2.0.
-filter-iterations <unsigned>: smooth the curve this many times
before fitting; default is 4.
-input-format: Available formats: ppm, pbm, pnm, png, tga, bmp, pgm, gf.
--integer-coords: write whole-number coordinates in SVG output instead of
values with a decimal point.
-help: print this message.
-line-reversion-threshold <real>: if a spline is closer to a straight
line than this, weighted by the square of the curve length, keep it a
straight line even if it is a list with curves; default is .01.
-line-threshold <real>: if the spline is not more than this far away
from the straight line defined by its endpoints,
then output a straight line; default is 1.
-list-output-formats: print a list of supported output formats to stderr.
-list-input-formats: print a list of supported input formats to stderr.
-log: write detailed progress reports to <input_name>.log.
-noise-removal <real>:: 0.0..1.0; default is 0.99.
-output-file <filename>: write to <filename>. With multiple input files,
<filename> may contain '*' (replaced by each input's name without its
extension) or name an existing directory.
-output-format <format>: use format <format> for the output file. Available formats:
emf, ugs, sk, pdf, ild, dxf, p2e, epd, cgm, mif, svg, ai, er, pov, eps, dr2d, plt, fig
-preserve-width: preserve line width prior to thinning.
-remove-adjacent-corners: remove corners that are adjacent.
-tangent-surround <unsigned>: number of points on either side of a
point to consider when computing the tangent at that point; default is 3.
-report-progress: report tracing status in real time.
-debug-bitmap: dump loaded bitmap to <input_name>.bitmap.ppm or pgm.
-version: print the version number of this program.
-width-weight-factor <real>: weight factor for fitting the linewidth.
-GitHub – autotrace/autotrace: bitmap to vector graphics converter
中心線を求める別の方法ImageMagick
C:\app\ImageMagick\convert.exe D:\data2\IMG_6511_cropped.bmp -morphology Thinning:-1 Skeleton "y:\23FB.png"
Morphology of Shapes — ImageMagick Examples










ディスカッション
コメント一覧
まだ、コメントがありません