规范类名及命名空间名称
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
// ============================================================================
|
||||
// Copyright © 2026 Hexagon Technology Center GmbH. All Rights Reserved.
|
||||
// 文件� MultiplicationProcessor.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 MultiplicationProcessor : ImageProcessorBase
|
||||
{
|
||||
private static readonly ILogger _logger = Log.ForContext<MultiplicationProcessor>();
|
||||
|
||||
public MultiplicationProcessor()
|
||||
{
|
||||
Name = LocalizationHelper.GetString("MultiplicationProcessor_Name");
|
||||
Description = LocalizationHelper.GetString("MultiplicationProcessor_Description");
|
||||
}
|
||||
|
||||
protected override void InitializeParameters()
|
||||
{
|
||||
Parameters.Add("Multiplier", new ProcessorParameter(
|
||||
"Multiplier",
|
||||
LocalizationHelper.GetString("MultiplicationProcessor_Multiplier"),
|
||||
typeof(double),
|
||||
2.0,
|
||||
0.1,
|
||||
10.0,
|
||||
LocalizationHelper.GetString("MultiplicationProcessor_Multiplier_Desc")));
|
||||
|
||||
Parameters.Add("Normalize", new ProcessorParameter(
|
||||
"Normalize",
|
||||
LocalizationHelper.GetString("MultiplicationProcessor_Normalize"),
|
||||
typeof(bool),
|
||||
true,
|
||||
null,
|
||||
null,
|
||||
LocalizationHelper.GetString("MultiplicationProcessor_Normalize_Desc")));
|
||||
|
||||
_logger.Debug("InitializeParameters");
|
||||
}
|
||||
|
||||
public override Image<Gray, byte> Process(Image<Gray, byte> inputImage)
|
||||
{
|
||||
double multiplier = GetParameter<double>("Multiplier");
|
||||
bool normalize = GetParameter<bool>("Normalize");
|
||||
|
||||
var floatImage = inputImage.Convert<Gray, float>();
|
||||
var result = floatImage * multiplier;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ä¸�归一化时,直接截æ–到0-255范围
|
||||
result = result.ThresholdBinary(new Gray(255), new Gray(255));
|
||||
}
|
||||
|
||||
floatImage.Dispose();
|
||||
_logger.Debug("Process: Multiplier = {Multiplier}, Normalize = {Normalize}", multiplier, normalize);
|
||||
return result.Convert<Gray, byte>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user