Initial commit: skills library
- 70 skills with code and documentation - Add .gitignore (ignore __pycache__, output/, temp/, venv/) - Clean up test intermediates and caches
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
# 提高识别率技巧
|
||||
|
||||
## 图片质量要求
|
||||
|
||||
### ✅ 最佳
|
||||
- 300+ DPI 扫描件
|
||||
- 光线均匀、无阴影
|
||||
- 纸张平整无褶皱
|
||||
- 音符清晰、线条完整
|
||||
|
||||
### ⚠️ 次佳
|
||||
- 150 DPI 扫描
|
||||
- 手机拍摄但光线好
|
||||
- 轻微阴影可接受
|
||||
|
||||
### ❌ 避免
|
||||
- 50 DPI 以下的模糊图
|
||||
- 严重倾斜(可预处理校正)
|
||||
- 光线不均导致部分过暗/过亮
|
||||
- 铅笔痕迹干扰
|
||||
|
||||
## 预处理建议
|
||||
|
||||
### Python + PIL 增强
|
||||
|
||||
```python
|
||||
from PIL import Image, ImageFilter, ImageOps
|
||||
import numpy as np
|
||||
|
||||
def preprocess_sheet_music(image_path):
|
||||
img = Image.open(image_path).convert('L') # 灰度
|
||||
|
||||
# 增加对比度
|
||||
img = ImageOps.autocontrast(img)
|
||||
|
||||
# 去噪
|
||||
img = img.filter(ImageFilter.MedianFilter(size=3))
|
||||
|
||||
# 二值化(有时有效)
|
||||
# img = img.point(lambda x: 0 if x < 128 else 255)
|
||||
|
||||
return img
|
||||
|
||||
# 使用
|
||||
processed = preprocess_sheet_music("original.jpg")
|
||||
processed.save("processed.png")
|
||||
```
|
||||
|
||||
### 倾斜校正
|
||||
|
||||
```python
|
||||
from deskew import deskew
|
||||
|
||||
# 自动检测并校正倾斜角度
|
||||
image = Image.open("tilted.jpg")
|
||||
corrected = deskew(image)
|
||||
corrected.save("corrected.jpg")
|
||||
```
|
||||
|
||||
## 格式选择
|
||||
|
||||
| 格式 | 推荐度 | 说明 |
|
||||
|------|--------|------|
|
||||
| PNG | ⭐⭐⭐⭐⭐ | 无损压缩,最佳 |
|
||||
| TIFF | ⭐⭐⭐⭐ | 印刷级无损 |
|
||||
| JPG (高画质) | ⭐⭐⭐ | 可接受 |
|
||||
| JPG (低画质) | ⭐ | 压缩失真严重 |
|
||||
|
||||
## 分辨率建议
|
||||
|
||||
| 乐谱复杂度 | 最小宽度 | 建议 DPI |
|
||||
|-----------|---------|---------|
|
||||
| 简单旋律 | 1000px | 150 |
|
||||
| 钢琴谱(双手) | 2500px | 300 |
|
||||
| 交响乐总谱 | 4000px | 400 |
|
||||
|
||||
## 多页处理
|
||||
|
||||
```python
|
||||
import subprocess
|
||||
|
||||
# 将多页 PDF 转为单页图片
|
||||
subprocess.run([
|
||||
"pdftoppm",
|
||||
"-r", "300", # DPI
|
||||
"-png", # 输出 PNG
|
||||
"score.pdf", # 输入
|
||||
"page" # 输出前缀
|
||||
])
|
||||
|
||||
# 然后逐页识别
|
||||
for i in range(1, page_count + 1):
|
||||
model.predict(f"page-{i}.png")
|
||||
```
|
||||
|
||||
## 识别后校对
|
||||
|
||||
建议在 MuseScore 中打开识别结果,检查:
|
||||
1. 节拍是否正确
|
||||
2. 升降号是否遗漏
|
||||
3. 和弦分解是否正确
|
||||
4. 休止符位置
|
||||
Reference in New Issue
Block a user