修复注释乱码

This commit is contained in:
李伟
2026-04-14 17:11:31 +08:00
parent b8bcefc84b
commit cd03e30bb8
58 changed files with 761 additions and 767 deletions
@@ -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++)