14.8 round 1: coverage and Color Smoothness pinned by exact pixels

This commit is contained in:
ZacharyZhang-NY committed 2026-10-11 05:59:34 -04:00
1 parent 440bd1c9b0
commit a834076ca9
2 files changed
+25 -2

No files matched your search

+24 -1
View File
@@ -28,13 +28,25 @@ Measured measure(const QImage &image, int margin)
return {color / counted, brightness / counted};
}
CameraRawSettings colorNoise(double amount, double detail = 50)
CameraRawSettings colorNoise(double amount, double detail = 50, double smoothness = 50)
{
CameraRawSettings settings;
settings.detail.noiseColor = amount;
settings.detail.noiseColorDetail = detail;
settings.detail.noiseColorSmoothness = smoothness;
return settings;
}
// Red, then blue of some alpha from x 15.
QImage split(int blueAlpha)
{
QImage picture = BrushRaster::context(31, 21, false);
QPainter painter(&picture);
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.fillRect(QRect(0, 0, 15, 21), QColor(230, 51, 51));
painter.fillRect(QRect(15, 0, 16, 21), QColor(51, 51, 230, blueAlpha));
return picture;
}
}
class CameraRawColorNoiseTests : public QObject {
@@ -46,6 +58,7 @@ private slots:
void colorDetailKeepsARealColorEdge();
void aSpeckTakesTheColorAroundItAndKeepsItsBrightness();
void translucentPixelsKeepTheirColor();
void coverageWeighsNeighboursAndSmoothnessReaches();
};
void CameraRawColorNoiseTests::colorNoiseReductionRemovesColorGrainNotBrightness()
@@ -150,5 +163,15 @@ void CameraRawColorNoiseTests::translucentPixelsKeepTheirColor()
QVERIFY2(std::abs(after[channel] - before[channel]) <= 2, qPrintable(QStringLiteral("%1: %2 → %3").arg(channel).arg(before[channel]).arg(after[channel])));
}
void CameraRawColorNoiseTests::coverageWeighsNeighboursAndSmoothnessReaches()
{
// A faint blue pulls the red only by its coverage.
using Pixel = std::array<int, 4>;
QCOMPARE(pixels(colorNoise(100, 0).apply(split(32)))[size_t(10 * 31 + 14)], (Pixel{215, 53, 71, 255}));
// Smoothness widens the reach: none at 0, some at 100.
QCOMPARE(pixels(colorNoise(100, 0, 0).apply(split(255)))[size_t(10 * 31 + 9)], (Pixel{230, 51, 51, 255}));
QCOMPARE(pixels(colorNoise(100, 0, 100).apply(split(255)))[size_t(10 * 31 + 9)], (Pixel{203, 55, 87, 255}));
}
QTEST_MAIN(CameraRawColorNoiseTests)
#include "CameraRawColorNoiseTests.moc"