Skip to content

Commit d296bd3

Browse files
dakerfinetjul
authored andcommitted
fix(Convolution2DPass): fix default kernel size
1 parent a11970d commit d296bd3

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

  • Sources/Rendering/OpenGL/Convolution2DPass

Sources/Rendering/OpenGL/Convolution2DPass/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function vtkConvolution2DPass(publicAPI, model) {
1515
model.classHierarchy.push('vtkConvolution2DPass');
1616

1717
publicAPI.computeKernelWeight = function computeKernelWeight(kernel) {
18-
const weight = kernel.reduce((prev, curr) => prev + curr);
18+
const weight = kernel.reduce((prev, curr) => prev + curr, 0);
1919
return weight <= 0 ? 1 : weight;
2020
};
2121

@@ -34,12 +34,11 @@ function vtkConvolution2DPass(publicAPI, model) {
3434
}
3535

3636
// if no kernel is set, use the default kernel (no post-processing)
37+
const kernelLength = model.kernelDimension * model.kernelDimension;
3738
if (model.kernel === null) {
38-
model.kernel = new Float32Array(model.kernelDimension);
39-
model.kernel[Math.floor(model.kernelDimension / 2)] = 1;
39+
model.kernel = new Float32Array(kernelLength);
40+
model.kernel[Math.floor(kernelLength / 2)] = 1;
4041
}
41-
42-
const kernelLength = model.kernelDimension * model.kernelDimension;
4342
if (model.kernel.length !== kernelLength) {
4443
vtkErrorMacro(
4544
`The given kernel is invalid. 2D convolution kernels have to be 1D arrays with ${kernelLength} components representing the ${model.kernelDimension}x${model.kernelDimension} kernel in row-major form.`

0 commit comments

Comments
 (0)