CFAR 检测算法库
面向雷达目标检测的 CFAR 算法与评估工具箱
统一接口与评估脚本,快速对比多类 CFAR 算法
【CFAR】【雷达检测】【虚警控制】【MATLAB】
📌 为什么选择
项目聚焦雷达检测中的虚警控制与多目标鲁棒性。提供从门限系数求解到检测与评估的完整链路。适合教学、对比与工程验证。
| 痛点 | 方案 |
|---|---|
| 算法接口不统一 | 统一 cfar_detect_xx 结构化输出 |
| 门限系数难求解 | 解析公式与二分搜索封装 |
| 多目标干扰虚警高 | 引入 OS/TM/CMLD/迭代类 |
| 评估脚本难复现 | evaluation 脚本集中管理 |
| 杂波模型难生成 | 提供对数正态杂波生成器 |
🎯 核心价值
🔬 学术研究价值
面向算法机理与对比研究的统一实现。
- 统一公式对齐
- 完整算法谱系
- 可复现实验
- 结构化输出
💼 工程应用价值
面向工程评估的轻量可用工具集。
- 接口一致性
- 参数可控性
- 脚本即用性
- 边界处理统一
⚡ 技术亮点
🌊 CA 与鲁棒 CFAR 对比
| 特性 | 传统方案 | 本方案 |
|---|---|---|
| 噪声估计方式 | 简单均值 | 均值/序统计/截断混合 |
| 多目标鲁棒性 | 易受强回波影响 | 显式抑制强干扰 |
| 门限求解方式 | 手工推导 | 解析公式 + 二分统一 |
| 边界处理策略 | 实现分散 | 左中右统一流程 |
| 接口输出形式 | 返回格式不一 | 结构体统一输出 |
📊 性能指标(实测数据)
数据来源:evaluation 脚本的蒙特卡洛仿真曲线
| 场景 | 基线 | 本方案 | 结论 |
|---|---|---|---|
| 多目标 Pd-Pfa | CA-CFAR | GO/SO/OS | 曲线对比清晰 |
| 多目标 Pd-SNR | CA-CFAR | TM/CMLD/OS | 鲁棒性提升趋势 |
| 对数正态 Pd-Pfa | CA/GO/SO | OS-CFAR | 非均匀杂波更稳 |
| 对数正态 Pd-SNR | CA/GO/SO | OS-CFAR | 检测优势可见 |
🎯 多目标鲁棒检测能力
强调在强回波干扰下的稳定门限估计能力。
| 参数 | 配置 | 性能 |
|---|---|---|
| 参考窗长度 N | 64 | 统计稳定性好 |
| 序统计比例 rate | 0.75 | 强干扰抑制明显 |
| 迭代次数上限 | 30 | 收敛可控 |
🖥️ 运行环境
以 MATLAB 基础环境为核心,便于教学与工程复现。
- 语言:MATLAB
- 依赖:基础函数,无额外工具箱
- 硬件:普通 PC 即可
📁 项目结构
CFAR/
├── detectors/ # 检测器实现
│ ├── cfar_detect_ca.m # CA-CFAR
│ ├── cfar_detect_os.m # OS-CFAR
│ └── cfar_detect_icos.m # 迭代 OS-CFAR
├── evaluation/ # 评估脚本
│ ├── eval_multitarget_pd_pfa.m
│ └── eval_performance_vs_snr.m
└── docs/ # 文档体系
├── 算法文档.md # 理论与公式
└── 代码文档.md # 接口与结构
📄 文档体系
文档覆盖算法原理与代码结构两个维度。
📘 算法文档
系统阐述 CFAR 公式、门限推导与算法谱系。
📒 代码文档
聚焦模块划分、接口规范与脚本流程。
💻 核心代码展示
🔥 门限系数求解
门限求解统一由解析式与二分搜索支撑。
function result = binary_search(scope, precision, func, varargin)
target_pfa = varargin{end};
func_args = varargin(1:end-1);
while true
result = mean(scope);
pfa_calc = func(result, func_args{:});
difference = 1 / pfa_calc - 1 / target_pfa;
if abs(difference) < precision || abs(scope(1) - scope(2)) < 0.001
return;
elseif difference < 0
scope(1) = result;
else
scope(2) = result;
end
end
end
🌟 滑窗检测流程
滑窗检测统一处理左边界、中间、右边界。
function result = cfar_detect_ca(x, alpha, n_slide, n_guard)
half_slide = n_slide / 2;
half_guard = n_guard / 2;
len = length(x);
left_bound = 1 + half_guard + half_slide;
right_bound = len - half_guard - half_slide;
threshold = zeros(1, len);
targets = [];
for i = 1:(left_bound - 1)
cell_right = x(i + half_guard + 1 : i + half_slide * 2 + half_guard);
threshold(i) = mean(cell_right) * alpha;
if threshold(i) < x(i)
targets = [targets, i];
end
end
for i = left_bound:right_bound
cell_left = x(i - half_slide - half_guard : i - half_guard - 1);
cell_right = x(i + half_guard + 1 : i + half_guard + half_slide);
threshold(i) = (mean(cell_left) + mean(cell_right)) / 2 * alpha;
if threshold(i) < x(i)
targets = [targets, i];
end
end
for i = (right_bound + 1):len
cell_left = x(i - half_guard - half_slide * 2 : i - half_guard - 1);
threshold(i) = mean(cell_left) * alpha;
if threshold(i) < x(i)
targets = [targets, i];
end
end
result.name = 'CFAR_CA';
result.threshold = threshold;
result.targets = targets;
end
🚀 鲁棒检测流程
引入序统计或截断策略抑制强干扰。
function result = cfar_detect_icos(x, Pfa, n_slide, n_guard, rate)
half_slide = n_slide / 2;
half_guard = n_guard / 2;
len = length(x);
max_iter = 30;
left_bound = 1 + half_guard + half_slide;
right_bound = len - half_guard - half_slide;
threshold = zeros(1, len);
targets = [];
for i = 1:(left_bound - 1)
ref_cells = x(i + half_guard + 1 : i + half_slide * 2 + half_guard);
alpha = calc_threshold_os(Pfa, length(ref_cells), rate);
for iter = 1:max_iter
ref_sorted = sort(ref_cells);
k = ceil(rate * length(ref_cells));
t = ref_sorted(k) * alpha;
ref_cells = ref_cells(ref_cells <= t);
new_alpha = calc_threshold_os(Pfa, length(ref_cells), rate);
if new_alpha == alpha
break;
end
alpha = new_alpha;
end
ref_sorted = sort(ref_cells);
k = ceil(rate * length(ref_cells));
threshold(i) = ref_sorted(k) * alpha;
if threshold(i) < x(i)
targets = [targets, i];
end
end
for i = left_bound:right_bound
cell_left = x(i - half_slide - half_guard : i - half_guard - 1);
cell_right = x(i + half_guard + 1 : i + half_guard + half_slide);
ref_cells = [cell_left, cell_right];
alpha = calc_threshold_os(Pfa, length(ref_cells), rate);
for iter = 1:max_iter
ref_sorted = sort(ref_cells);
k = ceil(rate * length(ref_cells));
t = ref_sorted(k) * alpha;
ref_cells = ref_cells(ref_cells <= t);
new_alpha = calc_threshold_os(Pfa, length(ref_cells), rate);
if new_alpha == alpha
break;
end
alpha = new_alpha;
end
ref_sorted = sort(ref_cells);
k = ceil(rate * length(ref_cells));
threshold(i) = ref_sorted(k) * alpha;
if threshold(i) < x(i)
targets = [targets, i];
end
end
result.name = 'CFAR_ICOS';
result.threshold = threshold;
result.targets = targets;
end
🎬 一键运行
# 打开 MATLAB 并进入工程目录
# 将 utils/pfa/threshold/detectors 加入路径
# 运行 evaluation 中的评估脚本
结果预览
输出 Pd-Pfa 与 Pd-SNR 对比曲线。
多算法性能曲线对比图。
📸 演示图片预览
示意图用于展示关键性能曲线与检测效果。
- Pd-Pfa 曲线对比
- Pd-SNR 曲线对比
- 多目标检测示意
- 门限序列示意
- 杂波分布示意




🛒 获取方式
本文代码仅为核心片段,完整版工程已整理好。 关注公众号 【3GPP 仿真实验室】进行获取。
📚 参考文献
- H. Rohling, “Radar CFAR Thresholding in Clutter and Multiple Target Situations,” IEEE Trans. AES, 1983.
- M. I. Skolnik, Radar Handbook, 3rd ed., McGraw-Hill, 2008.
- S. M. Kay, Fundamentals of Statistical Signal Processing: Detection Theory, Prentice Hall, 1998.
- J. I. Marcum, “A Statistical Theory of Target Detection,” RAND Research Memorandum, 1947.
- A. Farina, Radar Data Processing: Introduction and Tracking, Research Studies Press, 1985.