Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

379
Views
Using histogram equalization in color image in js

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.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

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
about 4 years ago · Juan Pablo Isaza Report

0

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();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!