justadudewhohacks / justadudewhohacks/opencv4nodejs

cv.LUT is not a function

Open
#524 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5.1k
Forks
826
PR merge metrics
No merged PRs in 30d

Description

Hello Vincent,

I have been using opencv4nodejs for a while now for quite a few of opencv operations done on the web and it's been working great. I've recently been required to implement cv.LUT function which I cannot see any help online in opencv4nodejs repository and also in my code it gives me "cv.LUT is not a function" error. Could you please advise on how I can achieve this or use an alternative way to get the step done that LUT function does? My lines of code are below (the error is on 7th to the last line of the function). The function is just test function and the quality is not that high for now so I apologize for that in advance

```
function histMatchRGB(currentMat, src_mask, dstMat, dst_mask){
var currentMatchannels;
if(currentMat.channels < 3 || dstMat.channels < 3 || dstMat.channels != currentMat.channels){
// Channels do not match or one of the images is not the color image
return [];
console.log("Error")
}else{
let HISTMATCH_EPSILON = 0.000001
var currentMatchannels = currentMat.splitChannels();
var dstMatchannels = dstMat.splitChannels();
let numChannels = dstMat.channels;
var errorImage = new cv.Mat(1, 1, cv.CV_8U, 0);
var src_hist = new cv.Mat(1, 256, cv.CV_64FC1, 0);
var dst_hist = new cv.Mat(1, 256, cv.CV_64FC1, 0);
var src_cdf = new cv.Mat(1, 256, cv.CV_64FC1, 0);
var dst_cdf = new cv.Mat(1, 256, cv.CV_64FC1, 0);

var _src_hist = new cv.Mat(1, 256, cv.CV_64FC1, 0);
var _dst_hist = new cv.Mat(1, 256, cv.CV_64FC1, 0);
var _src_cdf = new cv.Mat(1, 256, cv.CV_64FC1, 0);
var _dst_cdf = new cv.Mat(1, 256, cv.CV_64FC1, 0);

var Mv = new cv.Mat(1, 256, cv.CV_8UC1, 0);
var M = Mv.copy();

for (var i = 0; i < numChannels; i++) {
src_hist = src_hist.and(new cv.Mat(1, 256, cv.CV_64FC1, 0));
dst_hist = dst_hist.and(new cv.Mat(1, 256, cv.CV_64FC1, 0));
src_cdf = src_cdf.and(new cv.Mat(1, 256, cv.CV_64FC1, 0));
dst_cdf = dst_cdf.and(new cv.Mat(1, 256, cv.CV_64FC1, 0));

let last = 0;
var h = do1ChnHist(currentMatchannels[i], src_mask, _src_hist, _src_cdf);
_src_hist = h[0];
_src_cdf = h[1];
h = do1ChnHist(dstMatchannels[i], dst_mask, _dst_hist, _dst_cdf);
_dst_hist = h[0];
_dst_cdf = h[1];

for (var j = 0; j F1j) {
M[j] = k;
last = k;
break;
}
}
}
var lut = new cv.Mat(1, 256, cv.CV_8UC1, M);
currentMatchannels[i] = cv.LUT(currentMatchannels[i], lut);
}
var outMat = new cv.Mat(currentMatchannels[0], currentMatchannels[1], currentMatchannels[2])
cv.imwrite("illuminationAdjusted.jpg",outMat);
}
return outMat;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.