mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Treat pixels as unsigned and correct pixel count division.
PiperOrigin-RevId: 451428202
This commit is contained in:
parent
983e074fc9
commit
38720a6b6d
1 changed files with 4 additions and 4 deletions
|
|
@ -454,10 +454,10 @@ public final class SsimHelper {
|
||||||
double total = 0;
|
double total = 0;
|
||||||
for (int y = 0; y < windowHeight; y++) {
|
for (int y = 0; y < windowHeight; y++) {
|
||||||
for (int x = 0; x < windowWidth; x++) {
|
for (int x = 0; x < windowWidth; x++) {
|
||||||
total += pixelBuffer[get1dIndex(x, y, stride, bufferIndexOffset)];
|
total += pixelBuffer[get1dIndex(x, y, stride, bufferIndexOffset)] & 0xFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return total / windowWidth * windowHeight;
|
return total / (windowWidth * windowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calculates the variances and covariance of the pixels in the window for both buffers. */
|
/** Calculates the variances and covariance of the pixels in the window for both buffers. */
|
||||||
|
|
@ -476,8 +476,8 @@ public final class SsimHelper {
|
||||||
for (int y = 0; y < windowHeight; y++) {
|
for (int y = 0; y < windowHeight; y++) {
|
||||||
for (int x = 0; x < windowWidth; x++) {
|
for (int x = 0; x < windowWidth; x++) {
|
||||||
int index = get1dIndex(x, y, stride, bufferIndexOffset);
|
int index = get1dIndex(x, y, stride, bufferIndexOffset);
|
||||||
double referencePixelDeviation = referenceBuffer[index] - referenceMean;
|
double referencePixelDeviation = (referenceBuffer[index] & 0xFF) - referenceMean;
|
||||||
double distortedPixelDeviation = distortedBuffer[index] - distortedMean;
|
double distortedPixelDeviation = (distortedBuffer[index] & 0xFF) - distortedMean;
|
||||||
referenceVariance += referencePixelDeviation * referencePixelDeviation;
|
referenceVariance += referencePixelDeviation * referencePixelDeviation;
|
||||||
distortedVariance += distortedPixelDeviation * distortedPixelDeviation;
|
distortedVariance += distortedPixelDeviation * distortedPixelDeviation;
|
||||||
referenceDistortedCovariance += referencePixelDeviation * distortedPixelDeviation;
|
referenceDistortedCovariance += referencePixelDeviation * distortedPixelDeviation;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue