What is the difference between cv :: equalizeHist and matlab histeq ()

A very simple question, but I'm confused. Can anyone please explain if there is a difference between Matlab's histeq () function and Opencv's cv :: equalizeHist () function.

As I try to apply histogram alignment in Matlab on the image, but I found out that the result is not the same, there is a difference of about 4-6 in each pixel value. Especially the first 2 pixels of the line. and less than 1 or 2 differences in other pixels. for example for the same image openCV results in

100160210240

But Matlab returns

97, 159, 210, 240.

even i tried using histeq (image, 255); or histeq (image, 256); but even the same thing. Who cares? Thank you in advance.

+3


source to share


2 answers


This may be because Matlab uses a constraint stating that a grayscale transform cannot exceed the cumulative histogram of your image by more than half the distance between histogram counts for a given intensity. You have more details about the algorithms used by Matlab here (at the bottom of the page in the "Algorithm" section) and OpenCV here .



+4


source


Matlab's histeq function gives you a couple of input options: 1) J = histeq(I, hgram)

- the J output will approximate a user-defined histogram and 2) J = histeq(I, n)

- the J output will approximate a flat histogram by default, but with n discrete gray levels. If n is omitted, the default number of levels is 64. OpenCV equalizeHist (src, dst) doesn't give you any of these options; it turns out that it assumes 256 gray levels. So if you try J = histeq(I, 256)

your result will match opencv.



0


source







All Articles