Normalize a matrix with opencv.js

I want to normalize a Mat object using the native methods of opencv.js.

I have tried with “cv.multiply” or “cv.gemm” but I don’t know how to use them properly with CV_32FC1 matrix.

In the meantime I use a loop to apply normalization to each pixel value but it seems poorly optimized.

How to properly use “cv.multiply”, “cv.gemm” or other method to replace unsupported arithmetic operators in JavaScript with opencv.js?

In C++:

double maxVal;
minMaxLoc(mat, NULL, &maxVal);
mat = 128 * mat / maxVal;

In JavaScript (but not optimized):

let maxVal = cv.minMaxLoc(mat).maxVal;
for (let i = 0; i < mat.rows; i++) {
	for (let j = 0; j < mat.cols; j++) {
		mat.floatPtr(i, j)[0] = 128 * mat.floatPtr(i, j)[0] / maxVal;

use normalize with NORM_MINMAX