forked from amkovkov/GranuSightSoftware2
feat: FrameDecoder reserved flat-field correction
This commit is contained in:
@@ -159,8 +159,13 @@ public class BGGR_PISP_COMP1_RAW_FrameDecoder : IFrameDecoder // BGGR_PISP_COMP1
|
||||
int idx = y * width + x;
|
||||
double value = unpackedAvg[idx];
|
||||
|
||||
// Коррекция уровня чёрного
|
||||
value = Math.Max(0, value - blackLevel);
|
||||
|
||||
// Коррекция пересвета
|
||||
// value = value * FlatFieldCorrectionCoefficient(x, y, width, height);
|
||||
|
||||
// Коррекция цветовой температуры
|
||||
bool isBlue = (y % 2 == 0) && (x % 2 == 0);
|
||||
bool isRed = (y % 2 == 1) && (x % 2 == 1);
|
||||
|
||||
@@ -180,4 +185,19 @@ public class BGGR_PISP_COMP1_RAW_FrameDecoder : IFrameDecoder // BGGR_PISP_COMP1
|
||||
|
||||
return bgr;
|
||||
}
|
||||
|
||||
private static float FlatFieldCorrectionCoefficient(int x, int y, int width, int height)
|
||||
{
|
||||
var centerXShift = -0.01125904f;
|
||||
var centerYShift = 0.00997807f;
|
||||
var alpha = 2.0f;
|
||||
var beta = 1.0f;
|
||||
|
||||
var centerX = width / 2.0f + width * centerXShift;
|
||||
var centerY = height / 2.0f + height * centerYShift;
|
||||
|
||||
var distance = MathF.Sqrt(MathF.Pow(centerX - x, 2) + MathF.Pow(centerY - y, 2));
|
||||
distance /= MathF.Sqrt(MathF.Pow(width, 2) + MathF.Pow(height, 2));
|
||||
return alpha * distance + beta;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user