点像のサンプラーの瞳関数の格子を光の通る行だけにする
・点像分布関数の計算で使う瞳関数の格子を光の通る行だけにして、使用メモリを削減-M
このコミットが含まれているのは:
2ファイル変更
+13
-10
検索条件に一致するファイルはありません
@@ -16,17 +16,19 @@ internal sealed class FraunhoferKernelSampler
|
||||
public bool TryComputeIntensity(in PsfSpecification specification, double pupilDiameter, double phaseScale, ReadOnlySpan<double> positionScales)
|
||||
{
|
||||
var gridSize = specification.PupilGridSize;
|
||||
EnsureCapacity(gridSize);
|
||||
|
||||
var center = gridSize / 2;
|
||||
var reach = (int)(pupilDiameter / 2d);
|
||||
var firstRow = Math.Max(center - reach, 0);
|
||||
var lastRow = Math.Min(center + reach, gridSize - 1);
|
||||
if (FraunhoferPsfGenerator.BuildPupil(in specification, pupilDiameter, phaseScale, grid.Real, grid.Imaginary, firstRow, lastRow) == 0)
|
||||
EnsureCapacity(gridSize, lastRow - firstRow + 1);
|
||||
if (FraunhoferPsfGenerator.BuildPupil(in specification, pupilDiameter, phaseScale, grid.Real, grid.Imaginary, firstRow, lastRow, firstRow) == 0)
|
||||
return false;
|
||||
|
||||
for (var row = firstRow; row <= lastRow; row++)
|
||||
FastFourierTransform.Forward(grid.Real.Slice(row * gridSize, gridSize), grid.Imaginary.Slice(row * gridSize, gridSize));
|
||||
{
|
||||
var offset = (row - firstRow) * gridSize;
|
||||
FastFourierTransform.Forward(grid.Real.Slice(offset, gridSize), grid.Imaginary.Slice(offset, gridSize));
|
||||
}
|
||||
|
||||
MarkSampledColumns(in specification, center, positionScales);
|
||||
for (var shiftedColumn = 0; shiftedColumn < gridSize; shiftedColumn++)
|
||||
@@ -63,8 +65,9 @@ internal sealed class FraunhoferKernelSampler
|
||||
columnImaginary[..firstRow].Clear();
|
||||
for (var row = firstRow; row <= lastRow; row++)
|
||||
{
|
||||
columnReal[row] = real[row * gridSize + column];
|
||||
columnImaginary[row] = imaginary[row * gridSize + column];
|
||||
var index = (row - firstRow) * gridSize + column;
|
||||
columnReal[row] = real[index];
|
||||
columnImaginary[row] = imaginary[index];
|
||||
}
|
||||
|
||||
columnReal.Slice(lastRow + 1, gridSize - lastRow - 1).Clear();
|
||||
@@ -103,10 +106,10 @@ internal sealed class FraunhoferKernelSampler
|
||||
}
|
||||
}
|
||||
|
||||
void EnsureCapacity(int gridSize)
|
||||
void EnsureCapacity(int gridSize, int pupilRows)
|
||||
{
|
||||
var area = gridSize * gridSize;
|
||||
grid.Ensure(area);
|
||||
grid.Ensure(pupilRows * gridSize);
|
||||
line.Ensure(gridSize);
|
||||
if (intensity.Length < area)
|
||||
intensity = new double[area];
|
||||
|
||||
@@ -77,7 +77,7 @@ public sealed class FraunhoferPsfGenerator : IPsfGenerator
|
||||
internal static int BuildPupil(in PsfSpecification specification, Span<double> real, Span<double> imaginary, int firstRow, int lastRow)
|
||||
=> BuildPupil(in specification, specification.PupilDiameterSamples, 1d, real, imaginary, firstRow, lastRow);
|
||||
|
||||
internal static int BuildPupil(in PsfSpecification specification, double pupilDiameter, double phaseScale, Span<double> real, Span<double> imaginary, int firstRow, int lastRow)
|
||||
internal static int BuildPupil(in PsfSpecification specification, double pupilDiameter, double phaseScale, Span<double> real, Span<double> imaginary, int firstRow, int lastRow, int storedFirstRow = 0)
|
||||
{
|
||||
var gridSize = specification.PupilGridSize;
|
||||
var center = gridSize / 2;
|
||||
@@ -91,7 +91,7 @@ public sealed class FraunhoferPsfGenerator : IPsfGenerator
|
||||
for (var y = firstRow; y <= lastRow; y++)
|
||||
{
|
||||
var normalizedY = (y - center) / pupilRadius;
|
||||
var row = y * gridSize;
|
||||
var row = (y - storedFirstRow) * gridSize;
|
||||
real.Slice(row, firstColumn).Clear();
|
||||
imaginary.Slice(row, firstColumn).Clear();
|
||||
for (var x = firstColumn; x <= lastColumn; x++)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする