Files
2026-05-13 16:57:16 +08:00

53 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PreProcessing 预处理
这个目录包含17*17型特殊种类篆文字图像的预处理流程。日常批量处理请使用 `scripts/run_preprocessing.py`
## 脚本用法
依赖见 `scripts/requirements.txt`。如果环境里还没有安装,可以先运行:
```bash
.venv/bin/pip install -r PreProcessing_MatrixZhuan/scripts/requirements.txt
```
从项目根目录运行:
```bash
.venv/bin/python PreProcessing_MatrixZhuan/scripts/run_preprocessing.py \
--input-dir PreProcessing_MatrixZhuan/original_characters \
--cleaned-dir PreProcessing_MatrixZhuan/out_cleaned \
--matrix-dir PreProcessing_MatrixZhuan/out_matrix \
--svg-dir PreProcessing_MatrixZhuan/out_svg
```
参数含义:
- `--input-dir`:原始图像输入文件夹
- `--cleaned-dir`cleaned 二值图输出文件夹
- `--matrix-dir`17x17 矩阵文本输出文件夹
- `--svg-dir`:矢量图 SVG 输出文件夹
输出命名会和输入文件名对齐:
- cleaned 图像:`原文件名_cleaned.png`
- 矩阵文本:`原文件名_matrix.txt`
- 矢量图:`原文件名.svg`
矩阵文本是纯 17 行,每行 17 个字符,只包含 `0``1`
## 可选调参
默认参数会输出 17x17 矩阵。必要时可以追加这些参数:
- `--grid-size`,默认 `17`
- `--cell-samples`,默认 `32`
- `--open-kernel-size`
- `--close-kernel-size`
- `--median-size`
- `--min-component-area`
- `--triangle-threshold`
## 目录说明
`comparisons/``manual_diffs/``manual_matrices/``processed_characters/``svg_characters/` 等测试和比较用目录已经在 `PreProcessing_MatrixZhuan/.gitignore` 中忽略。