CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
140 lines
5.8 KiB
C#
140 lines
5.8 KiB
C#
using Chronos.Core.Codecs.Raw;
|
||
using Chronos.Core.Imaging;
|
||
using Chronos.Core.Mathematics;
|
||
using Chronos.Testing;
|
||
|
||
namespace Chronos.Core.Tests.Raw;
|
||
|
||
/// <summary>Demosaic accuracy against the full-colour scene a mosaic was sampled from.</summary>
|
||
public sealed class DemosaicTests(TestContext context)
|
||
{
|
||
/// <summary>Fujifilm X-Trans layout (6×6).</summary>
|
||
internal static readonly CfaPattern XTrans = new(6, 6,
|
||
[
|
||
1, 1, 0, 1, 1, 2,
|
||
1, 1, 2, 1, 1, 0,
|
||
2, 0, 1, 0, 2, 1,
|
||
1, 1, 2, 1, 1, 0,
|
||
1, 1, 0, 1, 1, 2,
|
||
0, 2, 1, 2, 0, 1,
|
||
]);
|
||
|
||
/// <summary>Smooth colour scene modelled like a photograph: luminance texture at 10–30 px periods multiplied by a
|
||
/// slowly varying chroma field (high frequencies correlate across channels, as in natural images).</summary>
|
||
private static ImageBuffer Scene(int w, int h)
|
||
{
|
||
var image = new ImageBuffer(w, h);
|
||
for (var y = 0; y < h; y++)
|
||
{
|
||
for (var x = 0; x < w; x++)
|
||
{
|
||
var l = 0.3 + 0.1 * double.Sin(x * 0.31 + y * 0.12) + 0.06 * double.Sin(y * 0.45 - x * 0.2) + 0.04 * double.Cos((x - y) * 0.6);
|
||
image[0, x, y] = (float)(l * (1 + 0.35 * double.Sin(x * 0.02 + 0.5)));
|
||
image[1, x, y] = (float)(l * (1 + 0.15 * double.Cos(y * 0.03)));
|
||
image[2, x, y] = (float)(l * (1 + 0.35 * double.Cos(x * 0.015 - y * 0.02)));
|
||
}
|
||
}
|
||
return image;
|
||
}
|
||
|
||
internal static ImageBuffer Mosaic(ImageBuffer scene, CfaPattern cfa)
|
||
{
|
||
var m = new ImageBuffer(scene.Width, scene.Height, 1);
|
||
for (var y = 0; y < scene.Height; y++)
|
||
{
|
||
for (var x = 0; x < scene.Width; x++) m[0, x, y] = scene[cfa.ColorAt(x, y), x, y];
|
||
}
|
||
return m;
|
||
}
|
||
|
||
[Theory]
|
||
[Case("RGGB")]
|
||
[Case("GBRG")]
|
||
public void AhdAndBilinearMeetTheirAccuracyGates(string layout)
|
||
{
|
||
var cfa = CfaPattern.Bayer(layout);
|
||
using var scene = Scene(256, 192);
|
||
using var mosaic = Mosaic(scene, cfa);
|
||
using var ahd = AhdDemosaic.Run(mosaic, cfa, Matrix3.Rec709ToXyz, -1, default);
|
||
using var bilinear = Demosaic.Bilinear(mosaic, cfa, -1, default);
|
||
var pAhd = SyntheticRaw.Psnr(scene, ahd, 2);
|
||
var pBilinear = SyntheticRaw.Psnr(scene, bilinear, 2);
|
||
context.Log($"{layout}: AHD {pAhd:F1} dB, bilinear {pBilinear:F1} dB");
|
||
Assert.GreaterOrEqual(pAhd, 38);
|
||
Assert.GreaterOrEqual(pBilinear, 32);
|
||
Assert.Greater(pAhd, pBilinear);
|
||
}
|
||
|
||
[Test]
|
||
public void AhdDoesNotZipperAlongEdges()
|
||
{
|
||
var cfa = CfaPattern.Bayer("RGGB");
|
||
using var scene = SyntheticRaw.Edges(128, 128);
|
||
using var mosaic = Mosaic(scene, cfa);
|
||
using var ahd = AhdDemosaic.Run(mosaic, cfa, Matrix3.Rec709ToXyz, -1, default);
|
||
using var bilinear = Demosaic.Bilinear(mosaic, cfa, -1, default);
|
||
var (zipAhd, fringeAhd) = EdgeArtefacts(ahd);
|
||
var (zipBilinear, fringeBilinear) = EdgeArtefacts(bilinear);
|
||
context.Log($"zipper AHD {zipAhd:F5} bilinear {zipBilinear:F5}; fringe AHD {fringeAhd:F5} bilinear {fringeBilinear:F5}");
|
||
Assert.Less(zipAhd, 0.002);
|
||
Assert.Less(fringeAhd, 0.002);
|
||
Assert.Less(fringeAhd, fringeBilinear);
|
||
}
|
||
|
||
[Test]
|
||
public void XTransNeighbourhoodInterpolationAndBinning()
|
||
{
|
||
using var scene = Scene(240, 180);
|
||
using var mosaic = Mosaic(scene, XTrans);
|
||
Assert.Equal(3, XTrans.BinSize);
|
||
Assert.False(XTrans.IsBayer);
|
||
using var full = Demosaic.Neighbourhood(mosaic, XTrans, -1, default);
|
||
var psnr = SyntheticRaw.Psnr(scene, full, 2);
|
||
using var third = Demosaic.Bin(mosaic, XTrans, 3, -1, default);
|
||
using var expected = Resampler.Resize(scene, 80, 60, ResampleFilter.Box);
|
||
var binned = SyntheticRaw.Psnr(expected, third, 1);
|
||
context.Log($"X-Trans neighbourhood {psnr:F1} dB, binned {binned:F1} dB");
|
||
Assert.GreaterOrEqual(psnr, 34);
|
||
Assert.GreaterOrEqual(binned, 34);
|
||
}
|
||
|
||
[Test]
|
||
public void PatternReductionAndShift()
|
||
{
|
||
var bayer = new CfaPattern(4, 4, [0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2]);
|
||
Assert.Equal(2, bayer.Width);
|
||
Assert.True(bayer.IsBayer);
|
||
Assert.Equal("RGGB", bayer.ToString());
|
||
Assert.Equal("GRBG", bayer.Shift(1, 0).ToString());
|
||
Assert.Equal("BGGR", bayer.Shift(-1, -1).ToString());
|
||
Assert.Throws<InvalidDataException>(() => new CfaPattern(2, 2, [0, 1, 1, 1]));
|
||
Assert.Throws<InvalidDataException>(() => new CfaPattern(2, 2, [0, 1, 3, 2]));
|
||
}
|
||
|
||
/// <summary>Zipper: second difference along each edge; fringe: chroma |R−G| + |B−G| next to the edges of a gray scene.</summary>
|
||
private static (double Zipper, double Fringe) EdgeArtefacts(ImageBuffer image)
|
||
{
|
||
double zipper = 0, fringe = 0;
|
||
var n = 0;
|
||
int w = image.Width, h = image.Height;
|
||
for (var d = -2; d <= 1; d++)
|
||
{
|
||
for (var k = 8; k < h - 8; k++)
|
||
{
|
||
if (k is > 56 and < 72) continue;
|
||
// Vertical edge at x = w/2 (columns w/2-2 .. w/2+1), and horizontal edge at y = h/2.
|
||
int vx = w / 2 + d, hy = h / 2 + d;
|
||
for (var c = 0; c < 3; c++)
|
||
{
|
||
zipper += double.Abs(image[c, vx, k] - (image[c, vx, k - 1] + image[c, vx, k + 1]) / 2);
|
||
zipper += double.Abs(image[c, k, hy] - (image[c, k - 1, hy] + image[c, k + 1, hy]) / 2);
|
||
}
|
||
fringe += double.Abs(image[0, vx, k] - image[1, vx, k]) + double.Abs(image[2, vx, k] - image[1, vx, k]);
|
||
fringe += double.Abs(image[0, k, hy] - image[1, k, hy]) + double.Abs(image[2, k, hy] - image[1, k, hy]);
|
||
n += 2;
|
||
}
|
||
}
|
||
return (zipper / (3 * n), fringe / n);
|
||
}
|
||
}
|