修复注释乱码
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
// ============================================================================
|
||||
// Copyright © 2026 Hexagon Technology Center GmbH. All Rights Reserved.
|
||||
// 文件� HorizontalEdgeProcessor.cs
|
||||
// 文件名: HorizontalEdgeProcessor.cs
|
||||
// 描述: 水平边缘检测算子,专门用于检测水平方向的边缘
|
||||
// 功能:
|
||||
// - 检测水平边�
|
||||
// - 检测水平边缘
|
||||
// - 支持Prewitt和Sobel算子
|
||||
// - 可调节检测灵敏度
|
||||
// - 适用于检测水平线条和纹理
|
||||
// 算法: Prewitt/Sobel水平算子
|
||||
// 作� �伟 wei.lw.li@hexagon.com
|
||||
// 作者: 李伟 wei.lw.li@hexagon.com
|
||||
// ============================================================================
|
||||
|
||||
using Emgu.CV;
|
||||
using Emgu.CV.CvEnum;
|
||||
using Emgu.CV.Structure;
|
||||
using Serilog;
|
||||
using XP.ImageProcessing.Core;
|
||||
using Serilog;
|
||||
|
||||
namespace XP.ImageProcessing.Processors;
|
||||
|
||||
/// <summary>
|
||||
/// 水平边缘检测算å?
|
||||
/// 水平边缘检测算子
|
||||
/// </summary>
|
||||
public class HorizontalEdgeProcessor : ImageProcessorBase
|
||||
{
|
||||
@@ -92,15 +92,15 @@ public class HorizontalEdgeProcessor : ImageProcessorBase
|
||||
|
||||
private Image<Gray, byte> ApplySobel(Image<Gray, byte> inputImage, double sensitivity, int threshold)
|
||||
{
|
||||
// 使用Sobelç®—å�检测水平边缘(Yæ–¹å�‘导数ï¼?
|
||||
// 使用Sobel算子检测水平边缘(Y方向导数)
|
||||
Image<Gray, float> sobelY = new Image<Gray, float>(inputImage.Size);
|
||||
CvInvoke.Sobel(inputImage, sobelY, DepthType.Cv32F, 0, 1, 3);
|
||||
|
||||
// 转�为�对值并应用���
|
||||
// 转换为绝对值并应用灵敏度
|
||||
Image<Gray, byte> result = new Image<Gray, byte>(inputImage.Size);
|
||||
CvInvoke.ConvertScaleAbs(sobelY, result, sensitivity, 0);
|
||||
|
||||
// 应用阈�
|
||||
// 应用阈值
|
||||
if (threshold > 0)
|
||||
{
|
||||
CvInvoke.Threshold(result, result, threshold, 255, ThresholdType.Binary);
|
||||
@@ -141,10 +141,10 @@ public class HorizontalEdgeProcessor : ImageProcessorBase
|
||||
sum -= inputData[y + 1, x, 0];
|
||||
sum -= inputData[y + 1, x + 1, 0];
|
||||
|
||||
// ��对值并应用���
|
||||
// 取绝对值并应用灵敏度
|
||||
int value = (int)(Math.Abs(sum) * sensitivity);
|
||||
|
||||
// 应用阈�
|
||||
// 应用阈值
|
||||
if (value > threshold)
|
||||
{
|
||||
outputData[y, x, 0] = (byte)Math.Min(255, value);
|
||||
@@ -161,11 +161,11 @@ public class HorizontalEdgeProcessor : ImageProcessorBase
|
||||
|
||||
private Image<Gray, byte> ApplySimple(Image<Gray, byte> inputImage, double sensitivity, int threshold)
|
||||
{
|
||||
// 简å�•差分算å?
|
||||
// 简单差分算子
|
||||
// [ 1 1 1]
|
||||
// [ 0 0 0]
|
||||
// [-1 -1 -1]
|
||||
// 但��更简�
|
||||
// 但权重更简单
|
||||
|
||||
int width = inputImage.Width;
|
||||
int height = inputImage.Height;
|
||||
@@ -182,7 +182,7 @@ public class HorizontalEdgeProcessor : ImageProcessorBase
|
||||
int diff = inputData[y - 1, x, 0] - inputData[y + 1, x, 0];
|
||||
int value = (int)(Math.Abs(diff) * sensitivity);
|
||||
|
||||
// 应用阈�
|
||||
// 应用阈值
|
||||
if (value > threshold)
|
||||
{
|
||||
outputData[y, x, 0] = (byte)Math.Min(255, value);
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
// ============================================================================
|
||||
// Copyright © 2026 Hexagon Technology Center GmbH. All Rights Reserved.
|
||||
// ��辣�? KirschEdgeProcessor.cs
|
||||
// �讛膩: Kirsch颲寧�璉�瘚讠�摮琜��其�璉�瘚见㦛�讛器蝻?
|
||||
// 文件名: KirschEdgeProcessor.cs
|
||||
// 描述: Kirsch边缘检测算子,用于检测图像边缘
|
||||
// 功能:
|
||||
// - Kirsch蝞堒�颲寧�璉�瘚?
|
||||
// - 8銝芣䲮�𤑳�颲寧�璉�瘚?
|
||||
// - Kirsch算子边缘检测
|
||||
// - 8个方向的边缘检测
|
||||
// - 输出最大响应方向的边缘
|
||||
// - 撖孵臁憯唳��笔漲雿?
|
||||
// 蝞埈�: Kirsch蝞堒�嚗?�孵�璅⊥踎嚗?
|
||||
// 雿𡏭�? �𦒘� wei.lw.li@hexagon.com
|
||||
// - 对噪声敏感度低
|
||||
// 算法: Kirsch算子(8方向模板)
|
||||
// 作者: 李伟 wei.lw.li@hexagon.com
|
||||
// ============================================================================
|
||||
|
||||
using Emgu.CV;
|
||||
using Emgu.CV.Structure;
|
||||
using Serilog;
|
||||
using XP.ImageProcessing.Core;
|
||||
using Serilog;
|
||||
|
||||
namespace XP.ImageProcessing.Processors;
|
||||
|
||||
/// <summary>
|
||||
/// Kirsch颲寧�璉�瘚讠�摮?
|
||||
/// Kirsch边缘检测算子
|
||||
/// </summary>
|
||||
public class KirschEdgeProcessor : ImageProcessorBase
|
||||
{
|
||||
private static readonly ILogger _logger = Log.ForContext<KirschEdgeProcessor>();
|
||||
|
||||
// Kirsch蝞堒��?銝芣䲮�烐芋�?
|
||||
// Kirsch算子的8个方向模板
|
||||
private static readonly int[][,] KirschKernels = new int[8][,]
|
||||
{
|
||||
// N
|
||||
@@ -86,14 +86,14 @@ public class KirschEdgeProcessor : ImageProcessorBase
|
||||
Image<Gray, byte> result = new Image<Gray, byte>(width, height);
|
||||
byte[,,] outputData = result.Data;
|
||||
|
||||
// 撖寞�銝芸�蝝惩��?銝枝irsch璅⊥踎嚗����憭批�摨?
|
||||
// 对每个像素应用8个Kirsch模板,取最大响应
|
||||
for (int y = 1; y < height - 1; y++)
|
||||
{
|
||||
for (int x = 1; x < width - 1; x++)
|
||||
{
|
||||
int maxResponse = 0;
|
||||
|
||||
// 撖?銝芣䲮�穃��怨恣蝞?
|
||||
// 对8个方向分别计算
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
int sum = 0;
|
||||
@@ -106,7 +106,7 @@ public class KirschEdgeProcessor : ImageProcessorBase
|
||||
}
|
||||
}
|
||||
|
||||
// �𣇉�撖孵�?
|
||||
// 取绝对值
|
||||
sum = Math.Abs(sum);
|
||||
if (sum > maxResponse)
|
||||
{
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
// ============================================================================
|
||||
// Copyright © 2026 Hexagon Technology Center GmbH. All Rights Reserved.
|
||||
// 文件� SobelEdgeProcessor.cs
|
||||
// æ��è¿°: Sobel边缘检测算å�,用于检测图åƒ�è¾¹ç¼?
|
||||
// 文件名: SobelEdgeProcessor.cs
|
||||
// 描述: Sobel边缘检测算子,用于检测图像边缘
|
||||
// 功能:
|
||||
// - Sobelç®—å�边缘检æµ?
|
||||
// - 支�X方��Y方�和组�检�
|
||||
// - Sobel算子边缘检测
|
||||
// - 支持X方向、Y方向和组合检测
|
||||
// - 可调节核大小
|
||||
// - 输出边缘强度�
|
||||
// - 输出边缘强度图
|
||||
// 算法: Sobel算子
|
||||
// 作� �伟 wei.lw.li@hexagon.com
|
||||
// 作者: 李伟 wei.lw.li@hexagon.com
|
||||
// ============================================================================
|
||||
|
||||
using Emgu.CV;
|
||||
using Emgu.CV.CvEnum;
|
||||
using Emgu.CV.Structure;
|
||||
using Serilog;
|
||||
using XP.ImageProcessing.Core;
|
||||
using Serilog;
|
||||
|
||||
namespace XP.ImageProcessing.Processors;
|
||||
|
||||
/// <summary>
|
||||
/// Sobel边缘检测算å?
|
||||
/// Sobel边缘检测算子
|
||||
/// </summary>
|
||||
public class SobelEdgeProcessor : ImageProcessorBase
|
||||
{
|
||||
@@ -96,7 +96,7 @@ public class SobelEdgeProcessor : ImageProcessorBase
|
||||
// 计算梯度幅值:sqrt(Gx^2 + Gy^2)
|
||||
Image<Gray, float> magnitude = new Image<Gray, float>(inputImage.Size);
|
||||
|
||||
// 手动计算幅�
|
||||
// 手动计算幅值
|
||||
for (int y = 0; y < inputImage.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < inputImage.Width; x++)
|
||||
|
||||
Reference in New Issue
Block a user