规范类名及命名空间名称

This commit is contained in:
李伟
2026-04-13 14:35:37 +08:00
parent c430ec229b
commit ace1c70ddf
217 changed files with 1271 additions and 1384 deletions
@@ -0,0 +1,95 @@
// ============================================================================
// Copyright © 2026 Hexagon Technology Center GmbH. All Rights Reserved.
// 文件å? IntegralProcessor.cs
// æè¿°: 积分è¿ç®—ç®—å­ï¼Œè®¡ç®—积分图åƒ?
// 功能:
// - 计算积分图åƒï¼ˆç´¯åŠ å’Œï¼?
// - 用于快速区域求�
// - 支æŒå½’一化输å‡?
// 算法: 积分图åƒç®—法
// 作è€? æŽä¼Ÿ wei.lw.li@hexagon.com
// ============================================================================
using Emgu.CV;
using Emgu.CV.Structure;
using Serilog;
using System.Drawing;
using XP.ImageProcessing.Core;
namespace XP.ImageProcessing.Processors;
/// <summary>
/// 积分è¿ç®—ç®—å­
/// </summary>
public class IntegralProcessor : ImageProcessorBase
{
private static readonly ILogger _logger = Log.ForContext<IntegralProcessor>();
public IntegralProcessor()
{
Name = LocalizationHelper.GetString("IntegralProcessor_Name");
Description = LocalizationHelper.GetString("IntegralProcessor_Description");
}
protected override void InitializeParameters()
{
Parameters.Add("Normalize", new ProcessorParameter(
"Normalize",
LocalizationHelper.GetString("IntegralProcessor_Normalize"),
typeof(bool),
true,
null,
null,
LocalizationHelper.GetString("IntegralProcessor_Normalize_Desc")));
_logger.Debug("InitializeParameters");
}
public override Image<Gray, byte> Process(Image<Gray, byte> inputImage)
{
bool normalize = GetParameter<bool>("Normalize");
int width = inputImage.Width;
int height = inputImage.Height;
// 使用double类型é¿å…溢出
var integralImage = new Image<Gray, double>(width, height);
// 计算积分图åƒ
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
double sum = inputImage.Data[y, x, 0];
if (x > 0)
sum += integralImage.Data[y, x - 1, 0];
if (y > 0)
sum += integralImage.Data[y - 1, x, 0];
if (x > 0 && y > 0)
sum -= integralImage.Data[y - 1, x - 1, 0];
integralImage.Data[y, x, 0] = sum;
}
}
var result = integralImage.Convert<Gray, float>();
if (normalize)
{
double minVal = 0, maxVal = 0;
Point minLoc = new Point();
Point maxLoc = new Point();
CvInvoke.MinMaxLoc(result, ref minVal, ref maxVal, ref minLoc, ref maxLoc);
if (maxVal > minVal)
{
result = (result - minVal) * (255.0 / (maxVal - minVal));
}
}
integralImage.Dispose();
_logger.Debug("Process: Normalize = {Normalize}", normalize);
return result.Convert<Gray, byte>();
}
}