GradientAV is a post-processing tool for retinal vessel segmentation that converts neural network predictions (multi-colored: red/blue/green/purple/cyan) into standardized artery-vein classification maps (red=artery, blue=vein, black=background).
Key Innovation: Instead of the traditional "binarize-then-smooth" paradigm, we preserve the original gradient information from neural network outputs, achieving naturally smooth vessel edges without shape distortion.
| Traditional Methods | Problems |
|---|---|
| Morphological smoothing | Jagged edges remain, over-processing causes deformation |
| Gaussian blur + threshold | Vessels become thicker, details lost |
| B-spline contour interpolation | Computationally complex, prone to distortion |
| Super-sampling anti-aliasing | Severe structural distortion |
Root Cause: All methods follow the "binarize → smooth" paradigm. Once hard edges are created, subsequent smoothing inevitably leads to information loss or deformation.
Core Insight: Neural network outputs inherently contain natural edge gradients (from softmax probabilities or sub-pixel responses). This gradient IS the natural anti-aliasing.
Input Image → HSV Conversion → Soft Mask Extraction → Hue Classification → Gradient Modulation → Output
↓
Preserve original brightness gradient (NO binarization)
Mathematical Formulation:
For input image
Where
git clone https://github.com/Changhuaishui/GradientAV.git
cd GradientAV
pip install -r requirements.txtSingle file:
python gradient_av.py -i input.png -o output.pngBatch processing:
python gradient_av.py -i ./input_folder -o ./output_folderWith comparison output:
python gradient_av.py -i input.png -o output.png --compareParameters:
| Parameter | Description | Default |
|---|---|---|
-i, --input |
Input file or directory | Required |
-o, --output |
Output file or directory | Required |
-c, --compare |
Generate side-by-side comparison | False |
-m, --min-intensity |
Minimum intensity threshold | 5 |
| Metric | Traditional Methods | GradientAV |
|---|---|---|
| Edge Smoothness | Obvious jagging | Natural gradient |
| Vessel Shape Preservation | Deformation/thickening | Fully preserved |
| Processing Speed | Slow (multiple iterations) | Fast (single mapping) |
GradientAV 是一个视网膜血管分割的后处理工具,用于将神经网络预测结果(多色:红/蓝/绿/紫/青)转换为标准化的动静脉分类图(红色=动脉,蓝色=静脉,黑色=背景)。
核心创新:摒弃传统的"二值化-再平滑"范式,直接保留神经网络输出的梯度信息,实现自然平滑的血管边缘且不产生形变。
| 传统方法 | 问题 |
|---|---|
| 形态学平滑(开闭运算) | 边缘仍有锯齿,过度处理导致血管变形 |
| 高斯模糊 + 阈值化 | 血管变粗,细节丢失 |
| 轮廓B样条插值 | 计算复杂,易产生形变 |
| 超采样抗锯齿 | 血管结构严重失真 |
根本原因:所有方法都遵循 "二值化→平滑" 范式。硬边缘一旦产生,后续平滑必然导致信息损失或形变。
核心洞察:神经网络的原始预测输出本身就包含自然的边缘渐变信息(来自 softmax 概率或网络的亚像素响应),这种渐变就是天然的抗锯齿。
输入图像 → HSV转换 → 软掩码提取 → 色相分类 → 梯度调制 → 输出
↓
保留原始亮度渐变(不二值化)
git clone https://github.com/Changhuaishui/GradientAV.git
cd GradientAV
pip install -r requirements.txt单文件处理:
python gradient_av.py -i input.png -o output.png批量处理:
python gradient_av.py -i ./input_folder -o ./output_folder生成对比图:
python gradient_av.py -i input.png -o output.png --compare| 指标 | 传统方法 | GradientAV |
|---|---|---|
| 边缘平滑度 | 锯齿明显 | 自然渐变 |
| 血管形态保持 | 变形/变粗 | 完全保持 |
| 处理速度 | 较慢(多次迭代) | 快速(单次映射) |
GradientAV/
├── README.md
├── LICENSE
├── requirements.txt
├── gradient_av.py # Main program
├── examples/
│ ├── input/ # Example inputs
│ └── output/ # Example outputs
└── docs/
└── method.md # Detailed methodology
If you find this work useful, please consider citing:
@software{gradientav2024,
author = {Changhuaishui},
title = {GradientAV: Gradient-Preserving Retinal Artery-Vein Classification},
year = {2024},
url = {https://github.com/Changhuaishui/GradientAV}
}This project is licensed under the MIT License - see the LICENSE file for details.
If this project helps you, please give it a star!