I want to use OpenCV histogram equalization with color image output but I didn't find a way to do this. here is the tutorial: https://docs.opencv.org/3.4/d2/d74/tutorial_js_histogram_equalization.html
let src = cv.imread('canvasInput');
let dst = new cv.Mat();
cv.cvtColor(src, src, cv.COLOR_RGBA2GRAY, 0);
cv.equalizeHist(src, dst);
cv.imshow('canvasOutput', src);
cv.imshow('canvasOutput', dst);
src.delete(); dst.delete();
this code converts image to gray.
you can use histogram equalization with color images:
Here is the answer I found with @berak help. this will equalize histogram for color images
let imgElement = document.getElementById("ImgViewImage"); // img element with ImgViewImage id
let src = cv.imread(imgElement);
let dst = new cv.Mat();
let hsvPlanes = new cv.MatVector();
let mergedPlanes = new cv.MatVector();
cv.cvtColor(src, src, cv.COLOR_RGB2HSV, 0);
cv.split(src, hsvPlanes);
let H = hsvPlanes.get(0);
let S = hsvPlanes.get(1);
let V = hsvPlanes.get(2);
cv.equalizeHist(V, V);
mergedPlanes.push_back(H);
mergedPlanes.push_back(S);
mergedPlanes.push_back(V);
cv.merge(mergedPlanes, src);
cv.cvtColor(src, dst, cv.COLOR_HSV2RGB, 0);
cv.imshow("canvasOutput", dst); // canavas element with canvasOutput id
src.delete();
dst.delete();
hsvPlanes.delete();
mergedPlanes.delete();