优化:修复Logger类型错误,重写CLAHE算法,像素遍历改用unsafe指针加速

This commit is contained in:
李伟
2026-05-26 13:28:52 +08:00
parent 82b7c32147
commit 030433cc92
5 changed files with 140 additions and 53 deletions
@@ -125,18 +125,28 @@ public class VoidMeasurementProcessor : ImageProcessorBase
// ── 双阈值分割提取气泡(亮区域) ──
var voidImg = new Image<Gray, byte>(w, h);
byte[,,] srcData = blurred.Data;
byte[,,] dstData = voidImg.Data;
byte[,,] maskData = roiMask.Data;
for (int y = 0; y < h; y++)
unsafe
{
for (int x = 0; x < w; x++)
byte* srcPtr = (byte*)blurred.Mat.DataPointer;
byte* dstPtr = (byte*)voidImg.Mat.DataPointer;
byte* mskPtr = (byte*)roiMask.Mat.DataPointer;
int srcStep = blurred.Mat.Step;
int dstStep = voidImg.Mat.Step;
int mskStep = roiMask.Mat.Step;
for (int y = 0; y < h; y++)
{
if (maskData[y, x, 0] > 0)
byte* srcRow = srcPtr + y * srcStep;
byte* dstRow = dstPtr + y * dstStep;
byte* mskRow = mskPtr + y * mskStep;
for (int x = 0; x < w; x++)
{
byte val = srcData[y, x, 0];
dstData[y, x, 0] = (val >= minThresh && val <= maxThresh) ? (byte)255 : (byte)0;
if (mskRow[x] > 0)
{
byte val = srcRow[x];
dstRow[x] = (val >= minThresh && val <= maxThresh) ? (byte)255 : (byte)0;
}
}
}
}