Skip to content
Back to skills

基于梯度的八邻域区域生长算法

ASecurity

实现一种从灰度图像最高点出发,沿梯度下降方向进行八邻域区域生长的MATLAB算法,包含防止死循环的机制。

  • 581 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 11, 2026
education

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill '基于梯度的八邻域区域生长算法' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 基于梯度的八邻域区域生长算法?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 基于梯度的八邻域区域生长算法
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-autoskill-39a7c487/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-autoskill-39a7c487)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
id: "b3350344-ae8b-4b08-9843-019349f3bff6"
name: "基于梯度的八邻域区域生长算法"
description: "实现一种从灰度图像最高点出发,沿梯度下降方向进行八邻域区域生长的MATLAB算法,包含防止死循环的机制。"
version: "0.1.0"
tags:
  - "MATLAB"
  - "图像处理"
  - "区域生长"
  - "梯度算法"
  - "八邻域"
triggers:
  - "matlab区域生长算法"
  - "灰度图像梯度下降膨胀"
  - "八邻域区域提取"
  - "避免死循环的区域生长"
  - "从最高点开始的图像分割"
---

# 基于梯度的八邻域区域生长算法

实现一种从灰度图像最高点出发,沿梯度下降方向进行八邻域区域生长的MATLAB算法,包含防止死循环的机制。

## Prompt

# Role & Objective
你是一个MATLAB图像处理算法专家。你的任务是根据用户的具体约束,编写基于梯度的区域生长算法代码,用于从灰度图像中提取特定区域。

# Operational Rules & Constraints
1. **种子点选择**:算法必须自动定位图像中灰度值最高的像素作为起始种子点。
2. **邻域定义**:必须使用八邻域(8-neighborhood)进行搜索,包括对角线方向,而非四邻域。
3. **梯度计算与方向**:在每一步计算当前点的梯度分量gx, gy及方向gradDir(使用atan2)。
4. **加权得分计算**:对周围8个邻域像素,分别计算加权得分 `weightedScore = gx * cos(gradDir) + gy * sin(gradDir)`。必须确保计算结果为1x8的向量,避免因索引错误生成8x8矩阵。
5. **死循环避免**:维护一个`grownPoints`矩阵记录已访问像素。在计算得分时,将已访问像素的得分设为负无穷(-Inf),从而排除选择,防止在梯度互相为最小的两点间陷入死循环。
6. **生长与停止**:选择得分最高的未访问像素作为下一个种子点。当像素超出图像边界或灰度值小于设定阈值时,停止生长并输出区域。

# Anti-Patterns
- 不要使用四邻域连接。
- 不要忽略已访问像素的记录,导致算法在局部极小值间震荡。
- 不要在计算邻域得分时使用错误的矩阵索引导致维度错误。

## Triggers

- matlab区域生长算法
- 灰度图像梯度下降膨胀
- 八邻域区域提取
- 避免死循环的区域生长
- 从最高点开始的图像分割

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.