npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

n8n-nodes-canopyrate

v0.1.0

Published

N8N node for calculating rice canopy coverage rate

Readme

N8N Canopy Rate Node

用于计算水稻冠层覆盖率的N8N自定义节点。

功能特性

  • ✅ 支持从文件路径或二进制数据读取图像
  • ✅ 使用超绿法(ExG)进行植被分割
  • ✅ OTSU自动阈值处理
  • ✅ 形态学操作去噪
  • ✅ 支持JSON和CSV输出格式
  • ✅ 支持中文路径
  • ✅ 简单的配置和安装

安装详细步骤

前提条件

  • 已安装Node.js和npm
  • 已安装n8n并知道n8n的安装目录

方法1:npm link方式(推荐用于开发测试)

步骤1:在节点目录创建全局链接

# 进入节点项目目录
cd d:\Workspace
odes\canopyrate

# 创建全局链接(需要管理员权限)
npm link

这会在全局npm模块目录创建一个符号链接。

步骤2:在n8n目录链接节点

# 进入n8n安装目录(根据您的n8n安装位置)
cd C:\Users\12573\AppData\Roaming
pm
ode_modules
8n
# 或者如果是全局安装:
cd C:\Program Files
odejs
ode_modules
8n

# 链接节点到n8n
npm link n8n-nodes-canopyrate

步骤3:验证链接

# 检查n8n的node_modules目录
ls node_modules | grep canopyrate
# 应该能看到n8n-nodes-canopyrate

# 检查链接是否正确
npm ls n8n-nodes-canopyrate

方法2:直接安装方式(推荐用于生产环境)

步骤1:打包节点

# 在节点目录
cd d:\Workspace
odes\canopyrate
npm pack

这会生成一个 .tgz 文件,如 n8n-nodes-canopyrate-0.1.0.tgz

步骤2:在n8n目录安装

# 进入n8n安装目录
cd /path/to/n8n

# 安装节点包
npm install /path/to/n8n-nodes-canopyrate-0.1.0.tgz

方法3:从GitHub安装(如果已上传到仓库)

cd /path/to/n8n
npm install github:your-username/n8n-nodes-canopyrate

重启n8n服务

安装完成后,必须重启n8n服务:

# 如果使用pm2
pm2 restart n8n

# 如果使用systemd
sudo systemctl restart n8n

# 如果直接运行
# 先停止n8n进程,然后重新启动

验证安装

  1. 重启n8n后,访问n8n界面
  2. 创建工作流,在节点列表中找到"Canopy Rate Calculator"
  3. 测试节点:配置图像路径或连接图像输入节点

常见问题解决

问题1:npm link权限不足

# Windows: 以管理员身份运行PowerShell
# Linux/Mac: 使用sudo
sudo npm link

问题2:链接后节点不显示

  • 检查n8n日志文件查看错误信息
  • 确认节点包名在package.json中正确
  • 重启n8n服务

问题3:依赖冲突

# 在n8n目录重新安装依赖
npm install
# 或清除缓存
npm cache clean --force

开发模式调试

如果要在开发过程中实时调试,可以使用:

# 在节点目录
npm run dev

# 在n8n目录使用nodemon自动重启
npm install -g nodemon
nodemon --watch ../canopyrate --exec "npm start"

使用方法

基本配置

  1. 在n8n工作流中添加"Canopy Rate Calculator"节点
  2. 选择图像来源:
    • Binary Data: 从前置节点的二进制数据获取图像
    • File Path: 直接指定图像文件路径
  3. 选择输出格式:JSON或CSV
  4. 配置可选参数(阈值方法、固定阈值、最小覆盖率等)

输入要求

  • 支持的图像格式:JPG, JPEG, PNG, BMP, TIFF
  • 建议图像分辨率:不低于640x480像素
  • 图像应包含清晰的植被区域

输出结果

JSON格式输出包含:

{
  "data_name": "image.jpg",
  "canopy_rate_percent": 45.67,
  "total_area": 307200,
  "leaf_area": 140256,
  "image_width": 640,
  "image_height": 480,
  "timestamp": "2024-01-01T12:00:00.000Z"
}

CSV格式输出包含相同数据的CSV文件。

技术原理

节点使用以下算法计算冠层覆盖率:

  1. 颜色空间转换: 读取RGB图像
  2. 超绿法(ExG): 2.5*G - R - B 增强绿色植被区域
  3. 阈值分割: 自动或固定阈值进行二值化
  4. 面积计算: 统计植被像素占比

开发

项目结构

canopyrate/
├── nodes/
│   └── CanopyRate/
│       └── CanopyRate.node.js  # 主要节点代码
├── index.js                    # 模块导出
├── package.json               # 项目配置
└── README.md                   # 说明文档

构建项目

npm run build

依赖项

  • jimp: 图像处理库
  • n8n-workflow: N8N工作流库
  • n8n-core: N8N核心库

许可证

MIT License

技术支持

如有问题或建议,请参考n8n官方文档或提交issue。