Histogram equalization of image processing
Basic Idea :
Histogram equalization is a common image enhancement method in image processing, and the main advantage of histogram equalization is
It can reduce the image noise and enhance the local display of the image. For common RGB images, histogram equalization
Can be processed on three color channels respectively, the basic histogram equalization formula is:
Where NJ represents the number of pixels of the gray level RK, L for the total number of gray in the image, for RGB, L
The value range is [0~255] with a total gray level of 256. and R represents the histogram data for the input image. According to the loss
The gray value SK calculates the pixel value of the output pixel and completes the pixel processing after the histogram equalization.
Program Effect:
Source code:
Package com.gloomyfish.filter.study;
Import Java.awt.image.BufferedImage; public class Histogramefilter extends abstractbufferedimageop{@Override public bufferedimage filter (BufferedImage src,
BufferedImage dest) {int width = src.getwidth ();
int height = src.getheight ();
if (dest = = null) Dest = createcompatibledestimage (src, null);
int[] Inpixels = new Int[width*height];
int[] Outpixels = new Int[width*height];
getRGB (SRC, 0, 0, width, height, inpixels); int[][] Rgbhis = new int[3][256]; RGB int[][] newrgbhis = new int[3][256];
After him for (int i=0; i<3; i++) {for (int j=0; j<256; J + +) {Rgbhis[i][j] = 0;
NEWRGBHIS[I][J] = 0;
} int index = 0;
int totalpixelnumber = height * width;
for (int row=0; row
Reprint Please be sure to indicate