Switched to ThumbHasher over BlurHasher
This commit is contained in:
@ -56,15 +56,15 @@ public static class Core
|
||||
{
|
||||
double basis = xCosines[xPixel] * yCosines[yPixel];
|
||||
Pixel pixel = pixels[xPixel, yPixel];
|
||||
r += basis * pixel._Red;
|
||||
g += basis * pixel._Green;
|
||||
b += basis * pixel._Blue;
|
||||
r += basis * pixel.Red;
|
||||
g += basis * pixel.Green;
|
||||
b += basis * pixel.Blue;
|
||||
}
|
||||
|
||||
double scale = normalization / (width * height);
|
||||
factors[componentsX * yComponent + xComponent]._Red = r * scale;
|
||||
factors[componentsX * yComponent + xComponent]._Green = g * scale;
|
||||
factors[componentsX * yComponent + xComponent]._Blue = b * scale;
|
||||
factors[componentsX * yComponent + xComponent].Red = r * scale;
|
||||
factors[componentsX * yComponent + xComponent].Green = g * scale;
|
||||
factors[componentsX * yComponent + xComponent].Blue = b * scale;
|
||||
|
||||
progressCallback?.Report(processedFactors * 100 / factorCount);
|
||||
processedFactors++;
|
||||
@ -90,9 +90,9 @@ public static class Core
|
||||
|
||||
int factorIndex = componentsX * yComponent + xComponent;
|
||||
|
||||
actualMaximumValue = Math.Max(Math.Abs(factors[factorIndex]._Red), actualMaximumValue);
|
||||
actualMaximumValue = Math.Max(Math.Abs(factors[factorIndex]._Green), actualMaximumValue);
|
||||
actualMaximumValue = Math.Max(Math.Abs(factors[factorIndex]._Blue), actualMaximumValue);
|
||||
actualMaximumValue = Math.Max(Math.Abs(factors[factorIndex].Red), actualMaximumValue);
|
||||
actualMaximumValue = Math.Max(Math.Abs(factors[factorIndex].Green), actualMaximumValue);
|
||||
actualMaximumValue = Math.Max(Math.Abs(factors[factorIndex].Blue), actualMaximumValue);
|
||||
}
|
||||
|
||||
int quantizedMaximumValue = (int)Math.Max(0.0, Math.Min(82.0, Math.Floor(actualMaximumValue * 166 - 0.5)));
|
||||
@ -105,7 +105,7 @@ public static class Core
|
||||
resultBuffer[1] = '0';
|
||||
}
|
||||
|
||||
EncodeDc(dc._Red, dc._Green, dc._Blue).EncodeBase83(resultBuffer.Slice(2, 4));
|
||||
EncodeDc(dc.Red, dc.Green, dc.Blue).EncodeBase83(resultBuffer.Slice(2, 4));
|
||||
|
||||
for (int yComponent = 0; yComponent < componentsY; yComponent++)
|
||||
for (int xComponent = 0; xComponent < componentsX; xComponent++)
|
||||
@ -116,7 +116,7 @@ public static class Core
|
||||
|
||||
int factorIndex = componentsX * yComponent + xComponent;
|
||||
|
||||
EncodeAc(factors[factorIndex]._Red, factors[factorIndex]._Green, factors[factorIndex]._Blue, maximumValue).EncodeBase83(resultBuffer.Slice(6 + (factorIndex - 1) * 2, 2));
|
||||
EncodeAc(factors[factorIndex].Red, factors[factorIndex].Green, factors[factorIndex].Blue, maximumValue).EncodeBase83(resultBuffer.Slice(6 + (factorIndex - 1) * 2, 2));
|
||||
}
|
||||
|
||||
return resultBuffer.ToString();
|
||||
@ -184,9 +184,9 @@ public static class Core
|
||||
{
|
||||
ref Pixel result = ref pixels[xPixel, yPixel];
|
||||
|
||||
result._Red = 0.0;
|
||||
result._Green = 0.0;
|
||||
result._Blue = 0.0;
|
||||
result.Red = 0.0;
|
||||
result.Green = 0.0;
|
||||
result.Blue = 0.0;
|
||||
}
|
||||
|
||||
double[] xCosines = new double[outputWidth];
|
||||
@ -215,9 +215,9 @@ public static class Core
|
||||
|
||||
double basis = xCosines[xPixel] * yCosines[yPixel];
|
||||
|
||||
result._Red += coefficient._Red * basis;
|
||||
result._Green += coefficient._Green * basis;
|
||||
result._Blue += coefficient._Blue * basis;
|
||||
result.Red += coefficient.Red * basis;
|
||||
result.Green += coefficient.Green * basis;
|
||||
result.Blue += coefficient.Blue * basis;
|
||||
}
|
||||
|
||||
progressCallback?.Report(componentIndex * 100 / componentCount);
|
||||
|
@ -5,14 +5,14 @@
|
||||
/// </summary>
|
||||
public struct Pixel
|
||||
{
|
||||
public double _Red;
|
||||
public double _Green;
|
||||
public double _Blue;
|
||||
public double Red { get; set; }
|
||||
public double Green { get; set; }
|
||||
public double Blue { get; set; }
|
||||
|
||||
public Pixel(double red, double green, double blue)
|
||||
{
|
||||
_Red = red;
|
||||
_Green = green;
|
||||
_Blue = blue;
|
||||
Red = red;
|
||||
Green = green;
|
||||
Blue = blue;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user