Histogram equalization is to make the histogram of the image as average as possible, so that the probability of each 0-255 is equal. The formula is as follows:
#This proof can be found in any image processing textbook. The implementation code is provided below:
public void histequalization(){ toGray(); double[] hist = math.Norm(hist()); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { this.data[x + y * w] = (int)(math.sum(hist, this.data[x + y * w])*255); //上面公式 } } }
The results are as follows:
Original picture: