Fix kernel construction
.fill(0) was missing
This commit is contained in:
@@ -129,7 +129,7 @@ const convertToCLIPInput = (imageData: ImageData) => {
|
||||
const scale = Math.max(requiredWidth / width, requiredHeight / height);
|
||||
|
||||
// Perform antialiasing if downscaling.
|
||||
const shouldAntiAlias = scale < 0.8;
|
||||
const antiAlias = scale < 0.8;
|
||||
|
||||
const scaledWidth = Math.round(width * scale);
|
||||
const scaledHeight = Math.round(height * scale);
|
||||
@@ -150,7 +150,7 @@ const convertToCLIPInput = (imageData: ImageData) => {
|
||||
pixelData,
|
||||
width,
|
||||
height,
|
||||
shouldAntiAlias,
|
||||
antiAlias,
|
||||
);
|
||||
clipInput[pi] = r / 255.0;
|
||||
clipInput[pi + cOffsetG] = g / 255.0;
|
||||
|
||||
@@ -321,7 +321,10 @@ const gaussianKernelRadius = Math.floor(gaussianKernelSize / 2);
|
||||
const gaussianSigma = 10.0;
|
||||
|
||||
const create2DGaussianKernel = (size: number, sigma: number): number[][] => {
|
||||
const kernel = Array(size).map(() => Array(size).fill(0) as number[]);
|
||||
const kernel = Array(size)
|
||||
.fill(0)
|
||||
.map(() => Array(size).fill(0) as number[]);
|
||||
|
||||
let sum = 0.0;
|
||||
const center = Math.floor(size / 2);
|
||||
|
||||
@@ -337,7 +340,7 @@ const create2DGaussianKernel = (size: number, sigma: number): number[][] => {
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize the kernel
|
||||
// Normalize the kernel.
|
||||
for (let y = 0; y < size; y++) {
|
||||
for (let x = 0; x < size; x++) {
|
||||
kernel[y]![x]! /= sum;
|
||||
|
||||
Reference in New Issue
Block a user