Apply simple convolution with tensorflow JS

Writing a simple code to understand how convolutions work.

Is there any basic step that is wrong?
I know that the pixel values will be wrong but how to fix this? Is it an option or an extra operation?

import * as tf from "@tensorflow/tfjs-node"
import { readFile, writeFile } from "node:fs/promises"

async function mainModule() {

    const img = tf.node.decodeImage(await readFile("./greyscale.png"), 1) as tf.Tensor3D;

    const result = img.div(255).conv2d(
        tf.tensor4d([-1, 2, -1,
        -1, 2, -1,
        -1, 2, -1,
        ], [1, 1, 3, 3], "float32").div(6) as tf.Tensor4D, 1, "same") as tf.Tensor3D


    const data = await tf.node.encodePng(result)

    await writeFile("./result.png", data)
}

mainModule()

Finally solved it here Simple convolution operation with tensorflow js - Stack Overflow

Still, would be great to have some advice if this isn’t the right code. I can’t really get why we reshape [1, 1, 3, 3]