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.
are there any better ways for histogram equalization in js?
CodePudding user response:
you can use histogram equalization with color images:
- cvtConvert() to hsv (not grayscale)
- split() the hsv image into seperate h,s,v planes
- apply equalizeHist() on the V (grayscale intensity) channel
- merge() hsv planes back
- cvtConvert() back to RGBA